StepType#

class rapidtools.jobs.StepType(name: str, title: str, doc: str, build: Callable[[...], Any], run: Callable[[StepContext], None], inputs: tuple[Input, ...] = (), params: tuple[Param, ...] = (), outputs: tuple[Output, ...] = (), activity: str = '', empty_hint: str = '', since: str = '1.0')[source]#

Bases: object

A kind of step a job may contain.

Variables:
  • name (str) – The type written in job files, <stage>.<variant>.

  • title (str) – Short human-readable title.

  • doc (str) – What the step does, for the reference documentation.

  • build (Callable) – build(step_type, params, inputs, output_dir, dry) returns the settings object the step runs with, raising ValueError for an invalid combination. dry is True while a job is only being validated, when references to earlier steps are placeholders and no file may be read.

  • run (Callable[[StepContext], None]) – Does the work.

  • inputs (tuple[Input, ...]) – Data the step reads.

  • params (tuple[Param, ...]) – Its options.

  • outputs (tuple[Output, ...]) – Files later steps may reference.

  • activity (str) – The work as a noun ('inference'), used in messages such as “skipping inference”.

  • empty_hint (str) – What to report when the step finds nothing and a later step needed its result.

  • since (str) – Interface version that introduced the step type.

Example

>>> detect = get_step_type('detect.aerial')
>>> detect.title, [p.name for p in detect.params][:2]
('Detect assets in aerial imagery', ['assets', 'asset_size_m'])

Methods

read_params

Validate the params of a step and fill in the defaults.

settings_kwargs

Return params keyed by the settings field each one fills.

read_params(given: dict[str, Any], secrets: Secrets | None = None, allow_missing_secrets: bool = False) → dict[str, Any][source]#

Validate the params of a step and fill in the defaults.

Parameters:
  • given (dict[str, Any]) – params from the job file.

  • secrets (Secrets | None) – Resolver for secret references.

  • allow_missing_secrets (bool) – Replace a secret that cannot be resolved with a placeholder instead of failing, so a job can be checked on a machine that does not hold the credentials.

Returns:

dict[str, Any] – A value for every parameter of the step type.

Raises:

ValueError – For an unknown, missing or invalid parameter.

settings_kwargs(params: dict[str, Any]) → dict[str, Any][source]#

Return params keyed by the settings field each one fills.