Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems getting this to work in Docker XBlock-SDK (without devstack) #38

Open
taniwallach opened this issue Jan 28, 2021 · 1 comment

Comments

@taniwallach
Copy link

I am trying to get this to work using an updated Docker version of the XBlock-SDK from https://github.com/taniwallach/xblock-sdk/tree/update-base-add-docker-compose-yml as a Docker image build using that branch does start up.

I ran into several problems, and still have not been able to get it to work.

My modified Dockerfile to overcome some of the issues I encountered is:

FROM xblock-sdk
RUN mkdir -p /usr/local/src/staff_graded-xblock
VOLUME ["/usr/local/src/staff_graded-xblock"]
RUN apt-get update && apt-get install -y gettext

# Upgrade pip
RUN echo "pip install -U pip" >> /usr/local/src/xblock-sdk/install_and_run_xblock.sh

# Next line fails, no such file
#RUN echo "pip install -r /usr/local/src/staff_graded-xblock/requirements.txt" >> /usr/local/src/xblock-sdk/install_and_run_xblock.sh
#
# so try this one instead - which does seem to work
RUN echo "pip install -r /usr/local/src/staff_graded-xblock/requirements/dev.txt" >> /usr/local/src/xblock-sdk/install_and_run_xblock.sh

RUN echo "pip install -e /usr/local/src/staff_graded-xblock" >> /usr/local/src/xblock-sdk/install_and_run_xblock.sh

# Need to add this to create database
RUN echo "python /usr/local/src/xblock-sdk/manage.py migrate" >> /usr/local/src/xblock-sdk/install_and_run_xblock.sh

# Skip translations - it fails
#RUN echo "cd /usr/local/src/staff_graded-xblock && make compile_translations && cd /usr/local/src/xblock-sdk" >> /usr/local/src/xblock-sdk/install_and_run_xblock.sh

RUN echo "exec python /usr/local/src/xblock-sdk/manage.py \"\$@\"" >> /usr/local/src/xblock-sdk/install_and_run_xblock.sh
RUN chmod +x /usr/local/src/xblock-sdk/install_and_run_xblock.sh
ENTRYPOINT ["/bin/bash", "/usr/local/src/xblock-sdk/install_and_run_xblock.sh"]
CMD ["runserver", "0.0.0.0:8000"]

which depends on the locally prepared xblock-sdk image.

  1. Due to a failure to get the i8n code to work - the line to run it was commented out.
  2. Add python /usr/local/src/xblock-sdk/manage.py migrate which is required to get the database initialized.
  • This probably only needs to be done once and not on each restart.

The server does come up, but gives an error No module named 'lms' shown below from bulk_grades/api.py: The line triggering the error seems to be

from lms.djangoapps.grades import api as grades_api

Error when i18n not run.

ModuleNotFoundError at /
No module named 'lms'
Request Method:	GET
Request URL:	http://localhost:8000/
Django Version:	2.2.17
Exception Type:	ModuleNotFoundError
Exception Value:	
No module named 'lms'
Exception Location:	/usr/local/lib/python3.8/dist-packages/bulk_grades/api.py in <module>, line 15
Python Executable:	/usr/bin/python
Python Version:	3.8.5
Python Path:	
['/usr/local/src/xblock-sdk',
 '/usr/lib/python38.zip',
 '/usr/lib/python3.8',
 '/usr/lib/python3.8/lib-dynload',
 '/usr/local/lib/python3.8/dist-packages',
 '/usr/local/src/xblock-sdk/src/acid-xblock',
 '/usr/local/src/xblock-sdk',
 '/usr/local/src/staff_graded-xblock',
 '/usr/lib/python3/dist-packages']
Server time:	Thu, 28 Jan 2021 14:21:43 -0500
Traceback Switch to copy-and-paste view
/usr/local/lib/python3.8/dist-packages/django/core/handlers/exception.py in inner
            response = get_response(request) …
▶ Local vars
/usr/local/lib/python3.8/dist-packages/django/core/handlers/base.py in _get_response
                response = self.process_exception_by_middleware(e, request) …
▶ Local vars
/usr/local/lib/python3.8/dist-packages/django/core/handlers/base.py in _get_response
                response = wrapped_callback(request, *callback_args, **callback_kwargs) …
▶ Local vars
/usr/local/src/xblock-sdk/workbench/views.py in index
    the_scenarios = sorted(get_scenarios().items()) …
▶ Local vars
/usr/local/src/xblock-sdk/workbench/scenarios.py in get_scenarios
        init_scenarios() …
/usr/local/src/xblock-sdk/workbench/scenarios.py in init_scenarios
    for class_name, cls in sorted(XBlock.load_classes(fail_silently=False)): …
/usr/local/lib/python3.8/dist-packages/xblock/plugin.py in load_classes
                yield (class_.name, cls._load_class_entry_point(class_)) …
▶ Local vars
/usr/local/lib/python3.8/dist-packages/xblock/plugin.py in _load_class_entry_point
        class_ = entry_point.load() …
▶ Local vars
/usr/local/lib/python3.8/dist-packages/pkg_resources/__init__.py in load
        return self.resolve() …
▶ Local vars
/usr/local/lib/python3.8/dist-packages/pkg_resources/__init__.py in resolve
        module = __import__(self.module_name, fromlist=['__name__'], level=0) …
▶ Local vars
/usr/local/src/staff_graded-xblock/staff_graded/__init__.py in <module>
from .staff_graded import StaffGradedXBlock …
▶ Local vars
/usr/local/src/staff_graded-xblock/staff_graded/staff_graded.py in <module>
from bulk_grades.api import get_score, set_score, ScoreCSVProcessor …
▶ Local vars
/usr/local/lib/python3.8/dist-packages/bulk_grades/api.py in <module>
from lms.djangoapps.grades import api as grades_api …
▶ Local vars

i18n issue

Installing collected packages: staff-graded-xblock
  Running setup.py develop for staff-graded-xblock
Successfully installed staff-graded-xblock
if [ ! -d "staff_graded/translations" ]; then ln -s locale/ staff_graded/translations; fi
cd staff_graded && i18n_tool generate
INFO:i18n.execute:Executing in . ...
INFO:i18n.execute:django-admin.py compilemessages -v0
python manage.py compilejsi18n --namespace staff_gradedi18n --output public/js/translations
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/django/core/management/__init__.py", line 204, in fetch_command
    app_name = commands[subcommand]
KeyError: 'compilejsi18n'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 12, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.8/dist-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.8/dist-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.8/dist-packages/django/core/management/__init__.py", line 211, in fetch_command
    settings.INSTALLED_APPS
  File "/usr/local/lib/python3.8/dist-packages/django/conf/__init__.py", line 79, in __getattr__
    self._setup(name)
  File "/usr/local/lib/python3.8/dist-packages/django/conf/__init__.py", line 66, in _setup
    self._wrapped = Settings(settings_module)
  File "/usr/local/lib/python3.8/dist-packages/django/conf/__init__.py", line 157, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/local/src/staff_graded-xblock/staff_graded/__init__.py", line 1, in <module>
    from .staff_graded import StaffGradedXBlock
  File "/usr/local/src/staff_graded-xblock/staff_graded/staff_graded.py", line 32, in <module>
    from bulk_grades.api import get_score, set_score, ScoreCSVProcessor
  File "/usr/local/lib/python3.8/dist-packages/bulk_grades/api.py", line 15, in <module>
    from lms.djangoapps.grades import api as grades_api
ModuleNotFoundError: No module named 'lms'
make: *** [Makefile:43: compile_translations] Error 1
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/usr/lib/python3.8/logging/config.py", line 563, in configure
    handler = self.configure_handler(handlers[name])
  File "/usr/lib/python3.8/logging/config.py", line 744, in configure_handler
    result = factory(**kwargs)
  File "/usr/lib/python3.8/logging/handlers.py", line 148, in __init__
    BaseRotatingHandler.__init__(self, filename, mode, encoding, delay)
  File "/usr/lib/python3.8/logging/handlers.py", line 55, in __init__
    logging.FileHandler.__init__(self, filename, mode, encoding, delay)
  File "/usr/lib/python3.8/logging/__init__.py", line 1143, in __init__
    StreamHandler.__init__(self, self._open())
  File "/usr/lib/python3.8/logging/__init__.py", line 1172, in _open
    return open(self.baseFilename, self.mode, encoding=self.encoding)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/src/staff_graded-xblock/var/workbench.log'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.8/dist-packages/django/utils/autoreload.py", line 54, in wrapper
    fn(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/django/core/management/commands/runserver.py", line 109, in inner_run
    autoreload.raise_last_exception()
  File "/usr/local/lib/python3.8/dist-packages/django/utils/autoreload.py", line 77, in raise_last_exception
    raise _exception[1]
  File "/usr/local/lib/python3.8/dist-packages/django/core/management/__init__.py", line 337, in execute
    autoreload.check_errors(django.setup)()
  File "/usr/local/lib/python3.8/dist-packages/django/utils/autoreload.py", line 54, in wrapper
    fn(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/django/__init__.py", line 19, in setup
    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
  File "/usr/local/lib/python3.8/dist-packages/django/utils/log.py", line 76, in configure_logging
    logging_config_func(logging_settings)
  File "/usr/lib/python3.8/logging/config.py", line 808, in dictConfig
    dictConfigClass(config).configure()
  File "/usr/lib/python3.8/logging/config.py", line 570, in configure
    raise ValueError('Unable to configure handler '
ValueError: Unable to configure handler 'logfile'
@taniwallach
Copy link
Author

Some additional information:

if [ ! -d "staff_graded/translations" ]; then ln -s locale/ staff_graded/translations; fi
cd staff_graded && i18n_tool generate
/bin/sh: 1: i18n_tool: not found

occurred before the changes to how the requirements were handled in the to the Dockerfile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant