Skip to content

Experiment

Experiment

Source code in python/opsml/experiment/_experiment.pyi
class Experiment:
    def start_experiment(
        self,
        space: Optional[str] = None,
        name: Optional[str] = None,
        code_dir: Optional[Path] = None,
        log_hardware: bool = False,
        experiment_uid: Optional[str] = None,
    ) -> "Experiment":
        """
        Start an Experiment

        Args:
            space (str | None):
                space to associate with `ExperimentCard`
            name (str | None):
                Name to associate with `ExperimentCard`
            code_dir (Path | None):
                Directory to log code from
            log_hardware (bool):
                Whether to log hardware information or not
            experiment_uid (str | None):
                Experiment UID. If provided, the experiment will be loaded from the server.

        Returns:
            Experiment
        """

    def __enter__(self) -> "Experiment":
        pass

    def __exit__(self, exc_type, exc_value, traceback) -> None:
        pass

    def log_metric(
        self,
        name: str,
        value: float,
        step: Optional[int] = None,
        timestamp: Optional[int] = None,
        created_at: Optional[datetime] = None,
    ) -> None:
        """
        Log a metric

        Args:
            name (str):
                Name of the metric
            value (float):
                Value of the metric
            step (int | None):
                Step of the metric
            timestamp (int | None):
                Timestamp of the metric
            created_at (datetime | None):
                Created at of the metric
        """

    def log_metrics(self, metrics: list[Metric]) -> None:
        """
        Log multiple metrics

        Args:
            metrics (list[Metric]):
                List of metrics to log
        """

    def log_parameter(
        self,
        name: str,
        value: Union[int, float, str],
    ) -> None:
        """
        Log a parameter

        Args:
            name (str):
                Name of the parameter
            value (int | float | str):
                Value of the parameter
        """

    def log_parameters(self, parameters: list[Parameter]) -> None:
        """
        Log multiple parameters

        Args:
            parameters (list[Parameter]):
                List of parameters to log
        """

    def log_artifact(
        self,
        path: Path,
    ) -> None:
        """
        Log an artifact

        Args:
            path (Path):
                Path to the artifact file. Path must be a file.
                If logging multiple artifacts, use `log_artifacts` instead.
        """

    def log_artifacts(
        self,
        paths: Path,
    ) -> None:
        """
        Log multiple artifacts

        Args:
            paths (Path):
                Paths to a directory containing artifacts.
                All files in the directory will be logged.
        """

    @property
    def card(self) -> "ExperimentCard":
        """
        ExperimentCard associated with the Experiment
        """

    def register_card(
        self,
        card: Union[DataCard, ModelCard, PromptCard],
        version_type: VersionType = VersionType.Minor,
        pre_tag: Optional[str] = None,
        build_tag: Optional[str] = None,
        save_kwargs: Optional[ModelSaveKwargs | DataSaveKwargs] = None,
    ) -> None:
        """Register a Card as part of an experiment

        Args:
            card (DataCard | ModelCard):
                Card to register. Can be a DataCard or a ModelCard
            version_type (VersionType):
                How to increment the version SemVer. Default is VersionType.Minor.
            pre_tag (str):
                Optional pre tag to associate with the version.
            build_tag (str):
                Optional build_tag to associate with the version.
            save_kwargs (SaveKwargs):
                Optional SaveKwargs to pass to the Card interface (If using DataCards
                and ModelCards).

        """

card property

ExperimentCard associated with the Experiment

log_artifact(path)

Log an artifact

Parameters:

Name Type Description Default
path Path

Path to the artifact file. Path must be a file. If logging multiple artifacts, use log_artifacts instead.

required
Source code in python/opsml/experiment/_experiment.pyi
def log_artifact(
    self,
    path: Path,
) -> None:
    """
    Log an artifact

    Args:
        path (Path):
            Path to the artifact file. Path must be a file.
            If logging multiple artifacts, use `log_artifacts` instead.
    """

log_artifacts(paths)

Log multiple artifacts

Parameters:

Name Type Description Default
paths Path

Paths to a directory containing artifacts. All files in the directory will be logged.

required
Source code in python/opsml/experiment/_experiment.pyi
def log_artifacts(
    self,
    paths: Path,
) -> None:
    """
    Log multiple artifacts

    Args:
        paths (Path):
            Paths to a directory containing artifacts.
            All files in the directory will be logged.
    """

log_metric(name, value, step=None, timestamp=None, created_at=None)

Log a metric

Parameters:

Name Type Description Default
name str

Name of the metric

required
value float

Value of the metric

required
step int | None

Step of the metric

None
timestamp int | None

Timestamp of the metric

None
created_at datetime | None

Created at of the metric

None
Source code in python/opsml/experiment/_experiment.pyi
def log_metric(
    self,
    name: str,
    value: float,
    step: Optional[int] = None,
    timestamp: Optional[int] = None,
    created_at: Optional[datetime] = None,
) -> None:
    """
    Log a metric

    Args:
        name (str):
            Name of the metric
        value (float):
            Value of the metric
        step (int | None):
            Step of the metric
        timestamp (int | None):
            Timestamp of the metric
        created_at (datetime | None):
            Created at of the metric
    """

log_metrics(metrics)

Log multiple metrics

Parameters:

Name Type Description Default
metrics list[Metric]

List of metrics to log

required
Source code in python/opsml/experiment/_experiment.pyi
def log_metrics(self, metrics: list[Metric]) -> None:
    """
    Log multiple metrics

    Args:
        metrics (list[Metric]):
            List of metrics to log
    """

log_parameter(name, value)

Log a parameter

Parameters:

Name Type Description Default
name str

Name of the parameter

required
value int | float | str

Value of the parameter

required
Source code in python/opsml/experiment/_experiment.pyi
def log_parameter(
    self,
    name: str,
    value: Union[int, float, str],
) -> None:
    """
    Log a parameter

    Args:
        name (str):
            Name of the parameter
        value (int | float | str):
            Value of the parameter
    """

log_parameters(parameters)

Log multiple parameters

Parameters:

Name Type Description Default
parameters list[Parameter]

List of parameters to log

required
Source code in python/opsml/experiment/_experiment.pyi
def log_parameters(self, parameters: list[Parameter]) -> None:
    """
    Log multiple parameters

    Args:
        parameters (list[Parameter]):
            List of parameters to log
    """

register_card(card, version_type=VersionType.Minor, pre_tag=None, build_tag=None, save_kwargs=None)

Register a Card as part of an experiment

Parameters:

Name Type Description Default
card DataCard | ModelCard

Card to register. Can be a DataCard or a ModelCard

required
version_type VersionType

How to increment the version SemVer. Default is VersionType.Minor.

Minor
pre_tag str

Optional pre tag to associate with the version.

None
build_tag str

Optional build_tag to associate with the version.

None
save_kwargs SaveKwargs

Optional SaveKwargs to pass to the Card interface (If using DataCards and ModelCards).

None
Source code in python/opsml/experiment/_experiment.pyi
def register_card(
    self,
    card: Union[DataCard, ModelCard, PromptCard],
    version_type: VersionType = VersionType.Minor,
    pre_tag: Optional[str] = None,
    build_tag: Optional[str] = None,
    save_kwargs: Optional[ModelSaveKwargs | DataSaveKwargs] = None,
) -> None:
    """Register a Card as part of an experiment

    Args:
        card (DataCard | ModelCard):
            Card to register. Can be a DataCard or a ModelCard
        version_type (VersionType):
            How to increment the version SemVer. Default is VersionType.Minor.
        pre_tag (str):
            Optional pre tag to associate with the version.
        build_tag (str):
            Optional build_tag to associate with the version.
        save_kwargs (SaveKwargs):
            Optional SaveKwargs to pass to the Card interface (If using DataCards
            and ModelCards).

    """

start_experiment(space=None, name=None, code_dir=None, log_hardware=False, experiment_uid=None)

Start an Experiment

Parameters:

Name Type Description Default
space str | None

space to associate with ExperimentCard

None
name str | None

Name to associate with ExperimentCard

None
code_dir Path | None

Directory to log code from

None
log_hardware bool

Whether to log hardware information or not

False
experiment_uid str | None

Experiment UID. If provided, the experiment will be loaded from the server.

None

Returns:

Type Description
Experiment

Experiment

Source code in python/opsml/experiment/_experiment.pyi
def start_experiment(
    self,
    space: Optional[str] = None,
    name: Optional[str] = None,
    code_dir: Optional[Path] = None,
    log_hardware: bool = False,
    experiment_uid: Optional[str] = None,
) -> "Experiment":
    """
    Start an Experiment

    Args:
        space (str | None):
            space to associate with `ExperimentCard`
        name (str | None):
            Name to associate with `ExperimentCard`
        code_dir (Path | None):
            Directory to log code from
        log_hardware (bool):
            Whether to log hardware information or not
        experiment_uid (str | None):
            Experiment UID. If provided, the experiment will be loaded from the server.

    Returns:
        Experiment
    """

Metric

Source code in python/opsml/experiment/_experiment.pyi
class Metric:
    def __init__(
        self,
        name: str,
        value: float,
        step: Optional[int] = None,
        timestamp: Optional[int] = None,
        created_at: Optional[datetime] = None,
    ) -> None:
        """
        Initialize a Metric

        Args:
            name (str):
                Name of the metric
            value (float):
                Value of the metric
            step (int | None):
                Step of the metric
            timestamp (int | None):
                Timestamp of the metric
            created_at (datetime | None):
                Created at of the metric
        """

    @property
    def name(self) -> str:
        """
        Name of the metric
        """

    @property
    def value(self) -> float:
        """
        Value of the metric
        """

    @property
    def step(self) -> Optional[int]:
        """
        Step of the metric
        """

    @property
    def timestamp(self) -> Optional[int]:
        """
        Timestamp of the metric
        """

    @property
    def created_at(self) -> Optional[datetime]:
        """
        Created at of the metric
        """

created_at property

Created at of the metric

name property

Name of the metric

step property

Step of the metric

timestamp property

Timestamp of the metric

value property

Value of the metric

__init__(name, value, step=None, timestamp=None, created_at=None)

Initialize a Metric

Parameters:

Name Type Description Default
name str

Name of the metric

required
value float

Value of the metric

required
step int | None

Step of the metric

None
timestamp int | None

Timestamp of the metric

None
created_at datetime | None

Created at of the metric

None
Source code in python/opsml/experiment/_experiment.pyi
def __init__(
    self,
    name: str,
    value: float,
    step: Optional[int] = None,
    timestamp: Optional[int] = None,
    created_at: Optional[datetime] = None,
) -> None:
    """
    Initialize a Metric

    Args:
        name (str):
            Name of the metric
        value (float):
            Value of the metric
        step (int | None):
            Step of the metric
        timestamp (int | None):
            Timestamp of the metric
        created_at (datetime | None):
            Created at of the metric
    """

Parameter

Source code in python/opsml/experiment/_experiment.pyi
class Parameter:
    def __init__(
        self,
        name: str,
        value: Union[int, float, str],
    ) -> None:
        """
        Initialize a Parameter

        Args:
            name (str):
                Name of the parameter
            value (int | float | str):
                Value of the parameter
        """

    @property
    def name(self) -> str:
        """
        Name of the parameter
        """

    @property
    def value(self) -> Union[int, float, str]:
        """
        Value of the parameter
        """

name property

Name of the parameter

value property

Value of the parameter

__init__(name, value)

Initialize a Parameter

Parameters:

Name Type Description Default
name str

Name of the parameter

required
value int | float | str

Value of the parameter

required
Source code in python/opsml/experiment/_experiment.pyi
def __init__(
    self,
    name: str,
    value: Union[int, float, str],
) -> None:
    """
    Initialize a Parameter

    Args:
        name (str):
            Name of the parameter
        value (int | float | str):
            Value of the parameter
    """

get_experiment_metrics(experiment_uid, names=None)

Get metrics of an experiment

Parameters:

Name Type Description Default
experiment_uid str

UID of the experiment

required
names list[str] | None

Names of the metrics to get. If None, all metrics will be returned.

None

Returns:

Type Description
Metrics

Metrics

Source code in python/opsml/experiment/_experiment.pyi
def get_experiment_metrics(
    experiment_uid: str,
    names: Optional[list[str]] = None,
) -> Metrics:
    """
    Get metrics of an experiment

    Args:
        experiment_uid (str):
            UID of the experiment
        names (list[str] | None):
            Names of the metrics to get. If None, all metrics will be returned.

    Returns:
        Metrics
    """

get_experiment_parameters(experiment_uid, names=None)

Get parameters of an experiment

Parameters:

Name Type Description Default
experiment_uid str

UID of the experiment

required
names list[str] | None

Names of the parameters to get. If None, all parameters will be returned.

None

Returns:

Type Description
Parameters

Parameters

Source code in python/opsml/experiment/_experiment.pyi
def get_experiment_parameters(
    experiment_uid: str,
    names: Optional[list[str]] = None,
) -> Parameters:
    """
    Get parameters of an experiment

    Args:
        experiment_uid (str):
            UID of the experiment
        names (list[str] | None):
            Names of the parameters to get. If None, all parameters will be returned.

    Returns:
        Parameters
    """

start_experiment(space=None, name=None, code_dir=None, log_hardware=False, experiment_uid=None)

Start an Experiment

Parameters:

Name Type Description Default
space str | None

space to associate with ExperimentCard

None
name str | None

Name to associate with ExperimentCard

None
code_dir Path | None

Directory to log code from

None
log_hardware bool

Whether to log hardware information or not

False
experiment_uid str | None

Experiment UID. If provided, the experiment will be loaded from the server.

None

Returns:

Type Description
Experiment

Experiment

Source code in python/opsml/experiment/_experiment.pyi
def start_experiment(
    space: Optional[str] = None,
    name: Optional[str] = None,
    code_dir: Optional[Path] = None,
    log_hardware: bool = False,
    experiment_uid: Optional[str] = None,
) -> Experiment:
    """
    Start an Experiment

    Args:
        space (str | None):
            space to associate with `ExperimentCard`
        name (str | None):
            Name to associate with `ExperimentCard`
        code_dir (Path | None):
            Directory to log code from
        log_hardware (bool):
            Whether to log hardware information or not
        experiment_uid (str | None):
            Experiment UID. If provided, the experiment will be loaded from the server.

    Returns:
        Experiment
    """