CRUD
The CRUD methods are used to create, read, update and delete runs. The syntax is the same for all CRUD methods.
Example:
import digitalhub as dh
# Use CRUD method from SDK
run = dh.new_run(project="my-project",
kind="python+run",
task="task-string")
A run
entity can be managed with the following methods.
Create:
Read:
Update:
Delete:
Create
You can create a run with the new_run()
.
The kwargs
parameters are determined by the kind of the object, and are described in the kinds section.
New
This run create a new entity and saves it into the backend.
new_run
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project
|
str
|
Project name. |
required |
kind
|
str
|
Kind the object. |
required |
uuid
|
str
|
ID of the object. |
None
|
labels
|
list[str]
|
List of labels. |
None
|
task
|
str
|
Name of the task associated with the run. |
None
|
local_execution
|
bool
|
Flag to determine if object has local execution. |
False
|
**kwargs
|
dict
|
Spec keyword arguments. |
{}
|
Returns:
Type | Description |
---|---|
Run
|
Object instance. |
Examples:
Read
To read runs you can use the get_run()
, list_runs()
or import_run()
runs.
Get
This run searches for a single run into the backend.
If you want to collect a run from the backend using get_run()
, you have two options:
- The first one is to use the
key
parameter which has the patternstore://<project-name>/<entity-type>/<entity-kind>/<entity-id>
. - The second one is to use the entity id as
identifier
, the project name asproject
.
get_run
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier
|
str
|
Entity key (store://...) or entity ID. |
required |
project
|
str
|
Project name. |
None
|
**kwargs
|
dict
|
Parameters to pass to the API call. |
{}
|
Returns:
Type | Description |
---|---|
Run
|
Object instance. |
Examples:
Using entity key:
Using entity ID:
List
This run returns all the latest runs from the backend related to a project.
Import
This run load the run from a local yaml file descriptor.
import_run
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file
|
str
|
Path to YAML file. |
required |
Returns:
Type | Description |
---|---|
Run
|
Object instance. |
Update
To update a run you can use the update_run()
method.
Delete
To delete a run you can use the delete_run()
method.
delete_run
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier
|
str
|
Entity key (store://...) or entity ID. |
required |
project
|
str
|
Project name. |
None
|
**kwargs
|
dict
|
Parameters to pass to the API call. |
{}
|
Returns:
Type | Description |
---|---|
dict
|
Response from backend. |
Examples: