Procedure

Convenience class for grouping stages and automatically passing a record between them.

Classes:

Procedure(stages[, manager, name, …])

A defined list of stages to run in sequence, creating a record to associate with them.

class curifactory.procedure.Procedure(stages, manager=None, name=None, previous_proc=None, records=None)

A defined list of stages to run in sequence, creating a record to associate with them.

For the stage list, specify only the names of the functions.

Example

@stage(...)
def data_stage(...):
    # ...

@stage(...)
def model_stage(...):
    # ...

proc = Procedure(
    [
        data_stage,
        model_stage
    ],
    mngr)
Parameters
  • stages – A list of function names that are wrapped in stage or aggregate decorators. Note that if using an aggregate state, it _must_ be the first one in the list.

  • manager (ArtifactManager) – The manager to associate this procedure and corresponding record with. If you specify None, one will be created with the default constructor.

  • name (str) – An optional name for the procedure. Currently unused, may eventually be put into logging or reporting.

  • previous_proc (Procedure) – If specified and this procedure begins with an aggregate stage, use the previous_proc.records list of records.

  • records (List[Record]) – If specified and this procedure begins with an aggregate stage, use this list of records.

Note

If a procedure begins with an aggregate stage and neither previous_proc nor records are specified, it will automatically grab all existing records from the artifact manager.

Methods:

run(args[, record, hide])

Run this procedure with the passed set of args.

run(args, record=None, hide=False)

Run this procedure with the passed set of args. This allows easily running multiple argsets through the same set of stages and automatically getting a separate record for each.

Parameters
  • args (ExperimentArgs) – The args to put into the record created for this procedure.

  • record (Record) – If you have a specific record you want the procedure to use (e.g. if you’re chaining multiple procedures and already have an applicable record to use from the previous one), pass it here. If unspecified, a new record will automatically be created for the passed args and relevant artifact manager.

  • hide (bool) – If True, don’t add the created record to the artifact manager.

Returns

The returned output from the last stage in self.stages.