gobbli.model.context module

class gobbli.model.context.ContainerTaskContext(task_root_dir)[source]

Bases: object

Encapsulates filesystem organization for tasks which take some input and produce some output using directories mapped between the host and a container.

Provide necessary input/output directories but also allow the caller to create their own directories as needed and map them to container paths.

Parameters

task_root_dir (Path) – The root directory for the task on the host. All directories in the context will be descendents of this directory.

property container_input_dir
Return type

Path

Returns

The directory to be used for task input, as mapped in the container.

property container_output_dir
Return type

Path

Returns

The directory to be used for task output, as mapped in the container.

property container_root_dir
Return type

Path

Returns

The container root directory corresponding to the ContainerTaskContext.params.task_root_dir host directory.

host_dir(name)[source]

Create (if necessary) and return a directory on the host under the task root path.

Parameters

name (str) – The name of the directory to create (relative to ContainerTaskContext.params.task_root_dir).

Return type

Path

Returns

The full path to the created task root directory.

property host_input_dir
Return type

Path

Returns

The host directory to be used for task input.

property host_output_dir
Return type

Path

Returns

The host directory to be used for task output.

to_container(host_dir)[source]

Convert a given directory on the host to a directory under some canonical path in the container. The given host directory must be under our root directory.

Parameters

host_dir (Path) – The full path to a descendent directory of the ContainerTaskContext.params.task_root_dir).

Return type

Path

gobbli.model.context.DOCKER_ROOT = PosixPath('/gobbli')