scaffold.data.artifact_manager.wandb ==================================== .. py:module:: scaffold.data.artifact_manager.wandb Attributes ---------- .. autoapisummary:: scaffold.data.artifact_manager.wandb.logger Classes ------- .. autoapisummary:: scaffold.data.artifact_manager.wandb.WandbArtifactManager Module Contents --------------- .. py:class:: WandbArtifactManager(entity: Optional[str] = None, project: Optional[str] = None, collection: str = 'default') Bases: :py:obj:`scaffold.data.artifact_manager.base.ArtifactManager` Artifact manager that uses Weights & Biases (WandB) as the backend. This manager logs artifacts to WandB. In WandB, collections correspond to artifact types. Each artifact can contain multiple files, and versions are managed implicitly. .. note:: It is assumed that wandb.init() has been called before using this manager. Initialize the WandbArtifactManager. :param entity: If not provided, it's inferred from the active run / API settings. :type entity: Optional[str] :param project: If not provided, it's inferred from the active run / API settings. :type project: Optional[str] :param collection: The default collection (artifact type) name. Defaults to "default". :type collection: str :raises ValueError: If neither a project nor an active project can be identified. .. py:method:: download_artifact(artifact_name: str, collection: Optional[str] = None, version: Optional[str] = None, to: Optional[str] = None) -> Union[scaffold.data.artifact_manager.base.Artifact, scaffold.data.artifact_manager.base.TmpArtifact] Download a specific artifact to a local path. WandB artifacts are downloaded in a nested folder structure. :param artifact_name: The name of the artifact to download. :type artifact_name: str :param collection: The collection (artifact type) name. Defaults to the active collection. :type collection: Optional[str] :param version: The version of the artifact to download. If None, 'latest' is used. :type version: Optional[str] :param to: The local destination path where the artifact should be downloaded. If not provided, a TmpArtifact context manager is returned. :type to: Optional[str] :returns: If `to` is provided, returns an Artifact with metadata. Otherwise, returns a TmpArtifact context manager that also has an `artifact` property. :rtype: Union[Artifact, TmpArtifact] .. py:method:: exists_in_collection(artifact_name: str, collection: Optional[str] = None) -> bool Check if an artifact exists in the specified collection. .. note:: The WandB API does not provide a direct existence check, so this is implemented by listing all artifacts in the collection. :param artifact_name: The artifact name. :type artifact_name: str :param collection: The collection (artifact type) name. Defaults to the active collection. :type collection: Optional[str] :returns: True if the artifact exists in the collection, False otherwise. :rtype: bool .. py:method:: list_collection_names() -> Iterable[str] List all collections (artifact types) managed by WandB. :returns: A list of collection names corresponding to WandB artifact types. :rtype: Iterable[str] .. py:method:: log_files(artifact_name: str, local_path: str, description: str, collection: Optional[str] = None, artifact_path: Optional[str] = None) -> scaffold.data.artifact_manager.base.Artifact Log files or a directory as a WandB artifact. This method uploads the file or directory located at `local_path` to WandB. If `local_path` is a directory, it uses `add_dir`; otherwise, it uses `add_file`. :param artifact_name: The artifact name. :type artifact_name: str :param local_path: The local path to the file or directory to be logged. :type local_path: str :param description: The artifact description. Is ignored for this ArtifactManager implementation. :type description: str :param collection: The collection (artifact type) name. Defaults to the active collection. :type collection: Optional[str] :param artifact_path: An optional subpath within the artifact. :type artifact_path: Optional[str] :returns: The logged artifact with its metadata (name, collection, version). For WandB, the version is typically "latest" as WandB manages versions internally. :rtype: Artifact .. py:data:: logger