> ## Documentation Index
> Fetch the complete documentation index at: https://www.truefoundry.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Run

> Represents a single ML experiment run - log metrics, parameters, models, and artifacts

MlFoundryRun.

## Properties

<Accordion title="run_id">
  Get run\_id for the current `run`

  #### Returns

  <ResponseField name="return" type="str" />
</Accordion>

<Accordion title="run_name">
  Get run\_name for the current `run`

  #### Returns

  <ResponseField name="return" type="str" />
</Accordion>

<Accordion title="fqn">
  Get fqn for the current `run`

  #### Returns

  <ResponseField name="return" type="str" />
</Accordion>

<Accordion title="status">
  Get status for the current `run`

  #### Returns

  <ResponseField name="return" type="RunStatus">
    [🔗 RunStatus](/docs/truefoundry-ml-reference/enums#runstatus)
  </ResponseField>
</Accordion>

<Accordion title="ml_repo">
  Get ml\_repo name of which the current `run` is part of

  #### Returns

  <ResponseField name="return" type="str" />
</Accordion>

<Accordion title="auto_end">
  Tells whether automatic end for `run` is True or False

  #### Returns

  <ResponseField name="return" type="bool" />
</Accordion>

<Accordion title="dashboard_link">
  Get Mlfoundry dashboard link for a `run`

  #### Returns

  <ResponseField name="return" type="str" />
</Accordion>

## Methods

<Accordion title="end">
  End a `run`.

  #### Parameters

  <ParamField body="status" type="RunStatus" default="RunStatus.FINISHED">
    [🔗 RunStatus](/docs/truefoundry-ml-reference/enums#runstatus)
  </ParamField>

  #### Returns

  <ResponseField name="return" type="None" />

  #### Usage

  ```python lines theme={"dark"}
  from truefoundry.ml import get_client

  client = get_client()

  client.end(
      status="value",
  )
  ```
</Accordion>

<Accordion title="delete">
  This function permanently delete the run

  #### Returns

  <ResponseField name="return" type="Any" />

  #### Usage

  ```python lines theme={"dark"}
  from truefoundry.ml import get_client

  client = get_client()

  client.delete(
  )
  ```
</Accordion>

<Accordion title="list_artifact_versions">
  Get all the version of an artifact from a particular run to download contents or load them in memory

  #### Parameters

  <ParamField body="artifact_type" type="Optional[ArtifactType]" default="ArtifactType.ARTIFACT">
    [🔗 ArtifactType](/docs/truefoundry-ml-reference/enums#artifacttype)
  </ParamField>

  #### Returns

  <ResponseField name="return" type="Iterator[ArtifactVersion]">
    [🔗 ArtifactVersion](/docs/truefoundry-ml-reference/types#artifactversion)
  </ResponseField>

  #### Usage

  ```python lines theme={"dark"}
  from truefoundry.ml import get_client

  client = get_client()

  client.list_artifact_versions(
      artifact_type="value",
  )
  ```
</Accordion>

<Accordion title="list_model_versions">
  Get all the version of a models from a particular run to download contents or load them in memory

  #### Returns

  <ResponseField name="return" type="Iterator[ModelVersion]">
    [🔗 ModelVersion](/docs/truefoundry-ml-reference/types#modelversion)
  </ResponseField>

  #### Usage

  ```python lines theme={"dark"}
  from truefoundry.ml import get_client

  client = get_client()

  client.list_model_versions(
  )
  ```
</Accordion>

<Accordion title="log_artifact">
  Logs an artifact for the current ML Repo.

  #### Parameters

  <ParamField body="name" type="str" required />

  <ParamField body="artifact_paths" type="List[Union[Tuple[str], Tuple[str, Optional[str]], ArtifactPath]]" required>
    [🔗 ArtifactPath](/docs/truefoundry-ml-reference/types#artifactpath)
  </ParamField>

  <ParamField body="description" type="Optional[str]" default="None" />

  <ParamField body="metadata" type="Optional[Dict[str, Any]]" default="None" />

  <ParamField body="step" type="Optional[int]" default="0" />

  <ParamField body="progress" type="Optional[bool]" default="None" />

  #### Returns

  <ResponseField name="return" type="ArtifactVersion">
    [🔗 ArtifactVersion](/docs/truefoundry-ml-reference/types#artifactversion)
  </ResponseField>

  #### Usage

  ```python lines theme={"dark"}
  from truefoundry.ml import get_client

  client = get_client()

  client.log_artifact(
      name="my-run",
      artifact_paths=[ArtifactPath("file.txt")],
      description="value",
      metadata="value",
      step="value",
      progress="value",
  )
  ```
</Accordion>

<Accordion title="log_metrics">
  Log metrics for the current `run`.

  #### Parameters

  <ParamField body="metric_dict" type="Dict[str, Union[int, float]]" required />

  <ParamField body="step" type="int" default="0" />

  #### Returns

  <ResponseField name="return" type="None" />

  #### Usage

  ```python lines theme={"dark"}
  from truefoundry.ml import get_client

  client = get_client()

  client.log_metrics(
      metric_dict="value",
      step="value",
  )
  ```
</Accordion>

<Accordion title="log_params">
  Logs parameters for the run.

  #### Parameters

  <ParamField body="param_dict" type="ParamsType" required />

  <ParamField body="flatten_params" type="bool" default="False" />

  #### Returns

  <ResponseField name="return" type="None" />

  #### Usage

  ```python lines theme={"dark"}
  from truefoundry.ml import get_client

  client = get_client()

  client.log_params(
      param_dict="value",
      flatten_params="value",
  )
  ```
</Accordion>

<Accordion title="set_tags">
  Set tags for the current `run`.

  #### Parameters

  <ParamField body="tags" type="Dict[str, str]" required />

  #### Returns

  <ResponseField name="return" type="None" />

  #### Usage

  ```python lines theme={"dark"}
  from truefoundry.ml import get_client

  client = get_client()

  client.set_tags(
      tags={"key": "value"},
  )
  ```
</Accordion>

<Accordion title="get_tags">
  Returns all the tags set for the current `run`.

  #### Parameters

  <ParamField body="no_cache" type="Any" default="False" />

  #### Returns

  <ResponseField name="return" type="Dict[str, str]" />

  #### Usage

  ```python lines theme={"dark"}
  from truefoundry.ml import get_client

  client = get_client()

  client.get_tags(
      no_cache="value",
  )
  ```
</Accordion>

<Accordion title="get_metrics">
  Get metrics logged for the current `run` grouped by metric name.

  #### Parameters

  <ParamField body="metric_names" type="Optional[Iterable[str]]" default="None" />

  #### Returns

  <ResponseField name="return" type="Dict[str, List[Metric]]">
    [🔗 Metric](/docs/truefoundry-ml-reference/types#metric)
  </ResponseField>

  #### Usage

  ```python lines theme={"dark"}
  from truefoundry.ml import get_client

  client = get_client()

  client.get_metrics(
      metric_names="value",
  )
  ```
</Accordion>

<Accordion title="get_params">
  Get all the params logged for the current `run`.

  #### Parameters

  <ParamField body="no_cache" type="Any" default="False" />

  #### Returns

  <ResponseField name="return" type="Dict[str, str]" />

  #### Usage

  ```python lines theme={"dark"}
  from truefoundry.ml import get_client

  client = get_client()

  client.get_params(
      no_cache="value",
  )
  ```
</Accordion>

<Accordion title="log_model">
  Serialize and log a versioned model under the current ML Repo. Each logged model generates a new version

  #### Parameters

  <ParamField body="name" type="str" required />

  <ParamField body="model_file_or_folder" type="Union[str, BlobStorageDirectory]" required>
    [🔗 BlobStorageDirectory](/docs/truefoundry-ml-reference/types#blobstoragedirectory)
  </ParamField>

  <ParamField body="description" type="Optional[str]" default="None" />

  <ParamField body="metadata" type="Optional[Dict[str, Any]]" default="None" />

  <ParamField body="step" type="int" default="0" />

  <ParamField body="progress" type="Optional[bool]" default="None" />

  <ParamField body="framework" type="Optional[Union[str, ModelFramework, Any]]" default="None">
    [🔗 ModelFramework](/docs/truefoundry-ml-reference/enums#modelframework)
  </ParamField>

  <ParamField body="environment" type="Optional[ModelVersionEnvironment]" default="None">
    [🔗 ModelVersionEnvironment](/docs/truefoundry-ml-reference/types#modelversionenvironment)
  </ParamField>

  #### Returns

  <ResponseField name="return" type="ModelVersion">
    [🔗 ModelVersion](/docs/truefoundry-ml-reference/types#modelversion)
  </ResponseField>

  #### Usage

  ```python lines theme={"dark"}
  from truefoundry.ml import get_client

  client = get_client()

  client.log_model(
      name="my-run",
      model_file_or_folder="model.pkl",
      description="value",
      metadata="value",
      step="value",
      progress="value",
      framework="value",
      environment="value",
  )
  ```
</Accordion>

<Accordion title="log_images">
  Log images under the current `run` at the given `step`.

  #### Parameters

  <ParamField body="images" type="Dict[str, Image]" required>
    [🔗 Image](/docs/truefoundry-ml-reference/types#image)
  </ParamField>

  <ParamField body="step" type="int" default="0" />

  #### Returns

  <ResponseField name="return" type="None" />

  #### Usage

  ```python lines theme={"dark"}
  from truefoundry.ml import get_client

  client = get_client()

  client.log_images(
      images="value",
      step="value",
  )
  ```
</Accordion>

<Accordion title="log_plots">
  Log custom plots under the current `run` at the given `step`.

  #### Parameters

  <ParamField body="plots" type="Dict[str, Union[Any, Any, Any, Plot]]" required>
    [🔗 Plot](/docs/truefoundry-ml-reference/types#plot)
  </ParamField>

  <ParamField body="step" type="int" default="0" />

  #### Returns

  <ResponseField name="return" type="None" />

  #### Usage

  ```python lines theme={"dark"}
  from truefoundry.ml import get_client

  client = get_client()

  client.log_plots(
      plots="value",
      step="value",
  )
  ```
</Accordion>
