Skip to content

experiment

experiment

Module for experiment op

Classes

Functions

create_exp_settings

create_exp_settings(exp_folder_pattern)

Creates the experiment settings

Source code in niceml/dagster/ops/experiment.py
def create_exp_settings(exp_folder_pattern):
    """Creates the experiment settings"""
    local_run_id = generate_timestamp()
    local_short_id = generate_short_id(local_run_id)
    exp_folder = subs_path_and_create_folder(
        exp_folder_pattern,
        local_short_id,
        local_run_id,
    )
    return exp_folder, local_run_id, local_short_id

experiment

experiment(context)

This Op creates the experiment params

Source code in niceml/dagster/ops/experiment.py
@op(
    config_schema=dict(
        exp_out_location=Field(
            dict,
            default_value=dict(uri="experiments"),
            description="Folder to store the experiments",
        ),
        exp_folder_pattern=Field(
            str,
            default_value="EXP-$RUN_ID-id_$SHORT_ID",
            description="Folder pattern of the experiment. "
            "Can use $RUN_ID and $SHORT_ID to make the name unique",
        ),
    ),
    required_resource_keys={"mlflow"},
)
def experiment(context: OpExecutionContext) -> ExperimentContext:
    """This Op creates the experiment params"""
    op_config = json.loads(json.dumps(context.op_config))
    exp_out_location: dict = op_config["exp_out_location"]
    exp_folder_pattern: str = op_config["exp_folder_pattern"]
    exp_folder, local_run_id, local_short_id = create_exp_settings(exp_folder_pattern)
    exp_location = join_location_w_path(exp_out_location, exp_folder)
    exp_context = ExperimentContext(
        fs_config=exp_location,
        run_id=local_run_id,
        short_id=local_short_id,
    )
    mlflow.set_tags(dict(run_id=local_run_id, short_id=local_short_id))
    mlflow.set_tag("mlflow.runName", local_short_id)

    return exp_context