module
TrueFoundry.ml
function
get_client
disable_analytics
(bool, optional): To turn off usage analytics collection, pass True
. By default, this is set to False
.MLFoundry
: Instance of MLFoundry
class which represents a run
.class
MlFoundry
function
create_data_directory
ml_repo
(str): Name of the ML Repo in which you want to create data_directoryname
(str): Name of the DataDirectory to be created.description
(str): Description of the Datsetmetadata
(Dict <str>
: Any): Metadata about the data_directory in Dictionary form.DataDirectory
: An instance of class DataDirectoryfunction
create_ml_repo
name
(str, optional): The name of the Repository you want to create. if not given, it creates a name by itself.storage_integration_fqn
(str): The storage integration FQN to use for the experiment for saving artifacts.function
create_run
run
.
In a machine learning experiment run
represents a single experiment conducted under a project.
Args:
ml_repo
(str): The name of the project under which the run will be created. ml_repo should only contain alphanumerics (a-z,A-Z,0-9) or hyphen (-). The user must have ADMIN
or WRITE
access to this project.run_name
(Optional[str], optional): The name of the run. If not passed, a randomly generated name is assigned to the run. Under a project, all runs should have a unique name. If the passed run_name
is already used under a project, the run_name
will be de-duplicated by adding a suffix. run name should only contain alphanumerics (a-z,A-Z,0-9) or hyphen (-).tags
(Optional[Dict[str, Any]], optional): Optional tags to attach with this run. Tags are key-value pairs.MlFoundryRun
: An instance of MlFoundryRun
class which represents a run
.function
get_all_runs
READ
access to the project.
Args:
ml_repo
(str): Name of the project.pd.DataFrame
: dataframe with two columns- run_id and run_namefunction
get_artifact_version
ml_repo
(str): ML Repo to which artifact is loggedartifact_name
(str): Artifact Nameartifact_type
(str): The type of artifact to fetch (acceptable values: “artifact”, “model”, “plot”, “image”)version
(str | int): Artifact Version to fetch (default is the latest version)ArtifactVersion
: An ArtifactVersion instance of the artifactfunction
get_artifact_version_by_fqn
fqn
(str): Fully qualified name of the artifact version.ArtifactVersion
: An ArtifactVersion instance of the artifactfunction
get_data_directory
data_directory
by name
.
Args:
ml_repo
(str): name of an the project of which the data-directory is part of.name
(str): the name of the data-directoryDataDirectory
: An instance of class DataDirectoryfunction
get_data_directory_by_fqn
fqn
(str): Fully qualified name of the artifact version.DataDirectory
: An instance of class DataDirectoryfunction
get_data_directory_by_id
id
(uuid.UUID): Id of the data_directory.DataDirectory
: An instance of class DataDirectoryfunction
get_model_version
ml_repo
(str): ML Repo to which model is loggedname
(str): Model Nameversion
(str | int): Model Version to fetch (default is the latest version)ModelVersion
: The ModelVersion instance of the model.function
get_model_version_by_fqn
fqn
(str): Fully qualified name of the model version.ModelVersion
: The ModelVersion instance of the model.function
get_run_by_fqn
run
by fqn
.
fqn
stands for Fully Qualified Name. A run fqn
has the following pattern: tenant_name/ml_repo/run_name
If a run svm
under the project cat-classifier
in truefoundry
tenant, the fqn
will be truefoundry/cat-classifier/svm
.
Args:
run_fqn
(str): fqn
of an existing run.MlFoundryRun
: An instance of MlFoundryRun
class which represents a run
.function
get_run_by_id
run
by the run_id
.
Args:
run_id
(str): run_id or fqn of an existing run
.MlFoundryRun
: An instance of MlFoundryRun
class which represents a run
.function
get_run_by_name
run
by run_name
.
Args:
ml_repo
(str): name of the ml_repo of which the run is part of.run_name
(str): the name of the run requiredMlFoundryRun
: An instance of MlFoundryRun
class which represents a run
.function
get_tracking_uri
function
list_artifact_versions
ml_repo
(str): Repository in which the model is stored.name
(str): Name of the artifact whose version is requiredartifact_type
(ArtifactType): Type of artifact you want for example model, image, etc.Iterator[ArtifactVersion]
: An iterator that yields non deleted artifact-versions of an artifact under a given ml_repo sorted reverse by the version numberfunction
list_artifact_versions_by_fqn
artifact_fqn
: FQN of the Artifact to list versions for.An artifact_fqn looks like
{artifact_type}`: {org}/{user}/{project}/{artifact_name}`or
{artifact_type}`: {user}/{project}/{artifact_name}`Iterator[ArtifactVersion]
: An iterator that yields non deleted artifact versions under the given artifact_fqn sorted reverse by the version numberArtifactVersion
: An instance of mlfoundry.ArtifactVersion
function
list_data_directories
ml_repo
(str): Name of the ML Repositorymax_results
(int): Maximum number of Data Directory to listoffset
(int): Skip these number of instance of DataDirectory and then give the result from these number onwardsDataDirectory
: An instance of class DataDirectoryfunction
list_ml_repos
List[str]
: A list of names of ML Reposfunction
list_model_versions
ml_repo
(str): Repository in which the model is stored.name
(str): Name of the model whose version is requiredIterator[ModelVersion]
: An iterator that yields non deleted model versions of a model under a given ml_repo sorted reverse by the version numberfunction
list_model_versions_by_fqn
model_fqn
: FQN of the Model to list versions for.A model_fqn looks like
model`: {org}/{user}/{project}/{artifact_name}`or
model`: {user}/{project}/{artifact_name}`Iterator[ModelVersion]
: An iterator that yields non deleted model versions under the given model_fqn sorted reverse by the version numberModelVersion
: An instance of mlfoundry.ModelVersion
function
log_artifact
ml_repo
.
An artifact
is a list of local files and directories. This function packs the mentioned files and directories in artifact_paths
and uploads them to remote storage linked to the ml_repo
Args:
ml_repo
(str): Name of the ML Repo to which an artifact is to be logged.name
(str): Name of the Artifact. If an artifact with this name already exists under the current ml_repo, the logged artifact will be added as a new version under that name
. If no artifact exist with the given name
, the given artifact will be logged as version 1.artifact_paths
(List[truefoundry.ml.ArtifactPath], optional): A list of pairs of (source path, destination path) to add files and folders to the artifact version contents. The first member of the pair should be a file or directory path and the second member should be the path inside the artifact contents to upload to.description
(Optional[str], optional): arbitrary text upto 1024 characters to store as description. This field can be updated at any time after logging. Defaults to None
metadata
(Optional[Dict[str, Any]], optional): arbitrary json serializable dictionary to store metadata. For example, you can use this to store metrics, params, notes. This field can be updated at any time after logging. Defaults to None
truefoundry.ml.ArtifactVersion
: an instance of ArtifactVersion
that can be used to download the files, or update attributes like description, metadata.function
log_model
name
and linked to the current run. Multiple versions of the model can be logged as separate versions under the same name
.
Args:
ml_repo
(str): Name of the ML Repo to which an artifact is to be logged.name
(str): Name of the model. If a model with this name already exists under the current ML Repo, the logged model will be added as a new version under that name
. If no models exist with the given name
, the given model will be logged as version 1.model_file_or_folder
(str): Path to either a single file or a folder containing model files. This folder is usually created using serialization methods of libraries or frameworks e.g. joblib.dump
, model.save_pretrained(...)
, torch.save(...)
, model.save(...)
framework
(Union[enums.ModelFramework, str]): Model Framework. Ex:- pytorch, sklearn, tensorflow etc. The full list of supported frameworks can be found in mlfoundry.enums.ModelFramework
. Can also be None
when model
is None
.description
(Optional[str], optional): arbitrary text upto 1024 characters to store as description. This field can be updated at any time after logging. Defaults to None
metadata
(Optional[Dict[str, Any]], optional): arbitrary json serializable dictionary to store metadata. For example, you can use this to store metrics, params, notes. This field can be updated at any time after logging. Defaults to None
truefoundry.ml.ModelVersion
: an instance of ModelVersion
that can be used to download the files, load the model, or update attributes like description, metadata, schema.function
search_runs
READ
access to the project. Returns an iterator that returns a MLFoundryRun on each next call. All the runs under a project which matches the filter string and the run_view_type are returned.
Args:
ml_repo
(str): Name of the project. filter_string (str, optional): Filter query string, defaults to searching all runs. Identifier required in the LHS of a search expression.
Signifies an entity to compare against. An identifier has two parts separated by a period
: the type of the entity and the name of the entity. The type of the entity is metrics, params, attributes, or tags. The entity name can contain alphanumeric characters and special characters.
You can search using two run attributes
: status and artifact_uri. Both attributes have string values. When a metric, parameter, or tag name contains a special character like hyphen, space, period, and so on, enclose the entity name in double quotes or backticks, params.”model-type” or params.model-type
run_view_type
(str, optional): one of the following values “ACTIVE_ONLY”, “DELETED_ONLY”, or “ALL” runs. order_by (List[str], optional): List of columns to order by (e.g., “metrics.rmse”). Currently supported values are metric.key, parameter.key, tag.key, attribute.key. The order_by
column can contain an optional DESC
or ASC
value. The default is ASC
. The default ordering is to sort by start_time DESC
.
job_run_name
(str): Name of the job which are associated with the runs to get that runs
max_results
(int): max_results on the total numbers of run yielded through filter
Iterator[MlFoundryRun]
: MLFoundryRuns matching the search query.