Experiments module
This module contains basic tag types to define an experiment with MLDev.
GenericPipeline
is a sequence of steps (staged) with added servicesBasicStage
is a simple step in a pipelineMonitoringService
is a base class for servicesFilePath
is a utility data type that defines a path with several files within
- class BasicStage(name='', params={}, env={}, inputs={}, outputs={}, script=[])[исходный код]
Базовые классы:
object
A main class for non-versioned pipeline stages
Defines a step in a pipeline that can be recalculated given
inputs
to productoutputs
.The pipeline, the stage participated in, first calls
stage.prepare(name)
method. The stage has to initialize all its dependencies and return with no error if it is ready to be run. If stage cannot run, it should raise an exception to prevent the pipeline from proceeding.If a stage does not define the
prepare
method, it is skipped.After that the pipeline call the stage instance via
__call__
method, that isstage(name)
. This method should check if actual execution is needed or results are already fresh enough and then callstage.run()
.The
stage.run()
method does the actual execution. It runs thescript
by default using the default shell viautils.exec_command
.Any configuration for pipeline and stage execution comes from
MLDevSettings()
.- Параметры
inputs – lists files and folders that this stage depends upon
outputs – lists files and folders that this stage produces and that will be added to version control
params – parameters for the commands being invoked
env – additional environmental variables to pass to commands
script – a list of command to invoke
- prepare(stage_name)[исходный код]
Called by the pipeline. By default does nothing.
- Параметры
stage_name – a name of the stage
- Результат
- run(stage_name)[исходный код]
Called by the pipeline. Enter the
stage_context
and executes the script.- Параметры
stage_name – a name of the stage
- Результат
- class FilePath(*args, **kwargs)[исходный код]
Базовые классы:
object
Implements a collection of files prefixed with a common path
If cast to
str
, produces a space separated list of absolute paths. > Note: this could cause problems if path of files contain unescaped spaces.When converted to json via
to_json()
produces a list of files fromget_files()
- Параметры
path – (optional) a base path for the files and folders,
defaults to experiment root if absent :param files: (optional) a list of files relative to the
path
- get_files(start=None)[исходный код]
Returns a list of paths to files in this
FilePath
- Параметры
start – (optional) if present, paths are relative to
start
, otherwise they are absolute- Результат
- get_path(start=None)[исходный код]
Returns a base path for this
FilePath
- Параметры
start – (optional) if present, paths are relative to
start
, otherwise they are absolute- Результат
- to_json()[исходный код]
- class GenericPipeline(*args, **kwargs)[исходный код]
Базовые классы:
object
This is a basic pipeline to run stages and services in a sequence
- Supports the following kinds of operation
sequence of runs - then use runs attribute in experiment.yml, expects instances of stages, for example using yaml anchors.
services and stages separately - first runs services, then stages, expects attribute names of top-level services and stages in the experiment spec in yaml. This does not requre use of yaml anchors.
When using runs, it executes „prepare“ and then calls the items in the order specified
The pipeline is a
Callable
and invoked aspipeline()
. The pipeline can be called inmode='prepare'
then it iterates over- Параметры
runs – (optional) a list of stages or services in this pipeline, in the order to be run
stages – (optional) alternative list of stages in the pipeline, runs after services
services – (optional) a list of services, runs before stages
- exec_item(run, experiment_config, run_name=None, exec_type='run')[исходный код]
- exec_runs(experiment_config, exec_type)[исходный код]
- exec_stages(experiment_config, exec_type)[исходный код]
- run_services(experiment_config, exec_type)[исходный код]
- class MonitoringService(name=None, params={})[исходный код]
Базовые классы:
object
A common superclass for services accompanying the experiment
Uses the following configuration parameters: -
MLDevSettings().temp_dir
for the directory for mldev temp files -MLDevSettings().tool_dir
for the install directory of mldev- prepare(service_name)[исходный код]
- class PythonFunction(*args, **kwargs)[исходный код]
Базовые классы:
object
Use this to load a specific python function into object graph from experiment.yaml
This is a string scalar specifying a fully qualified name of the function
- experiment_tag(loader=<function _mapping_loader>, representer=<function _mapping_representer>, name=None, pattern=None)[исходный код]
Use this tag to mark classes invoked from experiment.yml
Note: use experiment_tag(), not just experiment_tag
- Параметры
loader – a loader (deserializer) for the specified class to pass to YAML loader
representer – a representer (serializer) for the class to pass to YAML loader
name – a tag name to use, will use classname if absent
pattern – a regexp pattern to use when extracting from scalar strings (see also yaml.add_implicit_resolver)
- Результат
wrapped class