LEIP Pipeline

leip.run_pipeline(pipeline: Pipeline, output_path: Path, variables: Optional[Dict[str, str]] = None, print_results: bool = False, tags: List[str] = []) PipelineResult

Runs a set of supported tasks of the LEIP SDK. A pipeline consists of a directed acyclic graph of tasks.

Parameters
  • pipeline (Pipeline) – Pipeline configuration.

  • output_path (Path) – Root Directory path for pipeline results.

  • variables (Optional[Dict[str, str]]) – Values for variables appearing in task options.

  • print_results (bool) – Whether results should be printed to the screen.

  • tags (List[str]) – Tags for LEIP Enterprise events.

Returns

The results from each of the tasks.

Return type

PipelineResult

class leip.Pipeline(*, name: str = None, tasks: List[PipelineTask])

Pipeline configuration.

Parameters
Return type

None

name: Optional[str]

Name for this pipeline.

tasks: List[leip.core.operations.pipeline.options.PipelineTask]

List of tasks that describe this pipeline.

class leip.PipelineTask(*, name: str, model: TaskModelOptions = TaskModelOptions(inference=InferenceOptions(context='cpu', host='localhost', port='50051'), input_names=[], output_names=[], input_shapes=[], remove_nodes=[], dataset=DatasetOptions(public_dataset=None, type='leip'), custom_objects=None, crc=None, metadata={}, preprocessor=None, postprocessor=None, preprocessor_config=None, output_format='classifier', path=None), compile: CompileOptions = None, optimize: OptimizeOptions = None, run: RunOptions = None, evaluate: EvaluateOptions = None, analyze: AnalyzeOptions = None, package: PackageOptions = None, zoo_download: ZooDownloadOptions = None)

Configuration for a task in a pipeline. Aside from name and model attributes, only one of the others is expected to be defined, which expresses the type of task and its options.

Any str or Path value in a pipeline task may contain variables, which are replaced by a value before executing the task. The types of variables are: 1. $VAR{<var-name>} or $<var-name>: a variable provided as environment variable or in the pipeline call. Example: $VAR{model_id} or $model_id. 2. $TASK_OUTPUT{<task-name>:<task-type>}: output path of a previous task. Example: $TASK_OUTPUT{myname:compile}.

Parameters
  • name (str) –

  • model (TaskModelOptions) –

  • compile (Optional[CompileOptions]) –

  • optimize (Optional[OptimizeOptions]) –

  • run (Optional[RunOptions]) –

  • evaluate (Optional[EvaluateOptions]) –

  • analyze (Optional[AnalyzeOptions]) –

  • package (Optional[PackageOptions]) –

  • zoo_download (Optional[ZooDownloadOptions]) –

Return type

None

analyze: Optional[leip.core.operations.analyze.options.AnalyzeOptions]

Options to configure an analyze task.

compile: Optional[leip.core.operations.compile.options.CompileOptions]

Options to configure a compile task.

evaluate: Optional[leip.core.operations.evaluate.options.EvaluateOptions]

Options to configure an evaluate task.

model: leip.core.operations.pipeline.options.TaskModelOptions

Options that configure a source model.

name: str

Name for this task. The combination of this name and the task type is used for the output path, which may be referenced by subsequent tasks.

optimize: Optional[leip.core.operations.optimize.options.OptimizeOptions]

Options to configure an optimize task.

package: Optional[leip.core.operations.package.options.PackageOptions]

Options to configure a package task.

run: Optional[leip.core.operations.run.options.RunOptions]

Options to configure a run task.

zoo_download: Optional[publicsdk.core.operations.zoo.download.options.ZooDownloadOptions]

Options to configure a zoo_download task.

class leip.PipelineResult(*, tasks: List[PipelineTaskResult], success: bool = True)

The results from each of the tasks of a pipeline.

Parameters
Return type

None

success: bool

Indicates if all tasks completed successfully.

tasks: List[leip.core.operations.pipeline.options.PipelineTaskResult]

The list of results per task.

class leip.PipelineTaskResult(*, ref: str, success: bool = True, value: Any = None)

The result of one task in a pipeline.

Parameters
  • ref (str) –

  • success (bool) –

  • value (Any) –

Return type

None

ref: str

The reference name of the task.

success: bool

Indicates if the task completed successfully.

value: Any

The resulting value or exception.