common
— Common tools for the valjean executable
Common utilities for valjean commands.
- class valjean.cambronne.common.DictKwargAction(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)[source]
An
argparse.Action
subclass that parses arguments askey=value
pairs and stores the resulting associations in a dictionary.
- class valjean.cambronne.common.JobCommand[source]
Base class for all valjean subcommands that take a job file and job arguments.
- valjean.cambronne.common.run_job(job_file, job_args, job_kwargs)[source]
Run the job() function from the specified job file and return its result.
- Parameters:
- Returns:
whatever job() returns; expected to be a list of
Task
objects.- Return type:
- valjean.cambronne.common.check_unique_task_names(tasks)[source]
Check that the tasks have unique names.
- Parameters:
tasks (list) – A list of tasks.
- Raises:
ValueError – if two or more tasks have the same name.
- valjean.cambronne.common.collect_tasks(job_file, job_args, job_kwargs)[source]
Collect tasks from a job file, along with all their dependencies.
- valjean.cambronne.common.build_graphs(args)[source]
Build the dependency graphs according to the CLI parameters.
- valjean.cambronne.common.read_env(*, root, names, filename, fmt)[source]
Create an initial environment for the given task names, possibly merging a set of serialized environments.
The environment will be created from the partial environments that were serialized for the given task names. Missing partial environments will be silently ignored.
If filename is None, no de-serialization will take place and an empty environment will be returned.
- Parameters:
root (str) – path to the root directory containing all the environment files.
names (list(str)) – the list of task names that will be deserialized.
filename (str or None) – Name of the file containing the serialized environment. If None, no de-serialzation will take place.
fmt (str) – Environment serialization format (only
'pickle'
is supported at the moment).
- Returns:
an environment.
- Return type:
- valjean.cambronne.common.write_env(env, *, filename, fmt)[source]
Serialize the environment to files.
The environment will be written to one file per task (i.e. one per environment key). The name of the environment file is given by the filename parameter, and the directory is the output directory (
'output_dir'
key) of the task. If the task does not have an'output_dir'
key, serialization for that task will be skipped.If filename is None, no serialization will take place at all.