Importing a course from command line

Hi Folks
I am liking tutor, however, I cannot import a course form the command line. Here are the steps I followed.

  • change to my working directory: /home/ennisa/workspace/docs/company/code_institute/build
  • download demo course from github: git clone https://github.com/edx/demo-test-course.git
  • cd demo-test-course
  • execute import command with data dir and source dir arguments: tutor local run cms ./manage.py cms import /home/ennisa/workspace/docs/company/code_institute/build/demo-test-course course

This results in error

ennisa@workhorse:~/workspace/docs/company/code_institute/build/demo-test-course$ tutor local run cms ./manage.py cms import /home/ennisa/workspace/docs/company/code_institute/build/demo-test-course course 
docker-compose -f /home/ennisa/.local/share/tutor/env/local/docker-compose.yml -f /home/ennisa/.local/share/tutor/env/local/docker-compose.prod.yml --project-name tutor_local run --rm cms ./manage.py cms import /home/ennisa/workspace/docs/company/code_institute/build/demo-test-course course
Creating tutor_local_cms_run ... done
Importing...
    data_dir=/home/ennisa/workspace/docs/company/code_institute/build/demo-test-course, source_dirs=['course']
    Importing static content? True
    Importing python lib? True
2021-03-26 14:45:19,939 ERROR 1 [xmodule.modulestore.xml] [user None] [ip None] xml.py:385 - ERROR: Failed to load courselike 'b'course'': [Errno 2] No such file or directory: Path('/home/ennisa/workspace/docs/company/code_institute/build/demo-test-course/course/course.xml')
Traceback (most recent call last):
  File "/openedx/edx-platform/common/lib/xmodule/xmodule/modulestore/xml.py", line 380, in try_load_course
    course_descriptor = self.load_course(course_dir, course_ids, errorlog.tracker, target_course_id)
  File "/openedx/edx-platform/common/lib/xmodule/xmodule/modulestore/xml.py", line 441, in load_course
    with open(self.data_dir / course_dir / self.parent_xml) as course_file:
FileNotFoundError: [Errno 2] No such file or directory: Path('/home/ennisa/workspace/docs/company/code_institute/build/demo-test-course/course/course.xml')
ennisa@workhorse:~/workspace/docs/company/code_institute/build/demo-test-course$ 

Here are the log files show nothing when the command above is executed.

tutor local logs cms --tail=200

My tutor version is …

  • tutor, version 11.2.4

My OS is

  • ubuntu.
  1. first off is it possible to import a repo such as the demo repo?
  2. that is meant by data dir and source dir?

Thanks Anthony.

Hi @ennisa! You must understand that the files stored on your computer are not directly available in your containers. To add them to a container, you must mount a volume: Volumes | Docker Docs

In your particular case, you should probably run something along the lines of:

cd demo-test-course
tutor local run -v $(pwd):/tmp/democourse cms bash
./manage.py cms import ../data /tmp/democourse
./manage.py cms reindex_course --all --setup

This is normal, as this command does not display logs from containers run with tutor local run ....

PS: you are aware that there is a built-in command to import the demo course, right? Local deployment — Tutor documentation

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.