Skip to content

parameters

Module for execution parameter support in ML Workbench.

PARAMS_FILE_PATH module-attribute

PARAMS_FILE_PATH = '/home/jovyan/.params/params.json'

is_externally_set

is_externally_set(instance)

Check whether a @parameters-decorated instance was populated from the execution parameters file.

This allows code to distinguish "running interactively with declared defaults" from "running as a triggered job", which is useful e.g. to implement a set_defaults(...) helper that should never override values coming from a real execution: once a job supplies its execution parameters, all of them - not just the ones a caller happens to ask about - are treated as authoritative.

Parameters:

  • instance (Any) –

    A dataclass instance created via the @parameters decorator.

Returns:

  • bool –

    True if the execution parameters file was found for instance, False otherwise

  • bool –

    (including when instance was not created via @parameters).

parameters

parameters(cls)

Convert a class into a dataclass populated from execution parameters.

When running as a triggered job in ML Workbench, the backend mounts a JSON config file at PARAMS_FILE_PATH. This decorator reads that file and overwrites the dataclass defaults with the values from the file.

When running interactively (no config file present), the dataclass defaults are used.

Example: @parameters class MyConfig: alpha: float = 0.1 beta: float = 0.1 dataset: str = "default_dataset" additional: dict = { params : { theta: 0.1 } }