# Execution

# execute

machinable.execute(experiment:Union[machinable.experiment.experiment.Experiment, Any], storage:Union[dict, str]=None, engine:Union[machinable.engine.engine.Engine, str, dict, NoneType]=None, index:Union[machinable.index.index.Index, str, dict, NoneType]=None, project:Union[machinable.project.project.Project, Callable, str, dict]=None, seed:Union[int, NoneType, str]=None) -> machinable.execution.execution.Execution

Executes a machinable experiment

Schedules the experiment for execution.

# Arguments

  • experiment: machinable.Experiment, specifies the execution experiment. For convenience, it can also be a string or tuple that defines the node argument, e.g. ml.execute('my_model') or ml.execute((('my_model', {'param': 1}),))
  • storage: String, URL of the write location for the results. If unspecified, the result write will be non-persistent. Remote locations like SSH or S3 are supported via pyFilesystem URLs
  • engine: machinable.Engine|Dict|String|None, engine that handles execution, e.g. 'local' or 'ray' etc.
  • index: machinable.Index|Dict|String|None, index that tracks this execution
  • project: Project|Dict|String|None, project used, defaults to current working directory
  • seed: Integer|String|None, determines the global random seed. If None, a random seed will be generated. To re-use the same random seed of a previous execution, you can pass in its experiment ID

# Example

import machinable as ml
ml.execute(ml.Experiment().components('iris', 'random_forest'), 's3://bucket', seed=42)

# Functional API

You can use this method as a function decorator to implement a custom execution. The decorated function is invoked with the configuration as well as an store object, for example:

@ml.execute
def custom_execute(component, components, store):
    store.log.info('Custom training with learning_rate=' + str(component.config.lr))

custom_execute(experiment, storage, seed) # invokes the decorated function

# Using the Execution

This method forms a wrapper around machinable.Execution. You can instantiate machinable.Executon directly with the same argument to benefit from more fine grained execution APIs like asynchronous executon etc.

# Returns

The execution returns an machinable.Execution object that contains the result of the execution

# Execution

machinable.Execution(experiment:Union[machinable.experiment.experiment.Experiment, Any], storage:Union[dict, str]=None, engine:Union[machinable.engine.engine.Engine, str, dict, NoneType]=None, index:Union[machinable.index.index.Index, str, dict, NoneType]=None, project:Union[machinable.project.project.Project, Callable, str, dict]=None, seed:Union[int, NoneType, str]=None)

# export

export(self, path=None, overwrite=False)

Exports the execution

Converts the execution into a plain Python project that can be executed without machinable.

WARNING

This feature may not work reliably in all circumstances and project use cases

# Arguments

  • path: String, directory where exported execution will be stored. If None defaults to 'exports' in the current working directory
  • overwrite: Boolean, whether to overwrite an existing export.