CRUD
delete_model(identifier, project=None, entity_id=None, delete_all_versions=False, **kwargs)
Delete object from backend.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier |
str
|
Entity key (store://...) or entity name. |
required |
project |
str
|
Project name. |
None
|
entity_id |
str
|
Entity ID. |
None
|
delete_all_versions |
bool
|
Delete all versions of the named entity. If True, use entity name instead of entity key as identifier. |
False
|
**kwargs |
dict
|
Parameters to pass to the API call. |
{}
|
Returns:
Type | Description |
---|---|
dict
|
Response from backend. |
Examples:
If delete_all_versions is False:
Otherwise:
Source code in digitalhub_ml/entities/model/crud.py
get_model(identifier, project=None, entity_id=None, **kwargs)
Get object from backend.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier |
str
|
Entity key (store://...) or entity name. |
required |
project |
str
|
Project name. |
None
|
entity_id |
str
|
Entity ID. |
None
|
**kwargs |
dict
|
Parameters to pass to the API call. |
{}
|
Returns:
Type | Description |
---|---|
Model
|
Object instance. |
Examples:
Using entity key:
Using entity name:
Source code in digitalhub_ml/entities/model/crud.py
get_model_versions(identifier, project=None, **kwargs)
Get object versions from backend.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier |
str
|
Entity key (store://...) or entity name. |
required |
project |
str
|
Project name. |
None
|
**kwargs |
dict
|
Parameters to pass to the API call. |
{}
|
Returns:
Type | Description |
---|---|
list[Model]
|
List of object instances. |
Examples:
Using entity key:
Using entity name:
Source code in digitalhub_ml/entities/model/crud.py
import_model(file)
Import object from a YAML file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file |
str
|
Path to YAML file. |
required |
Returns:
Type | Description |
---|---|
Model
|
Object instance. |
Examples:
Source code in digitalhub_ml/entities/model/crud.py
list_models(project, **kwargs)
List all latest version objects from backend.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project |
str
|
Project name. |
required |
**kwargs |
dict
|
Parameters to pass to the API call. |
{}
|
Returns:
Type | Description |
---|---|
list[Model]
|
List of object instances. |
Examples:
Source code in digitalhub_ml/entities/model/crud.py
log_model(project, name, kind, source, path=None, **kwargs)
Create and upload an object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project |
str
|
Project name. |
required |
name |
str
|
Object name. |
required |
kind |
str
|
Kind the object. |
required |
source |
str
|
Model location on local path. |
required |
path |
str
|
Destination path of the model. If not provided, it's generated. |
None
|
**kwargs |
dict
|
New model spec parameters. |
{}
|
Returns:
Type | Description |
---|---|
Model
|
Object instance. |
Examples:
>>> obj = log_model(project="my-project",
>>> name="my-model",
>>> kind="model",
>>> source="./local-path")
Source code in digitalhub_ml/entities/model/crud.py
new_model(project, name, kind, uuid=None, description=None, labels=None, embedded=True, path=None, **kwargs)
Create a new object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project |
str
|
Project name. |
required |
name |
str
|
Object name. |
required |
kind |
str
|
Kind the object. |
required |
uuid |
str
|
ID of the object (UUID4, e.g. 40f25c4b-d26b-4221-b048-9527aff291e2). |
None
|
description |
str
|
Description of the object (human readable). |
None
|
labels |
list[str]
|
List of labels. |
None
|
embedded |
bool
|
Flag to determine if object spec must be embedded in project spec. |
True
|
path |
str
|
Object path on local file system or remote storage. It is also the destination path of upload() method. |
None
|
**kwargs |
dict
|
Spec keyword arguments. |
{}
|
Returns:
Type | Description |
---|---|
Model
|
Object instance. |
Examples:
>>> obj = new_model(project="my-project",
>>> name="my-model",
>>> kind="model",
>>> path="s3://my-bucket/my-key")