tlc.core.objects.mutable_objects.run#

A collection of metadata about a run.

Module Contents#

Classes#

Class

Description

Run

A collection of metadata about a run.

API#

class tlc.core.objects.mutable_objects.run.Run(url: tlc.core.url.Url | None = None, created: str | None = None, last_modified: str | None = None, description: str | None = None, metrics: list[dict[str, Any]] | None = None, constants: dict[str, Any] | None = None, init_parameters: Any = None)#

Bases: tlc.core.objects.mutable_object.MutableObject

A collection of metadata about a run.

copy(run_name: str | None = None, project_name: str | None = None, root_url: tlc.core.url.Url | str | None = None, if_exists: typing.Literal[raise, rename, overwrite] = 'raise', *, destination_url: tlc.core.url.Url | None = None) tlc.core.objects.mutable_objects.run.Run#

Create a copy of this run.

The copy is performed to:

  1. A URL derived from the given run_name, project_name, and root_url if given

  2. destination_url, if given

  3. A generated URL derived from the run’s URL, if none of the above are given

Parameters:
  • run_name – The name of the run to create.

  • project_name – The name of the project to create the run in.

  • root_url – The root URL to create the run in.

  • if_exists – What to do if the destination URL already exists.

  • destination_url – The URL to copy the run to.

Returns:

The copied run.

static add_run_properties_to_schema(schema: tlc.core.schema.Schema, include_url: bool, include_last_modified: bool, include_is_url_writable: bool) None#

Adds the properties for a Run to a schema

add_input_table(input_table: tlc.core.objects.table.Table | tlc.core.url.Url | str) None#

Adds an input table to the run.

This updates the Run object to include the input table in the list of inputs to the Run.

Parameters:

input_table – The input table to add.

add_input_value(input_value: dict[str, Any]) None#

Adds a value to the inputs of the run.

Parameters:

input_value – The value to add.

add_output_value(output_value: dict[str, Any]) None#

Adds a value to the outputs of the run.

Parameters:

output_value – The value to add.

set_parameters(parameters: dict[str, Any]) None#

Set the parameters of the run.

Parameters:

parameters – The parameters to set.

set_description(description: str) None#

Set the description of the run.

Parameters:

description – The description to set.

classmethod from_url(url: tlc.core.url.Url | str) tlc.core.objects.mutable_objects.run.Run#

Creates a Run object from a URL.

Parameters:

url – The URL to the Run object.

Returns:

The Run object.

property metrics_tables: list[tlc.core.objects.table.Table]#

Returns a list of the metrics tables for this run.

reduce_embeddings_by_example_table_url(table_url: tlc.core.url.Url, delete_source_tables: bool = False, **kwargs: Any) dict[tlc.core.url.Url, tlc.core.url.Url]#

Reduces all metrics tables using a reduction method trained on a single table.

reduce_embeddings_by_foreign_table_url(foreign_table_url: tlc.core.url.Url, delete_source_tables: bool = False, **kwargs: Any) dict[tlc.core.url.Url, tlc.core.url.Url]#

Reduces all metrics tables in a Run using a reducer trained on the embeddings in a specified metrics table.

See tlc.reduce_embeddings_by_foreign_table_url for more information.

Parameters:
  • foreign_table_url – The Url of the foreign table to use for reduction.

  • delete_source_tables – If True, the source metrics tables will be deleted after reduction.

Returns:

A dictionary mapping the original table URLs to the reduced table URLs.

reduce_embeddings_per_dataset(delete_source_tables: bool = False, **kwargs: Any) dict[tlc.core.url.Url, tlc.core.url.Url]#

Reduces the embeddings for each dataset in this run.

See tlc.reduce_embeddings_per_dataset for more information.

Parameters:

delete_source_tables – If True, the source metrics tables will be deleted after reduction.

Returns:

A dictionary mapping the original table URLs to the reduced table URLs.

update_metrics_table_urls(url_mapping: dict[tlc.core.url.Url, tlc.core.url.Url]) None#

Replace metrics table URLs in this run with the new table URLs.

Parameters:

url_mapping – A dictionary mapping the original table URLs to the new table URLs.

update_metric_table_infos(metric_infos: list[tlc.core.builtins.types.MetricTableInfo], url_mapping: dict[tlc.core.url.Url, tlc.core.url.Url]) list[tlc.core.builtins.types.MetricTableInfo]#

Update metrics table with new URL, file size, and row count details.

Parameters:
  • metric_infos – A list of MetricTableInfo dicts.

  • url_mapping – A dictionary mapping the original table URLs to the new table URLs.

Returns:

A list of updated MetricTableInfo dicts.

update_metrics(metric_infos: list[tlc.core.builtins.types.MetricTableInfo] = []) None#

Update the metrics field of a run.

add_metrics_data(metrics: dict[str, tlc.core.builtins.types.MetricData], override_column_schemas: dict[str, tlc.core.schema.Schema] = {}, input_table_url: tlc.core.url.Url | str | None = None, table_writer_base_name: str = 'metrics', stream_name: str = '') list[tlc.core.builtins.types.MetricTableInfo]#

Write the given metrics to a Table and updates the run with the table info.

Parameters:
  • metrics – The metrics data (dict of column-names to columns) to write.

  • override_column_schemas – A dictionary of schemas to override the default schemas for the columns.

  • input_table_url – The URL of the table used to generate the metrics data. If provided, the metrics data will be augmented with extra columns to identify the example id and example table. Should only be provided if the metrics data corresponds 1-1 with the rows in the table.

  • table_writer_base_name – The base name of the written tables.

  • table_writer_key – A key used to further identify the written tables.

Returns:

The written table infos.

Raises:
  • ValueError – If the number of rows in the metrics data does not match the number of rows in the table, or the input_table_url is not a valid URL.

  • FileNotFoundError – If the input_table_url can not be found.