Module Contents

runner.project.DEREX_RUNNER_PROJECT_DIR = .derex[source]
class runner.project.ProjectRunMode[source]

Bases: enum.Enum

debug = debug[source]
production = production[source]
class runner.project.Project(path: Union[Path, str] = None, read_only: bool = False)[source]

Represents a derex.runner project, i.e. a directory with a derex.config.yaml file and optionally a “themes”, “settings” and “requirements” directory. The directory is inspected on object instantiation: changes will not be automatically picked up unless a new object is created.

The project root directory can be passed in the path parameter, and defaults to the current directory. If files needed by derex outside of its private .derex. dir are missing they will be created, unless the read_only parameter is set to True.

root :Path[source]
base_image :str[source]
final_base_image :str[source]
requirements_dir :Optional[Path][source]
themes_dir :Optional[Path][source]
settings_dir :Optional[Path][source]
fixtures_dir :Optional[Path][source]
plugins_dir :Optional[Path][source]
requirements_image_name :str[source]
themes_image_name :str[source]
image_name :str[source]
image_prefix :str[source]
local_compose :Optional[Path][source]
requirements_volumes :Optional[Dict[str, str]][source]
property mysql_db_name(self)[source]
property mongodb_db_name(self)[source]
property runmode(self)[source]

The run mode of this project, either debug or production. In debug mode django’s runserver is used. Templates are reloaded on every request and assets do not need to be collected. In production mode gunicorn is run, and assets need to be compiled and collected.

property settings(self)[source]

Name of the module to use as DJANGO_SETTINGS_MODULE


Return an absolute path that will be mounted under lms/envs/derex_project and cms/envs/derex_project inside the container. If the project has local settings, we use that directory. Otherwise we use the directory bundled with derex.runner

_get_status(self, name: str, default: Optional[str] = None)[source]

Read value for the desired status from the project directory.

_set_status(self, name: str, value: str)[source]

Persist a status in the project directory. Each status will be written to a different file.

private_filepath(self, name: str)[source]

Return the full file path to name rooted from the project private dir “.derex”.

>>> Project().private_filepath("filename.txt")
_load(self, path: Union[Path, str] = None)[source]

Load project configuraton from the given directory.

update_default_settings(self, default_settings_dir, destination_settings_dir)[source]

Update default settings in a specified directory. Given a directory where to look for default settings modules recursively copy or update them into the destination directory. Additionally add a warning asking not to manually edit files. If files needs to be overwritten, print a diff.


If the project includes user defined settings, add ours to that directory to let the project’s settings use the line

from .derex import *

Also add a file with the above content if it does not exist.

get_plugin_directories(self, plugin: str)[source]

Return a dictionary filled with paths to existing directories for custom requirements, settings, fixtures and themes for a plugin.


Return an Enum object that includes possible settings for this project. This enum must be dynamic, since it depends on the contents of the project settings directory. For this reason we use the functional API for python Enum, which means we’re limited to IntEnums. For this reason we’ll be using instead of settings.value throughout the code.


Return a dictionary to be used as environment variables for all containers in this project. Variables are looked up inside the config according to the current settings for the project.

secret(self, name: str)[source]
runner.project.get_requirements_hash(path: Path) → str[source]

Given a directory, return a hash of the contents of the text files it contains.

runner.project.find_project_root(path: Path) → Path[source]

Find the project directory walking up the filesystem starting on the given path until a configuration file is found.

class runner.project.DebugBaseImageProject(path: Union[Path, str] = None, read_only: bool = False)[source]

Bases: runner.project.Project

A project that is always in debug mode and always uses the base image, irregardless of the presence of requirements.

property requirements_image_name(self)[source]
class runner.project.OpenEdXVersions[source]

Bases: enum.Enum