Custom xblock won't install in dev

I’m working on testing my existing xblocks in tutor version 10.4.0. They have been running fine in version 3.6. For some reason, one of the xblocks will not show in the Advanced Component list in CMS

My Advanced Module List on the Advanced Settings page is set to:
[
“assignmentregrade”,
“codeeditor”,
“codingproblem”,
“invideoquiz”,
“visualizer”,
“terms”,
“deadline”,
“racketstepper”
]

My private.txt file to looks like the following:

-e ./assignmentregrade
-e ./racketstepper
-e ./codeeditor
-e ./visualizer
-e ./codingproblem
-e ./coderevealer
-e ./terms
-e ./deadline

When I build the images with:
tutor images build openedx

I can see the xblocks being installed:

...
Obtaining file:///openedx/requirements/assignmentregrade (from -r ./private.txt (line 1))
Obtaining file:///openedx/requirements/racketstepper (from -r ./private.txt (line 2))
Obtaining file:///openedx/requirements/codeeditor (from -r ./private.txt (line 3))
Obtaining file:///openedx/requirements/visualizer (from -r ./private.txt (line 4))
Obtaining file:///openedx/requirements/codingproblem (from -r ./private.txt (line 5))
Obtaining file:///openedx/requirements/coderevealer (from -r ./private.txt (line 6))
Obtaining file:///openedx/requirements/terms (from -r ./private.txt (line 7))
Obtaining file:///openedx/requirements/deadline (from -r ./private.txt (line 8))
Requirement already satisfied: XBlock in /openedx/venv/lib/python3.5/site-packages (from assignmentregrade-xblock==0.1->-r ./private.txt (line 1)) (1.3.1)
Requirement already satisfied: web-fragments in /openedx/venv/lib/python3.5/site-packages (from XBlock->assignmentregrade-xblock==0.1->-r ./private.txt (line 1)) (0.3.2)
Requirement already satisfied: pyyaml in /openedx/venv/lib/python3.5/site-packages (from XBlock->assignmentregrade-xblock==0.1->-r ./private.txt (line 1)) (5.3.1)
Requirement already satisfied: markupsafe in /openedx/venv/lib/python3.5/site-packages (from XBlock->assignmentregrade-xblock==0.1->-r ./private.txt (line 1)) (1.1.1)
Requirement already satisfied: six in /openedx/venv/lib/python3.5/site-packages (from XBlock->assignmentregrade-xblock==0.1->-r ./private.txt (line 1)) (1.14.0)
Requirement already satisfied: webob in /openedx/venv/lib/python3.5/site-packages (from XBlock->assignmentregrade-xblock==0.1->-r ./private.txt (line 1)) (1.8.6)
Requirement already satisfied: python-dateutil in /openedx/venv/lib/python3.5/site-packages (from XBlock->assignmentregrade-xblock==0.1->-r ./private.txt (line 1)) (2.4.0)
Requirement already satisfied: fs in /openedx/venv/lib/python3.5/site-packages (from XBlock->assignmentregrade-xblock==0.1->-r ./private.txt (line 1)) (2.0.18)
Requirement already satisfied: lxml in /openedx/venv/lib/python3.5/site-packages (from XBlock->assignmentregrade-xblock==0.1->-r ./private.txt (line 1)) (4.5.0)
Requirement already satisfied: pytz in /openedx/venv/lib/python3.5/site-packages (from XBlock->assignmentregrade-xblock==0.1->-r ./private.txt (line 1)) (2020.1)
Requirement already satisfied: setuptools in /openedx/venv/lib/python3.5/site-packages (from fs->XBlock->assignmentregrade-xblock==0.1->-r ./private.txt (line 1)) (44.1.0)
Requirement already satisfied: appdirs~=1.4.3 in /openedx/venv/lib/python3.5/site-packages (from fs->XBlock->assignmentregrade-xblock==0.1->-r ./private.txt (line 1)) (1.4.4)
Installing collected packages: assignmentregrade-xblock, racketstepper-xblock, codeeditor-xblock, visualizer-xblock, codingproblem-xblock, coderevealer-xblock, terms-xblock, deadline-xblock
  Running setup.py develop for assignmentregrade-xblock
  Running setup.py develop for racketstepper-xblock
  Running setup.py develop for codeeditor-xblock
  Running setup.py develop for visualizer-xblock
  Running setup.py develop for codingproblem-xblock
  Running setup.py develop for coderevealer-xblock
  Running setup.py develop for terms-xblock
  Running setup.py develop for deadline-xblock
Successfully installed assignmentregrade-xblock codeeditor-xblock coderevealer-xblock codingproblem-xblock deadline-xblock racketstepper-xblock terms-xblock visualizer-xblock
...

All of the xblocks are installed and work EXCEPT for assignmentregrade.

When I run the following command:

tutor dev run --no-deps lms python -c "import pkg_resources
for entrypoint in pkg_resources.iter_entry_points('xblock.v1'):
    print(entrypoint)"

I can see 7 of the 8 xblocks, but not the assignmentregrade

Running openedx-dev as root user
...
crowdsourcehinter = crowdsourcehinter:CrowdsourceHinter
racketstepper = racketstepper:RacketStepperXBlock
codeeditor = codeeditor.codeeditor:CodeEditorXBlock
visualizer = visualizer:VisualizerXBlock
codingproblem = codingproblem:CodingProblemXBlock
coderevealer = coderevealer:CodeRevealerXBlock
terms = terms:TermsXBlock
deadline = deadline:DeadlineXBlock
acid_parent = acid:AcidParentBlock
...

Any ideas on what could be causing this issue?

Hi @ToddLichty,
In my opinion that, your custom XBlock must be placed “/requirements/” area.

$ cd .local/share/tutor/env/build/openedx/requirements

$ git clone YourCustomXBlockRepo

$ tutor images build openedx

I can confirm that it already is in the requirements folder.

Can I check out the repo for the XBlock?

So this is weird. I created a new XBlock and copied all the files from the old one to the new one. I was able to install and use it in the CMS without issue. I have no clue why the original version won’t work, but the new one is working fine.

@ToddLichty You are aware that Open edX switched from Python 2.7 to 3.5 between Ironwood and Juniper, right? So if your xblock was not compatible with Python 3 it could not be properly imported. You can check whether it imports successfully by running:

$ tutor dev run cms bash
$ ./manage.py cms shell
>> import assignmentregrade.xblock

@regis Thanks for the reply. I was able to import the xblock in the shell without an error.

It still does not show in the Advanced Component list.

Can you share your xblock’s setup.py file? If you can’t find the entrypoint it probably means that it is misconfigured.

@regis Here it is:

"""Setup for assignmentregrade XBlock."""

from __future__ import absolute_import

import os

from setuptools import setup


def package_data(pkg, roots):
    """Generic function to find package_data.

    All of the files under each of the `roots` will be declared as package
    data for package `pkg`.

    """
    data = []
    for root in roots:
        for dirname, _, files in os.walk(os.path.join(pkg, root)):
            for fname in files:
                data.append(os.path.relpath(os.path.join(dirname, fname), pkg))

    return {pkg: data}


setup(
    name='assignmentregrade-xblock',
    version='0.1',
    description='assignmentregrade XBlock',   # TODO: write a better description.
    license='UNKNOWN',          # TODO: choose a license: 'AGPL v3' and 'Apache 2.0' are popular.
    packages=[
        'assignmentregrade',
    ],
    install_requires=[
        'XBlock',
    ],
    entry_points={
        'xblock.v1': [
            'assignmentregrade = assignmentregrade:AssignmentRegradeXBlock',
        ]
    },
    package_data=package_data("assignmentregrade", ["static", "public"]),
)

I have absolutely no idea what is going on. It’s hard to debug any further without access to the container. The only explanations I see are:

  1. You did not properly search for assignmentregrade in the output of tutor dev run --no-deps lms python -c "import pkg_resources... above (sorry, I know this is unlikely but I just had to mention this).
  2. Another version of assignmentregrade-xblock is installed on top of your version, because of some dependency, and this other version does not have the right entrypoint.

This morning I nuked my tutor install and tried installing the xblock again. It is still not showing in the CMS list. Obviously, I need to get this working. I’ll keep posting my findings here as I try different tactics to get the XBlock working.