Skip to content

Manage projects

The methods below retrieve, import, update, or delete projects. For project creation, see Create a project.

Read

Use the read methods to retrieve projects from the backend or load them from a YAML descriptor.

get_project

Get a project entity from the backend.

Parameters:

Name Type Description Default
name str

Project name.

required
setup_kwargs dict

Keyword arguments passed to setup_project.

None

Returns:

Type Description
Project

Retrieved project entity.

Examples:

Retrieve a project by name:

import digitalhub as dh

project = dh.get_project("my-project")
import_project

Import a project entity from a YAML file.

Parameters:

Name Type Description Default
file str

Path to a YAML file containing the project descriptor.

required
setup_kwargs dict

Keyword arguments passed to setup_project.

None
reset_id bool

Whether to generate a new entity identifier instead of preserving the identifier from the imported project.

False

Returns:

Type Description
Project

Imported project entity.

Examples:

Import a project from a YAML descriptor:

import digitalhub as dh

project = dh.import_project("my-project.yaml")
load_project

Load a project entity from a YAML file.

Parameters:

Name Type Description Default
file str

Path to a YAML file containing the project descriptor.

required
setup_kwargs dict

Keyword arguments passed to setup_project.

None

Returns:

Type Description
Project

Loaded project entity.

Examples:

Load a project descriptor from a YAML file:

import digitalhub as dh

project = dh.load_project("my-project.yaml")

Update

Update a project after changing its mutable metadata.

update_project

Update a project entity.

Parameters:

Name Type Description Default
entity Project

Entity to update. The entity specification is immutable.

required

Returns:

Type Description
Project

Updated project entity.

Examples:

Update a project after changing its mutable metadata:

import digitalhub as dh

project = dh.get_project("my-project")
project.set_description("Updated project")
project = dh.update_project(project)

Delete

Delete a project from the backend.

delete_project

Delete a project entity.

Parameters:

Name Type Description Default
name str

Project name.

required
cascade bool

Whether to request cascade deletion from the backend.

True
clean_context bool

Whether to delete the project's local context.

True

Returns:

Type Description
dict

Response data from the backend.

Examples:

Delete a project:

import digitalhub as dh

dh.delete_project("my-project")