Skip to content

Artifact

Description¶

Comet Artifacts allow keeping track of assets beyond any particular experiment. You can keep track of Artifact versions, create many types of assets, manage them, and use them in any step in your ML pipelines - from training to production deployment.

Artifacts live in a Comet Project, are identified by their name and version string number.

Examples¶

library(cometr)
# Assuming you have COMET_API_KEY, COMET_WORKSPACE, COMET_PROJECT_NAME variables define
exp <- create_experiment()

# Create a Comet Artifact
artifact <- Artifact$new(artifact_name = "Artifact-Name", artifact_type = "Artifact-Type")
artifact$add("local-file")

exp$log_artifact(artifact)
exp$stop()

Methods¶

Public Methods¶

Method new()¶

Creates new Artifact object with provided parameters. After that, the Artifact object can be used to save assets and can be logged with an Experiment.

Usage

Artifact$new(
  artifact_name,
  artifact_type,
  artifact_version = NULL,
  aliases = NULL,
  metadata = NULL,
  version_tags = NULL
)

Arguments:

  • artifact_name (Required) Artifact name.
  • artifact_type (Required) The artifact type, for example 'dataset'.
  • artifact_version The version number to create. If not provided, a new version number will be created automatically.
  • aliases List of aliases. Some aliases to attach to the future Artifact Version. The aliases list is normalized to remove duplicates.
  • metadata Some additional meta-data to attach to the future Artifact Version.
  • version_tags List of tags to be attached to the future Artifact Version.

Method get_artifact_name()¶

Get the name of the artifact.

Usage

Artifact$get_artifact_name()

Method get_artifact_type()¶

Get the type of the artifact.

Usage

Artifact$get_artifact_type()

Method get_artifact_version()¶

Get the version of the artifact.

Usage

Artifact$get_artifact_version()

Method get_aliases()¶

Get the version of the artifact.

Usage

Artifact$get_aliases()

Method get_metadata()¶

Get the metadata of the artifact.

Usage

Artifact$get_metadata()

Method get_version_tags()¶

Get the list of tags of the artifact version.

Usage

Artifact$get_version_tags()

Method get_assets()¶

Get the list of assets of the artifact version.

Usage

Artifact$get_assets()

Method add()¶

Add a local asset to the current pending artifact object.

Usage

Artifact$add(
  local_path,
  overwrite = FALSE,
  logical_path = NULL,
  metadata = NULL
)

Arguments:

  • local_path (Required) Either a file/directory path of the files you want to log
  • overwrite If TRUE will overwrite all existing assets with the same name.
  • logical_path A custom file name to be displayed. If not provided the file name from the local_path argument will be used.
  • metadata Some additional data to attach to the asset.

Method add_remote()¶

Add a remote asset to the current pending artifact object. A Remote Asset is an asset but its content is not uploaded and stored on Comet. Rather a link for its location is stored so you can identify and distinguish between two experiment using different version of a dataset stored somewhere else.

Usage

Artifact$add_remote(
  uri,
  logical_path = NULL,
  overwrite = FALSE,
  metadata = NULL
)

Arguments:

  • uri (Required) The remote asset location, there is no imposed format and it could be a private link.
  • logical_path The "name" of the remote asset, could be a dataset name, a model file name.
  • overwrite If TRUE will overwrite all existing assets with the same name.
  • metadata Some additional data to attach to the asset.

Method add_asset()¶

Adds an initialized ArtifactAsset object to this Artifact.

Usage

Artifact$add_asset(asset)

Arguments:

Dec. 2, 2024