Manage workflows
The methods below retrieve, import, update, or delete workflows. They can be called directly from the SDK or through a Project object. When using a Project object, omit the project parameter and pass the other parameters as keyword arguments.
Read
Use the read methods to retrieve workflows from the backend or import them from a YAML descriptor.
get_workflow
Get a workflow 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 |
|---|---|
Workflow
|
Retrieved workflow entity. |
get_workflow_versions
Get all versions of a workflow 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[Workflow]
|
All versions of the workflow entity. |
Examples:
Get all workflow versions by name and project:
Get all workflow versions by key:
list_workflows
List workflow 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[Workflow]
|
Workflow entities matching the filters. |
import_workflow
Import a workflow 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 |
|---|---|
Workflow
|
Imported workflow entity. |
Update
Update a workflow after changing its mutable metadata.
update_workflow
Update a workflow entity in the backend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity
|
Workflow
|
Entity to update. The entity specification is immutable. |
required |
Returns:
| Type | Description |
|---|---|
Workflow
|
Updated workflow entity. |
Delete
Delete one workflow version or all versions of a workflow.
delete_workflow
Delete one or more versions of a workflow 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. |
Examples:
Delete one workflow version by key:
import digitalhub as dh
dh.delete_workflow(
"store://my-project/workflow/hera/my-workflow:123e4567-e89b-42d3-a456-426614174000",
)
Delete one workflow version by name and project:
dh.delete_workflow(
"my-workflow",
project="my-project",
entity_id="123e4567-e89b-42d3-a456-426614174000",
)
Delete all workflow versions by name and project: