Skip to content

Integrations Overview

tensoris.lib.integrations

Classes

HuggingFaceIntegration

Hugging Face Hub helper for downloading datasets/models and pushing PyTorch checkpoints.

References

Hugging Face Hub Python SDK: https://huggingface.co/docs/huggingface_hub/

Source code in src/tensoris/lib/integrations/huggingface.py
class HuggingFaceIntegration:
    """Hugging Face Hub helper for downloading datasets/models and pushing PyTorch checkpoints.

    References:
        Hugging Face Hub Python SDK: https://huggingface.co/docs/huggingface_hub/
    """

    def __init__(self, token: str | None = None) -> None:
        """Initialize Hugging Face Hub client.

        Args:
            token: Optional Hugging Face User Access Token (defaults to HF_TOKEN env var).
        """
        self.token = token or os.environ.get("HF_TOKEN")

    @property
    def is_available(self) -> bool:
        """Check if huggingface_hub library is installed."""
        return _HF_AVAILABLE

    def push_model(
        self,
        repo_id: str,
        local_dir: str | Path,
        commit_message: str = "Upload model checkpoint",
    ) -> str:
        """Upload local model directory or checkpoint files to Hugging Face Hub repository.

        Args:
            repo_id: Target Hugging Face Hub repo ID (e.g. 'username/model-name').
            local_dir: Local folder path containing checkpoint weights and configs.
            commit_message: Git commit message on Hub repo.

        Returns:
            URL string of published Hugging Face repository.
        """
        if not self.is_available:
            raise RuntimeError(
                "huggingface_hub package is not installed. Install via `pip install huggingface_hub`."
            )
        api = huggingface_hub.HfApi(token=self.token)
        api.create_repo(repo_id=repo_id, exist_ok=True)
        return api.upload_folder(
            folder_path=str(local_dir),
            repo_id=repo_id,
            commit_message=commit_message,
        )

    def download_file(
        self, repo_id: str, filename: str, local_dir: str | Path = "inputs/models"
    ) -> Path:
        """Download a single model weight file from Hugging Face Hub.

        Args:
            repo_id: Source Hugging Face Hub repository ID.
            filename: Target file name (e.g. 'pytorch_model.bin').
            local_dir: Destination folder path.

        Returns:
            Path object pointing to downloaded file.
        """
        if not self.is_available:
            raise RuntimeError("huggingface_hub package is not installed.")
        downloaded = huggingface_hub.hf_hub_download(
            repo_id=repo_id,
            filename=filename,
            local_dir=str(local_dir),
            token=self.token,
        )
        return Path(downloaded)
Attributes
is_available property
is_available

Check if huggingface_hub library is installed.

Methods:
__init__
__init__(token=None)

Initialize Hugging Face Hub client.

Parameters:

Name Type Description Default
token str | None

Optional Hugging Face User Access Token (defaults to HF_TOKEN env var).

None
Source code in src/tensoris/lib/integrations/huggingface.py
def __init__(self, token: str | None = None) -> None:
    """Initialize Hugging Face Hub client.

    Args:
        token: Optional Hugging Face User Access Token (defaults to HF_TOKEN env var).
    """
    self.token = token or os.environ.get("HF_TOKEN")
download_file
download_file(repo_id, filename, local_dir='inputs/models')

Download a single model weight file from Hugging Face Hub.

Parameters:

Name Type Description Default
repo_id str

Source Hugging Face Hub repository ID.

required
filename str

Target file name (e.g. 'pytorch_model.bin').

required
local_dir str | Path

Destination folder path.

'inputs/models'

Returns:

Type Description
Path

Path object pointing to downloaded file.

Source code in src/tensoris/lib/integrations/huggingface.py
def download_file(
    self, repo_id: str, filename: str, local_dir: str | Path = "inputs/models"
) -> Path:
    """Download a single model weight file from Hugging Face Hub.

    Args:
        repo_id: Source Hugging Face Hub repository ID.
        filename: Target file name (e.g. 'pytorch_model.bin').
        local_dir: Destination folder path.

    Returns:
        Path object pointing to downloaded file.
    """
    if not self.is_available:
        raise RuntimeError("huggingface_hub package is not installed.")
    downloaded = huggingface_hub.hf_hub_download(
        repo_id=repo_id,
        filename=filename,
        local_dir=str(local_dir),
        token=self.token,
    )
    return Path(downloaded)
push_model
push_model(
    repo_id,
    local_dir,
    commit_message="Upload model checkpoint",
)

Upload local model directory or checkpoint files to Hugging Face Hub repository.

Parameters:

Name Type Description Default
repo_id str

Target Hugging Face Hub repo ID (e.g. 'username/model-name').

required
local_dir str | Path

Local folder path containing checkpoint weights and configs.

required
commit_message str

Git commit message on Hub repo.

'Upload model checkpoint'

Returns:

Type Description
str

URL string of published Hugging Face repository.

Source code in src/tensoris/lib/integrations/huggingface.py
def push_model(
    self,
    repo_id: str,
    local_dir: str | Path,
    commit_message: str = "Upload model checkpoint",
) -> str:
    """Upload local model directory or checkpoint files to Hugging Face Hub repository.

    Args:
        repo_id: Target Hugging Face Hub repo ID (e.g. 'username/model-name').
        local_dir: Local folder path containing checkpoint weights and configs.
        commit_message: Git commit message on Hub repo.

    Returns:
        URL string of published Hugging Face repository.
    """
    if not self.is_available:
        raise RuntimeError(
            "huggingface_hub package is not installed. Install via `pip install huggingface_hub`."
        )
    api = huggingface_hub.HfApi(token=self.token)
    api.create_repo(repo_id=repo_id, exist_ok=True)
    return api.upload_folder(
        folder_path=str(local_dir),
        repo_id=repo_id,
        commit_message=commit_message,
    )

KaggleIntegration

Kaggle API Helper for downloading datasets and submitting competition predictions.

References

Kaggle API Documentation: https://github.com/Kaggle/kaggle-api

Source code in src/tensoris/lib/integrations/kaggle.py
class KaggleIntegration:
    """Kaggle API Helper for downloading datasets and submitting competition predictions.

    References:
        Kaggle API Documentation: https://github.com/Kaggle/kaggle-api
    """

    def __init__(self, api_key: str | None = None, username: str | None = None) -> None:
        """Initialize Kaggle API client.

        Args:
            api_key: Optional Kaggle API key (defaults to KAGGLE_KEY env var).
            username: Optional Kaggle username (defaults to KAGGLE_USERNAME env var).
        """
        if api_key:
            os.environ["KAGGLE_KEY"] = api_key
        if username:
            os.environ["KAGGLE_USERNAME"] = username

    @property
    def is_available(self) -> bool:
        """Check if Kaggle library is installed and authenticated."""
        return _KAGGLE_AVAILABLE

    def download_dataset(
        self, dataset_handle: str, output_dir: str | Path = "inputs/datasets"
    ) -> Path:
        """Download and unzip a Kaggle dataset.

        Args:
            dataset_handle: Kaggle dataset identifier (e.g. 'zillow/zecon').
            output_dir: Destination directory path.

        Returns:
            Path object pointing to the output directory.
        """
        if not self.is_available:
            raise RuntimeError(
                "Kaggle package is not installed or configured. Install via `pip install kaggle` "
                "and set KAGGLE_USERNAME and KAGGLE_KEY environment variables."
            )
        output_path = Path(output_dir)
        output_path.mkdir(parents=True, exist_ok=True)
        kaggle.api.dataset_download_files(
            dataset_handle, path=str(output_path), unzip=True
        )
        return output_path

    def submit_competition(
        self, file_path: str | Path, competition: str, message: str
    ) -> None:
        """Submit a prediction CSV file to a Kaggle competition.

        Args:
            file_path: Path to submission CSV file.
            competition: Kaggle competition handle.
            message: Submission description message.
        """
        if not self.is_available:
            raise RuntimeError("Kaggle package is not available.")
        kaggle.api.competition_submit(
            str(file_path), message=message, competition=competition
        )
Attributes
is_available property
is_available

Check if Kaggle library is installed and authenticated.

Methods:
__init__
__init__(api_key=None, username=None)

Initialize Kaggle API client.

Parameters:

Name Type Description Default
api_key str | None

Optional Kaggle API key (defaults to KAGGLE_KEY env var).

None
username str | None

Optional Kaggle username (defaults to KAGGLE_USERNAME env var).

None
Source code in src/tensoris/lib/integrations/kaggle.py
def __init__(self, api_key: str | None = None, username: str | None = None) -> None:
    """Initialize Kaggle API client.

    Args:
        api_key: Optional Kaggle API key (defaults to KAGGLE_KEY env var).
        username: Optional Kaggle username (defaults to KAGGLE_USERNAME env var).
    """
    if api_key:
        os.environ["KAGGLE_KEY"] = api_key
    if username:
        os.environ["KAGGLE_USERNAME"] = username
download_dataset
download_dataset(
    dataset_handle, output_dir="inputs/datasets"
)

Download and unzip a Kaggle dataset.

Parameters:

Name Type Description Default
dataset_handle str

Kaggle dataset identifier (e.g. 'zillow/zecon').

required
output_dir str | Path

Destination directory path.

'inputs/datasets'

Returns:

Type Description
Path

Path object pointing to the output directory.

Source code in src/tensoris/lib/integrations/kaggle.py
def download_dataset(
    self, dataset_handle: str, output_dir: str | Path = "inputs/datasets"
) -> Path:
    """Download and unzip a Kaggle dataset.

    Args:
        dataset_handle: Kaggle dataset identifier (e.g. 'zillow/zecon').
        output_dir: Destination directory path.

    Returns:
        Path object pointing to the output directory.
    """
    if not self.is_available:
        raise RuntimeError(
            "Kaggle package is not installed or configured. Install via `pip install kaggle` "
            "and set KAGGLE_USERNAME and KAGGLE_KEY environment variables."
        )
    output_path = Path(output_dir)
    output_path.mkdir(parents=True, exist_ok=True)
    kaggle.api.dataset_download_files(
        dataset_handle, path=str(output_path), unzip=True
    )
    return output_path
submit_competition
submit_competition(file_path, competition, message)

Submit a prediction CSV file to a Kaggle competition.

Parameters:

Name Type Description Default
file_path str | Path

Path to submission CSV file.

required
competition str

Kaggle competition handle.

required
message str

Submission description message.

required
Source code in src/tensoris/lib/integrations/kaggle.py
def submit_competition(
    self, file_path: str | Path, competition: str, message: str
) -> None:
    """Submit a prediction CSV file to a Kaggle competition.

    Args:
        file_path: Path to submission CSV file.
        competition: Kaggle competition handle.
        message: Submission description message.
    """
    if not self.is_available:
        raise RuntimeError("Kaggle package is not available.")
    kaggle.api.competition_submit(
        str(file_path), message=message, competition=competition
    )

RoboflowIntegration

Roboflow Helper for downloading computer vision datasets in YOLO, COCO, or Pascal VOC formats.

References

Roboflow Python SDK Documentation: https://docs.roboflow.com/

Source code in src/tensoris/lib/integrations/roboflow.py
class RoboflowIntegration:
    """Roboflow Helper for downloading computer vision datasets in YOLO, COCO, or Pascal VOC formats.

    References:
        Roboflow Python SDK Documentation: https://docs.roboflow.com/
    """

    def __init__(self, api_key: str | None = None) -> None:
        """Initialize Roboflow client.

        Args:
            api_key: Optional Roboflow API key (defaults to ROBOFLOW_API_KEY env var).
        """
        self.api_key = api_key or os.environ.get("ROBOFLOW_API_KEY")

    @property
    def is_available(self) -> bool:
        """Check if roboflow package is installed."""
        return _ROBOFLOW_AVAILABLE

    def download_dataset(
        self,
        workspace: str,
        project_id: str,
        version: int,
        model_format: str = "yolov8",
        output_dir: str | Path = "inputs/datasets",
    ) -> Any:
        """Download dataset version from Roboflow Universe or Workspace.

        Args:
            workspace: Roboflow workspace identifier.
            project_id: Roboflow project ID.
            version: Dataset version number integer.
            model_format: Export format ('yolov8', 'coco', 'pascal_voc', 'tfrecord').
            output_dir: Destination directory.

        Returns:
            Roboflow dataset download object containing dataset location.
        """
        if not self.is_available:
            raise RuntimeError(
                "roboflow package is not installed. Install via `pip install roboflow` "
                "and set ROBOFLOW_API_KEY environment variable."
            )
        if not self.api_key:
            raise ValueError(
                "ROBOFLOW_API_KEY is required to download datasets from Roboflow."
            )

        rf = roboflow.Roboflow(api_key=self.api_key)
        proj = rf.workspace(workspace).project(project_id)
        dataset = proj.version(version).download(model_format, location=str(output_dir))
        return dataset
Attributes
is_available property
is_available

Check if roboflow package is installed.

Methods:
__init__
__init__(api_key=None)

Initialize Roboflow client.

Parameters:

Name Type Description Default
api_key str | None

Optional Roboflow API key (defaults to ROBOFLOW_API_KEY env var).

None
Source code in src/tensoris/lib/integrations/roboflow.py
def __init__(self, api_key: str | None = None) -> None:
    """Initialize Roboflow client.

    Args:
        api_key: Optional Roboflow API key (defaults to ROBOFLOW_API_KEY env var).
    """
    self.api_key = api_key or os.environ.get("ROBOFLOW_API_KEY")
download_dataset
download_dataset(
    workspace,
    project_id,
    version,
    model_format="yolov8",
    output_dir="inputs/datasets",
)

Download dataset version from Roboflow Universe or Workspace.

Parameters:

Name Type Description Default
workspace str

Roboflow workspace identifier.

required
project_id str

Roboflow project ID.

required
version int

Dataset version number integer.

required
model_format str

Export format ('yolov8', 'coco', 'pascal_voc', 'tfrecord').

'yolov8'
output_dir str | Path

Destination directory.

'inputs/datasets'

Returns:

Type Description
Any

Roboflow dataset download object containing dataset location.

Source code in src/tensoris/lib/integrations/roboflow.py
def download_dataset(
    self,
    workspace: str,
    project_id: str,
    version: int,
    model_format: str = "yolov8",
    output_dir: str | Path = "inputs/datasets",
) -> Any:
    """Download dataset version from Roboflow Universe or Workspace.

    Args:
        workspace: Roboflow workspace identifier.
        project_id: Roboflow project ID.
        version: Dataset version number integer.
        model_format: Export format ('yolov8', 'coco', 'pascal_voc', 'tfrecord').
        output_dir: Destination directory.

    Returns:
        Roboflow dataset download object containing dataset location.
    """
    if not self.is_available:
        raise RuntimeError(
            "roboflow package is not installed. Install via `pip install roboflow` "
            "and set ROBOFLOW_API_KEY environment variable."
        )
    if not self.api_key:
        raise ValueError(
            "ROBOFLOW_API_KEY is required to download datasets from Roboflow."
        )

    rf = roboflow.Roboflow(api_key=self.api_key)
    proj = rf.workspace(workspace).project(project_id)
    dataset = proj.version(version).download(model_format, location=str(output_dir))
    return dataset

UltralyticsIntegration

Ultralytics YOLO model helper for object detection, segmentation, and classification workflows.

References

Ultralytics Documentation: https://docs.ultralytics.com/

Source code in src/tensoris/lib/integrations/ultralytics.py
class UltralyticsIntegration:
    """Ultralytics YOLO model helper for object detection, segmentation, and classification workflows.

    References:
        Ultralytics Documentation: https://docs.ultralytics.com/
    """

    def __init__(self, model_name: str = "yolov8n.pt") -> None:
        """Initialize Ultralytics YOLO model.

        Args:
            model_name: Pretrained YOLO weight file or config path (e.g. 'yolov8n.pt', 'yolov8x-seg.pt').
        """
        self.model_name = model_name
        self.model = None

    @property
    def is_available(self) -> bool:
        """Check if ultralytics package is installed."""
        return _ULTRALYTICS_AVAILABLE

    def load_model(self) -> Any:
        """Instantiate Ultralytics YOLO model class."""
        if not self.is_available:
            raise RuntimeError(
                "ultralytics package is not installed. Install via `pip install ultralytics`."
            )
        self.model = ultralytics.YOLO(self.model_name)  # type: ignore
        return self.model

    def train(
        self, data_yaml: str | Path, epochs: int = 50, imgsz: int = 640, batch: int = 16
    ) -> Any:
        """Train YOLO model on dataset.

        Args:
            data_yaml: Path to dataset configuration YAML file.
            epochs: Training epoch count.
            imgsz: Target image resolution size.
            batch: Training batch size.

        Returns:
            Training results object.
        """
        if self.model is None:
            self.load_model()
        assert self.model is not None
        return self.model.train(
            data=str(data_yaml),
            epochs=epochs,
            imgsz=imgsz,
            batch=batch,
        )  # type: ignore

    def export(self, format: str = "onnx") -> str:
        """Export trained YOLO model to deployment format (ONNX, TorchScript, Engine).

        Args:
            format: Output target format ('onnx', 'torchscript', 'engine', 'openvino').

        Returns:
            String path of exported model weight file.
        """
        if self.model is None:
            self.load_model()
        assert self.model is not None
        return self.model.export(format=format)  # type: ignore
Attributes
is_available property
is_available

Check if ultralytics package is installed.

Methods:
__init__
__init__(model_name='yolov8n.pt')

Initialize Ultralytics YOLO model.

Parameters:

Name Type Description Default
model_name str

Pretrained YOLO weight file or config path (e.g. 'yolov8n.pt', 'yolov8x-seg.pt').

'yolov8n.pt'
Source code in src/tensoris/lib/integrations/ultralytics.py
def __init__(self, model_name: str = "yolov8n.pt") -> None:
    """Initialize Ultralytics YOLO model.

    Args:
        model_name: Pretrained YOLO weight file or config path (e.g. 'yolov8n.pt', 'yolov8x-seg.pt').
    """
    self.model_name = model_name
    self.model = None
export
export(format='onnx')

Export trained YOLO model to deployment format (ONNX, TorchScript, Engine).

Parameters:

Name Type Description Default
format str

Output target format ('onnx', 'torchscript', 'engine', 'openvino').

'onnx'

Returns:

Type Description
str

String path of exported model weight file.

Source code in src/tensoris/lib/integrations/ultralytics.py
def export(self, format: str = "onnx") -> str:
    """Export trained YOLO model to deployment format (ONNX, TorchScript, Engine).

    Args:
        format: Output target format ('onnx', 'torchscript', 'engine', 'openvino').

    Returns:
        String path of exported model weight file.
    """
    if self.model is None:
        self.load_model()
    assert self.model is not None
    return self.model.export(format=format)  # type: ignore
load_model
load_model()

Instantiate Ultralytics YOLO model class.

Source code in src/tensoris/lib/integrations/ultralytics.py
def load_model(self) -> Any:
    """Instantiate Ultralytics YOLO model class."""
    if not self.is_available:
        raise RuntimeError(
            "ultralytics package is not installed. Install via `pip install ultralytics`."
        )
    self.model = ultralytics.YOLO(self.model_name)  # type: ignore
    return self.model
train
train(data_yaml, epochs=50, imgsz=640, batch=16)

Train YOLO model on dataset.

Parameters:

Name Type Description Default
data_yaml str | Path

Path to dataset configuration YAML file.

required
epochs int

Training epoch count.

50
imgsz int

Target image resolution size.

640
batch int

Training batch size.

16

Returns:

Type Description
Any

Training results object.

Source code in src/tensoris/lib/integrations/ultralytics.py
def train(
    self, data_yaml: str | Path, epochs: int = 50, imgsz: int = 640, batch: int = 16
) -> Any:
    """Train YOLO model on dataset.

    Args:
        data_yaml: Path to dataset configuration YAML file.
        epochs: Training epoch count.
        imgsz: Target image resolution size.
        batch: Training batch size.

    Returns:
        Training results object.
    """
    if self.model is None:
        self.load_model()
    assert self.model is not None
    return self.model.train(
        data=str(data_yaml),
        epochs=epochs,
        imgsz=imgsz,
        batch=batch,
    )  # type: ignore

WandbIntegration

Weights & Biases Logger for metric tracking, artifact logging, and hyperparameter sweeps.

References

Weights & Biases Python SDK Documentation: https://docs.wandb.ai/

Source code in src/tensoris/lib/integrations/wandb.py
class WandbIntegration:
    """Weights & Biases Logger for metric tracking, artifact logging, and hyperparameter sweeps.

    References:
        Weights & Biases Python SDK Documentation: https://docs.wandb.ai/
    """

    def __init__(
        self,
        project: str = "deep-learning-project",
        entity: str | None = None,
        config: dict[str, Any] | None = None,
        name: str | None = None,
        mode: str = "online",
    ) -> None:
        """Initialize W&B run.

        Args:
            project: W&B project name.
            entity: W&B username or team entity.
            config: Hyperparameter configuration dictionary.
            name: Display name for the run.
            mode: Run mode ('online', 'offline', or 'disabled').
        """
        self.project = project
        self.entity = entity
        self.config = config or {}
        self.name = name
        self.mode = mode
        self.run = None

    @property
    def is_available(self) -> bool:
        """Check if wandb library is installed."""
        return _WANDB_AVAILABLE

    def init(self) -> Any:
        """Initialize W&B run context."""
        if not self.is_available:
            raise RuntimeError(
                "wandb package is not installed. Install via `pip install wandb`."
            )
        self.run = wandb.init(
            project=self.project,
            entity=self.entity,
            config=self.config,
            name=self.name,
            mode=self.mode,
        )
        return self.run

    def log(self, metrics: dict[str, Any], step: int | None = None) -> None:
        """Log metric key-value dictionary to W&B dashboard.

        Args:
            metrics: Dictionary of numerical metrics or media logs.
            step: Optional global training step number.
        """
        if self.is_available and self.run is not None:
            wandb.log(metrics, step=step)

    def log_artifact(
        self, file_path: str, artifact_name: str, artifact_type: str = "model"
    ) -> None:
        """Upload checkpoint file or artifact to W&B.

        Args:
            file_path: Local file path to upload.
            artifact_name: W&B artifact name identifier.
            artifact_type: Artifact category ('model', 'dataset', 'checkpoint').
        """
        if self.is_available and self.run is not None:
            artifact = wandb.Artifact(artifact_name, type=artifact_type)
            artifact.add_file(file_path)
            self.run.log_artifact(artifact)

    def finish(self) -> None:
        """Finish W&B run."""
        if self.is_available and self.run is not None:
            wandb.finish()
Attributes
is_available property
is_available

Check if wandb library is installed.

Methods:
__init__
__init__(
    project="deep-learning-project",
    entity=None,
    config=None,
    name=None,
    mode="online",
)

Initialize W&B run.

Parameters:

Name Type Description Default
project str

W&B project name.

'deep-learning-project'
entity str | None

W&B username or team entity.

None
config dict[str, Any] | None

Hyperparameter configuration dictionary.

None
name str | None

Display name for the run.

None
mode str

Run mode ('online', 'offline', or 'disabled').

'online'
Source code in src/tensoris/lib/integrations/wandb.py
def __init__(
    self,
    project: str = "deep-learning-project",
    entity: str | None = None,
    config: dict[str, Any] | None = None,
    name: str | None = None,
    mode: str = "online",
) -> None:
    """Initialize W&B run.

    Args:
        project: W&B project name.
        entity: W&B username or team entity.
        config: Hyperparameter configuration dictionary.
        name: Display name for the run.
        mode: Run mode ('online', 'offline', or 'disabled').
    """
    self.project = project
    self.entity = entity
    self.config = config or {}
    self.name = name
    self.mode = mode
    self.run = None
finish
finish()

Finish W&B run.

Source code in src/tensoris/lib/integrations/wandb.py
def finish(self) -> None:
    """Finish W&B run."""
    if self.is_available and self.run is not None:
        wandb.finish()
init
init()

Initialize W&B run context.

Source code in src/tensoris/lib/integrations/wandb.py
def init(self) -> Any:
    """Initialize W&B run context."""
    if not self.is_available:
        raise RuntimeError(
            "wandb package is not installed. Install via `pip install wandb`."
        )
    self.run = wandb.init(
        project=self.project,
        entity=self.entity,
        config=self.config,
        name=self.name,
        mode=self.mode,
    )
    return self.run
log
log(metrics, step=None)

Log metric key-value dictionary to W&B dashboard.

Parameters:

Name Type Description Default
metrics dict[str, Any]

Dictionary of numerical metrics or media logs.

required
step int | None

Optional global training step number.

None
Source code in src/tensoris/lib/integrations/wandb.py
def log(self, metrics: dict[str, Any], step: int | None = None) -> None:
    """Log metric key-value dictionary to W&B dashboard.

    Args:
        metrics: Dictionary of numerical metrics or media logs.
        step: Optional global training step number.
    """
    if self.is_available and self.run is not None:
        wandb.log(metrics, step=step)
log_artifact
log_artifact(
    file_path, artifact_name, artifact_type="model"
)

Upload checkpoint file or artifact to W&B.

Parameters:

Name Type Description Default
file_path str

Local file path to upload.

required
artifact_name str

W&B artifact name identifier.

required
artifact_type str

Artifact category ('model', 'dataset', 'checkpoint').

'model'
Source code in src/tensoris/lib/integrations/wandb.py
def log_artifact(
    self, file_path: str, artifact_name: str, artifact_type: str = "model"
) -> None:
    """Upload checkpoint file or artifact to W&B.

    Args:
        file_path: Local file path to upload.
        artifact_name: W&B artifact name identifier.
        artifact_type: Artifact category ('model', 'dataset', 'checkpoint').
    """
    if self.is_available and self.run is not None:
        artifact = wandb.Artifact(artifact_name, type=artifact_type)
        artifact.add_file(file_path)
        self.run.log_artifact(artifact)