Manage a model
The CRUD methods are used to read, update, and delete models. They can be called through the SDK or through the Project object. When managing models from a project, omit the project parameter and pass every other parameter as a keyword argument. For model creation functions, see the Create a model guide.
Read
Use the read methods to retrieve models from the backend or load them from a YAML descriptor.
get_model
Get a model entity from the backend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
identifier
|
str
|
Entity name or entity key ( |
required |
project
|
str
|
Project name. Required when |
None
|
entity_id
|
str
|
Entity identifier. If omitted, the latest version is returned. |
None
|
Returns:
| Type | Description |
|---|---|
Model
|
Retrieved model entity. |
get_model_versions
Get all versions of a model entity from the backend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
identifier
|
str
|
Entity name or entity key ( |
required |
project
|
str
|
Project name. Required when |
None
|
Returns:
| Type | Description |
|---|---|
list[Model]
|
All versions of the model entity. |
list_models
List model entities in a project.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project
|
str
|
Project name. |
required |
q
|
str
|
Query string used to filter entities. |
None
|
name
|
str
|
Entity name used to filter results. |
None
|
kind
|
str
|
Entity kind used to filter results. |
None
|
labels
|
list[str]
|
Labels used to filter results. |
None
|
user
|
str
|
User who created the entity. |
None
|
state
|
str
|
Entity state used to filter results. |
None
|
created
|
str
|
Creation date filter. |
None
|
updated
|
str
|
Update date filter. |
None
|
versions
|
str
|
Version filter. Defaults to the latest version. |
None
|
Returns:
| Type | Description |
|---|---|
list[Model]
|
Model entities matching the filters. |
import_model
Import a model entity from a YAML file or entity key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file
|
str
|
Path to a YAML file containing the entity descriptor. Provide either
|
None
|
key
|
str
|
Entity key ( |
None
|
reset_id
|
bool
|
Whether to generate a new entity identifier instead of preserving the identifier from the imported entity. |
False
|
context
|
str
|
Project name used for context resolution. If omitted, the project from the entity descriptor is used. |
None
|
Returns:
| Type | Description |
|---|---|
Model
|
Imported model entity. |
Update
Update a model after changing its mutable metadata.
update_model
Update a model entity in the backend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity
|
Model
|
Entity to update. The entity specification is immutable. |
required |
Returns:
| Type | Description |
|---|---|
Model
|
Updated model entity. |
Delete
Delete one model version or all versions of a model.
delete_model
Delete one or more versions of a model entity from the backend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
identifier
|
str
|
Entity name or entity key ( |
required |
project
|
str
|
Project name. Required when |
None
|
entity_id
|
str
|
Identifier of the version to delete. Required when
|
None
|
delete_all_versions
|
bool
|
Whether to delete all versions of the named entity. When False, only one version is deleted. |
False
|
cascade
|
bool
|
Whether to request cascade deletion from the backend. |
True
|
Returns:
| Type | Description |
|---|---|
dict
|
Response data from the backend. |