runner.project

Module Contents

Classes

OpenEdXVersions

Generic enumeration.

ProjectRunMode

Generic enumeration.

Project

Represents a derex.runner project, i.e. a directory with a

DebugBaseImageProject

A project that is always in debug mode and always uses the base image,

Functions

get_requirements_hash(path: pathlib.Path) → str

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

find_project_root(path: pathlib.Path) → pathlib.Path

Find the project directory walking up the filesystem starting on the

Attributes

logger

DEREX_RUNNER_PROJECT_DIR

runner.project.logger[source]
runner.project.DEREX_RUNNER_PROJECT_DIR = .derex[source]
class runner.project.OpenEdXVersions[source]

Bases: enum.Enum

Generic enumeration.

Derive from this class to define new enumerations.

ironwood[source]
juniper[source]
koa[source]
class runner.project.ProjectRunMode[source]

Bases: enum.Enum

Generic enumeration.

Derive from this class to define new enumerations.

debug = debug[source]
production = production[source]
class runner.project.Project(path: Union[pathlib.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 :pathlib.Path[source]
base_image :str[source]
final_base_image :str[source]
openedx_version :OpenEdXVersions[source]
requirements_dir :Optional[pathlib.Path][source]
themes_dir :Optional[pathlib.Path][source]
settings_dir :Optional[pathlib.Path][source]
fixtures_dir :Optional[pathlib.Path][source]
plugins_dir :Optional[pathlib.Path][source]
openedx_customizations_dir :Optional[pathlib.Path][source]
e2e_dir :Optional[pathlib.Path][source]
requirements_image_name :str[source]
themes_image_name :str[source]
image_name :str[source]
image_prefix :str[source]
local_compose :Optional[pathlib.Path][source]
requirements_volumes :Optional[Dict[str, str]][source]
materialize_derex_settings[source]
_available_settings[source]
property mysql_db_name(self)str[source]
property mysql_user(self)str[source]
property mongodb_db_name(self)str[source]
property mongodb_user(self)str[source]
property runmode(self)ProjectRunMode[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

settings_directory_path(self)pathlib.Path[source]

Return an absolute path that will be mounted under /openedx/edx-platform/derex_settings inside the container. If the project has local settings, we use that directory. Otherwise we use the derex_django settings directory bundled with derex.runner

_get_status(self, name: str, default: Optional[str] = None)Optional[str][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)pathlib.Path[source]

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

>>> Project().private_filepath("filename.txt")
"/path/to/project/.derex/filename.txt"
_load(self, path: Union[pathlib.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.

_materialize_settings(self)[source]

If the project includes user defined settings and materialize_derex_settings is True for the project then copy current derex default settings to the project settings directory. This is useful to keep track of settings changes between version upgrades.

get_plugin_directories(self, plugin: str)Dict[str, pathlib.Path][source]

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

get_available_settings(self)[source]

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.

get_container_env(self)[source]

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)str[source]
get_openedx_customizations(self)dict[source]

Return a mapping of customized files to be mounted in the container in order to replace default edx-platform modules.

runner.project.get_requirements_hash(path: pathlib.Path)str[source]

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

runner.project.find_project_root(path: pathlib.Path)pathlib.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[pathlib.Path, str] = None, read_only: bool = False)[source]

Bases: Project

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

runmode[source]
property requirements_image_name(self)[source]
exception runner.project.ProjectNotFound[source]

Bases: ValueError

No derex project could be found.

Initialize self. See help(type(self)) for accurate signature.