Skip to content

Model

The model kind stores a generic machine-learning model when no specialized kind metadata is needed. The log_model() and register_model() functions are provided by the SDK.

Create

Log

log_model

Create and upload a model entity.

Parameters:

Name Type Description Default
project str

Project name.

required
name str

Entity name. If omitted, it is inferred from source.

None
source SourcesOrListOfSources

Local model source path or paths.

required
drop_existing bool

Whether to drop existing entity with the same name.

False
path str

Destination path. If omitted, it is generated.

None
version str

Entity version.

None
description str

Human-readable entity description.

None
labels list[str]

Entity labels.

None
framework str

Model framework.

None
algorithm str

Model algorithm.

None
parameters dict

Model parameters.

None
**kwargs dict

Additional model specification parameters.

{}

Returns:

Type Description
ModelModel

Created model entity with uploaded files.

Examples:

Upload a local model directory:

import digitalhub as dh

model = dh.log_model(
    project="my-project",
    name="image-classifier",
    source="./models/image-classifier",
    framework="pytorch",
    algorithm="resnet18",
)

Register

register_model

Register a model entity for an existing source.

Parameters:

Name Type Description Default
project str

Project name.

required
source SourcesOrListOfSources

Path or URI of the existing model.

required
name str

Entity name. If omitted, it is inferred from source.

None
uuid str

Entity identifier.

None
version str

Entity version.

None
description str

Human-readable entity description.

None
labels list[str]

Entity labels.

None
embedded bool

Whether to embed the entity specification in the project specification.

False
extensions list[dict]

Entity extensions.

None
framework str

Model framework.

None
algorithm str

Model algorithm.

None
parameters dict

Model parameters.

None
**kwargs dict

Additional model specification parameters.

{}

Returns:

Type Description
ModelModel

Registered model entity.

Examples:

Register a model that already exists in remote storage:

import digitalhub as dh

model = dh.register_model(
    project="my-project",
    name="registered-image-classifier",
    source="s3://my-bucket/models/image-classifier",
    framework="pytorch",
    algorithm="resnet18",
)

New

new_model

Create a new model entity in the backend.

Parameters:

Name Type Description Default
project str

Project name.

required
name str

Entity name.

required
kind str

Entity kind.

required
uuid str

Entity identifier.

None
version str

Entity version.

None
description str

Human-readable entity description.

None
labels list[str]

Entity labels.

None
embedded bool

Whether to embed the entity specification in the project specification.

False
path str

Entity path on the local file system or remote storage. It is also the destination path for uploads.

None
extensions list[dict]

Entity extensions.

None
**kwargs dict

Additional entity specification parameters.

{}

Returns:

Type Description
Model

Created model entity.

import digitalhub as dh

model = dh.new_model(
    project="my-project",
    name="image-classifier",
    kind="model",
    path="s3://my-bucket/models/image-classifier",
    framework="pytorch",
    algorithm="resnet18",
)

Retrieve and manage

Use the shared Model management reference to retrieve, update, or delete a Model.