CRUD
The CRUD methods are used to create, read, update and delete projects.
Example:
A project entity can be managed with the following methods.
Create:
Read:
Read or create:
Update:
Delete:
For project configuration options, please refer to the Config section, and the Setup section.
Create
You can create a project with the new_project() or with log_project() method.
New
This function create a new entity and saves it into the backend.
new_project
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Object name. |
required |
description
|
str
|
Description of the object (human readable). |
None
|
labels
|
list[str]
|
List of labels. |
None
|
config
|
dict
|
DHCore environment configuration. |
None
|
source
|
str
|
The context local folder of the project. |
None
|
setup_kwargs
|
dict
|
Setup keyword arguments passed to setup_project() function. |
None
|
Returns:
| Type | Description |
|---|---|
Project
|
Object instance. |
Examples:
Read
To read projects you can use the get_project(), import_project() or load_project().
Get
This function searches for a single project into the backend.
Import
This function load the project from a local yaml file descriptor.
import_project
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file
|
str
|
Path to YAML file. |
required |
setup_kwargs
|
dict
|
Setup keyword arguments passed to setup_project() function. |
None
|
reset_id
|
bool
|
Flag to determine if the ID of project entities should be reset. |
False
|
Returns:
| Type | Description |
|---|---|
Project
|
Object instance. |
Examples:
Load
This function returns a projects from the backend or from a local file according to the parameter passed to the function. If the parameter is name, the function will try to load the project from the backend. If the parameter is file, the function will try to load the project from the local file.
Read or create
You can read or create a project with the get_or_create_project() method.
get_or_create_project
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Project name. |
required |
config
|
dict
|
DHCore environment configuration. |
None
|
context
|
str
|
Folder where the project will saves its context locally. |
None
|
setup_kwargs
|
dict
|
Setup keyword arguments passed to setup_project() function. |
None
|
**kwargs
|
dict
|
Keyword arguments. |
required |
Returns:
| Type | Description |
|---|---|
Project
|
Object instance. |
Update
To update a project you can use the update_project() method.
Delete
To delete a project you can use the delete_project() method.
delete_project
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Project name. |
required |
cascade
|
bool
|
Flag to determine if delete is cascading. |
True
|
clean_context
|
bool
|
Flag to determine if context will be deleted. |
True
|
Returns:
| Type | Description |
|---|---|
dict
|
Response from backend. |
Examples: