Skip to content

CRUD

create_project(**kwargs)

Create a new project.

Parameters:

Name Type Description Default
**kwargs dict

Keyword arguments.

{}

Returns:

Type Description
Project

A Project instance.

Source code in digitalhub_core/entities/projects/crud.py
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
def create_project(**kwargs) -> Project:
    """
    Create a new project.

    Parameters
    ----------
    **kwargs : dict
        Keyword arguments.

    Returns
    -------
    Project
        A Project instance.
    """
    return project_from_parameters(**kwargs)

create_project_from_dict(obj)

Create a new Project instance from a dictionary.

Parameters:

Name Type Description Default
obj dict

Dictionary to create object from.

required

Returns:

Type Description
Project

Project object.

Source code in digitalhub_core/entities/projects/crud.py
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
def create_project_from_dict(obj: dict) -> Project:
    """
    Create a new Project instance from a dictionary.

    Parameters
    ----------
    obj : dict
        Dictionary to create object from.

    Returns
    -------
    Project
        Project object.
    """
    return project_from_dict(obj)

delete_project(name, cascade=True, clean_context=True, local=False, **kwargs)

Delete a 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. If a context is deleted, all its objects are unreacheable.

True
local bool

Flag to determine if backend is local.

False
**kwargs dict

Parameters to pass to the API call.

{}

Returns:

Type Description
dict

Response from backend.

Source code in digitalhub_core/entities/projects/crud.py
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
def delete_project(
    name: str,
    cascade: bool = True,
    clean_context: bool = True,
    local: bool = False,
    **kwargs,
) -> list[dict]:
    """
    Delete a project.

    Parameters
    ----------
    name : str
        Project name.
    cascade : bool
        Flag to determine if delete is cascading.
    clean_context : bool
        Flag to determine if context will be deleted. If a context is deleted,
        all its objects are unreacheable.
    local : bool
        Flag to determine if backend is local.
    **kwargs : dict
        Parameters to pass to the API call.

    Returns
    -------
    dict
        Response from backend.
    """
    client = get_client(local)
    obj = delete_entity_api_base(client, ENTITY_TYPE, name, cascade=cascade, **kwargs)
    if clean_context:
        delete_context(name)
    return obj

get_or_create_project(name, local=False, config=None, context=None, setup_kwargs=None, **kwargs)

Get or create a project.

Parameters:

Name Type Description Default
name str

Project name.

required
local bool

Flag to determine if backend is local.

False
config dict

DHCore env configuration.

None
context str

Folder where the project will saves its context locally.

None
setup_kwargs dict

Setup keyword arguments.

None
**kwargs dict

Keyword arguments.

{}

Returns:

Type Description
Project

A Project instance.

Source code in digitalhub_core/entities/projects/crud.py
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
def get_or_create_project(
    name: str,
    local: bool = False,
    config: dict | None = None,
    context: str | None = None,
    setup_kwargs: dict | None = None,
    **kwargs,
) -> Project:
    """
    Get or create a project.

    Parameters
    ----------
    name : str
        Project name.
    local : bool
        Flag to determine if backend is local.
    config : dict
        DHCore env configuration.
    context : str
        Folder where the project will saves its context locally.
    setup_kwargs : dict
        Setup keyword arguments.
    **kwargs : dict
        Keyword arguments.

    Returns
    -------
    Project
        A Project instance.
    """
    try:
        return get_project(
            name,
            local=local,
            config=config,
            setup_kwargs=setup_kwargs,
            **kwargs,
        )
    except BackendError:
        return new_project(
            name,
            local=local,
            config=config,
            setup_kwargs=setup_kwargs,
            context=context,
            **kwargs,
        )

get_project(name, local=False, config=None, setup_kwargs=None, **kwargs)

Retrieves project details from backend.

Parameters:

Name Type Description Default
name str

The Project name.

required
local bool

Flag to determine if backend is local.

False
config dict

DHCore env configuration.

None
setup_kwargs dict

Setup keyword arguments.

None
**kwargs dict

Parameters to pass to the API call.

{}

Returns:

Type Description
Project

Object instance.

Source code in digitalhub_core/entities/projects/crud.py
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
def get_project(
    name: str,
    local: bool = False,
    config: dict | None = None,
    setup_kwargs: dict | None = None,
    **kwargs,
) -> Project:
    """
    Retrieves project details from backend.

    Parameters
    ----------
    name : str
        The Project name.
    local : bool
        Flag to determine if backend is local.
    config : dict
        DHCore env configuration.
    setup_kwargs : dict
        Setup keyword arguments.
    **kwargs : dict
        Parameters to pass to the API call.

    Returns
    -------
    Project
        Object instance.
    """
    build_client(local, config)
    client = get_client(local)
    obj = read_entity_api_base(client, ENTITY_TYPE, name, **kwargs)
    obj["local"] = local
    project = create_project_from_dict(obj)
    return _setup_project(project, setup_kwargs)

import_project(file, local=False, config=None, setup_kwargs=None)

Import an Project object from a file using the specified file path.

Parameters:

Name Type Description Default
file str

Path to the file.

required
local bool

Flag to determine if backend is local.

False
config dict

DHCore env configuration.

None

Returns:

Type Description
Project

Object instance.

Source code in digitalhub_core/entities/projects/crud.py
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
def import_project(
    file: str,
    local: bool = False,
    config: dict | None = None,
    setup_kwargs: dict | None = None,
) -> Project:
    """
    Import an Project object from a file using the specified file path.

    Parameters
    ----------
    file : str
        Path to the file.
    local : bool
        Flag to determine if backend is local.
    config : dict
        DHCore env configuration.

    Returns
    -------
    Project
        Object instance.
    """
    build_client(local, config)
    obj: dict = read_yaml(file)
    obj["local"] = local
    project = create_project_from_dict(obj)
    return _setup_project(project, setup_kwargs)

load_project(name=None, filename=None, local=False, config=None, setup_kwargs=None, **kwargs)

Load project and context from backend or file.

Parameters:

Name Type Description Default
name str

Project name.

None
local bool

Flag to determine if backend is local.

False
config dict

DHCore env configuration.

None
setup_kwargs dict

Setup keyword arguments.

None
**kwargs dict

Keyword arguments.

{}

Returns:

Type Description
Project

A Project instance with setted context.

Source code in digitalhub_core/entities/projects/crud.py
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
def load_project(
    name: str | None = None,
    filename: str | None = None,
    local: bool = False,
    config: dict | None = None,
    setup_kwargs: dict | None = None,
    **kwargs,
) -> Project:
    """
    Load project and context from backend or file.

    Parameters
    ----------
    name : str
        Project name.
    local : bool
        Flag to determine if backend is local.
    config : dict
        DHCore env configuration.
    setup_kwargs : dict
        Setup keyword arguments.
    **kwargs : dict
        Keyword arguments.

    Returns
    -------
    Project
        A Project instance with setted context.
    """
    if name is not None:
        return get_project(name=name, local=local, config=config, setup_kwargs=setup_kwargs, **kwargs)
    if filename is not None:
        return import_project(filename, local=local, config=config, setup_kwargs=setup_kwargs)
    raise EntityError("Either name or filename must be provided.")

new_project(name, description=None, git_source=None, labels=None, local=False, config=None, context=None, setup_kwargs=None, **kwargs)

Create project.

Parameters:

Name Type Description Default
name str

Object name.

required
description str

Description of the object (human readable).

None
git_source str

Remote git source for object.

None
labels list[str]

List of labels.

None
local bool

Flag to determine if object will be exported to backend.

False
config dict

DHCore env configuration.

None
context str

The context of the project.

None
setup_kwargs dict

Setup keyword arguments.

None
**kwargs dict

Keyword arguments.

{}

Returns:

Type Description
Project

Project object.

Source code in digitalhub_core/entities/projects/crud.py
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
def new_project(
    name: str,
    description: str | None = None,
    git_source: str | None = None,
    labels: list[str] | None = None,
    local: bool = False,
    config: dict | None = None,
    context: str | None = None,
    setup_kwargs: dict | None = None,
    **kwargs,
) -> Project:
    """
    Create project.

    Parameters
    ----------
    name : str
        Object name.
    description : str
        Description of the object (human readable).
    git_source : str
        Remote git source for object.
    labels : list[str]
        List of labels.
    local : bool
        Flag to determine if object will be exported to backend.
    config : dict
        DHCore env configuration.
    context : str
        The context of the project.
    setup_kwargs : dict
        Setup keyword arguments.
    **kwargs : dict
        Keyword arguments.

    Returns
    -------
    Project
        Project object.
    """
    build_client(local, config)
    obj = create_project(
        name=name,
        kind="project",
        description=description,
        git_source=git_source,
        labels=labels,
        local=local,
        context=context,
        **kwargs,
    )
    obj.save()
    return _setup_project(obj, setup_kwargs)

update_project(entity, local=False, **kwargs)

Update object in backend.

Parameters:

Name Type Description Default
entity Project

The object to update.

required
local bool

Flag to determine if backend is local.

False
**kwargs dict

Parameters to pass to the API call.

{}

Returns:

Type Description
Project

Object instance.

Source code in digitalhub_core/entities/projects/crud.py
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
def update_project(entity: Project, local: bool = False, **kwargs) -> Project:
    """
    Update object in backend.

    Parameters
    ----------
    entity : Project
        The object to update.
    local : bool
        Flag to determine if backend is local.
    **kwargs : dict
        Parameters to pass to the API call.

    Returns
    -------
    Project
        Object instance.
    """
    client = get_client(local)
    obj = update_entity_api_base(client, ENTITY_TYPE, entity.name, entity.to_dict(), **kwargs)
    return create_project_from_dict(obj)

create_project(**kwargs)

Create a new project.

Parameters:

Name Type Description Default
**kwargs dict

Keyword arguments.

{}

Returns:

Type Description
ProjectData

A Project instance.

Source code in digitalhub_data/entities/projects/crud.py
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
def create_project(**kwargs) -> Project:
    """
    Create a new project.

    Parameters
    ----------
    **kwargs : dict
        Keyword arguments.

    Returns
    -------
    Project
        A Project instance.
    """
    return project_from_parameters(**kwargs)

create_project_from_dict(obj)

Create a new Project instance from a dictionary.

Parameters:

Name Type Description Default
obj dict

Dictionary to create object from.

required

Returns:

Type Description
ProjectData

Project object.

Source code in digitalhub_data/entities/projects/crud.py
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
def create_project_from_dict(obj: dict) -> Project:
    """
    Create a new Project instance from a dictionary.

    Parameters
    ----------
    obj : dict
        Dictionary to create object from.

    Returns
    -------
    Project
        Project object.
    """
    return project_from_dict(obj)

get_or_create_project(name, local=False, config=None, context=None, setup_kwargs=None, **kwargs)

Get or create a project.

Parameters:

Name Type Description Default
name str

Project name.

required
local bool

Flag to determine if backend is local.

False
config dict

DHCore env configuration.

None
context str

Folder where the project will saves its context locally.

None
setup_kwargs dict

Setup keyword arguments.

None
**kwargs dict

Keyword arguments.

{}

Returns:

Type Description
ProjectData

A Project instance.

Source code in digitalhub_data/entities/projects/crud.py
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
def get_or_create_project(
    name: str,
    local: bool = False,
    config: dict | None = None,
    context: str | None = None,
    setup_kwargs: dict | None = None,
    **kwargs,
) -> Project:
    """
    Get or create a project.

    Parameters
    ----------
    name : str
        Project name.
    local : bool
        Flag to determine if backend is local.
    config : dict
        DHCore env configuration.
    context : str
        Folder where the project will saves its context locally.
    setup_kwargs : dict
        Setup keyword arguments.
    **kwargs : dict
        Keyword arguments.

    Returns
    -------
    Project
        A Project instance.
    """
    try:
        return get_project(
            name,
            local=local,
            config=config,
            setup_kwargs=setup_kwargs,
            **kwargs,
        )
    except BackendError:
        return new_project(
            name,
            local=local,
            config=config,
            setup_kwargs=setup_kwargs,
            context=context,
            **kwargs,
        )

get_project(name, local=False, config=None, setup_kwargs=None, **kwargs)

Retrieves project details from backend.

Parameters:

Name Type Description Default
name str

The Project name.

required
local bool

Flag to determine if backend is local.

False
config dict

DHCore env configuration.

None
setup_kwargs dict

Setup keyword arguments.

None
**kwargs dict

Parameters to pass to the API call.

{}

Returns:

Type Description
ProjectData

Object instance.

Source code in digitalhub_data/entities/projects/crud.py
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
def get_project(
    name: str,
    local: bool = False,
    config: dict | None = None,
    setup_kwargs: dict | None = None,
    **kwargs,
) -> Project:
    """
    Retrieves project details from backend.

    Parameters
    ----------
    name : str
        The Project name.
    local : bool
        Flag to determine if backend is local.
    config : dict
        DHCore env configuration.
    setup_kwargs : dict
        Setup keyword arguments.
    **kwargs : dict
        Parameters to pass to the API call.

    Returns
    -------
    Project
        Object instance.
    """
    build_client(local, config)
    client = get_client(local)
    obj = read_entity_api_base(client, ENTITY_TYPE, name, **kwargs)
    obj["local"] = local
    project = create_project_from_dict(obj)
    return _setup_project(project, setup_kwargs)

import_project(file, local=False, config=None, setup_kwargs=None)

Import an Project object from a file using the specified file path.

Parameters:

Name Type Description Default
file str

Path to the file.

required
local bool

Flag to determine if backend is local.

False
config dict

DHCore env configuration.

None

Returns:

Type Description
ProjectData

Object instance.

Source code in digitalhub_data/entities/projects/crud.py
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
def import_project(
    file: str,
    local: bool = False,
    config: dict | None = None,
    setup_kwargs: dict | None = None,
) -> Project:
    """
    Import an Project object from a file using the specified file path.

    Parameters
    ----------
    file : str
        Path to the file.
    local : bool
        Flag to determine if backend is local.
    config : dict
        DHCore env configuration.

    Returns
    -------
    Project
        Object instance.
    """
    build_client(local, config)
    obj: dict = read_yaml(file)
    obj["local"] = local
    project = create_project_from_dict(obj)
    return _setup_project(project, setup_kwargs)

load_project(name=None, filename=None, local=False, config=None, setup_kwargs=None, **kwargs)

Load project and context from backend or file.

Parameters:

Name Type Description Default
name str

Project name.

None
local bool

Flag to determine if backend is local.

False
config dict

DHCore env configuration.

None
setup_kwargs dict

Setup keyword arguments.

None
**kwargs dict

Keyword arguments.

{}

Returns:

Type Description
ProjectData

A Project instance with setted context.

Source code in digitalhub_data/entities/projects/crud.py
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
def load_project(
    name: str | None = None,
    filename: str | None = None,
    local: bool = False,
    config: dict | None = None,
    setup_kwargs: dict | None = None,
    **kwargs,
) -> Project:
    """
    Load project and context from backend or file.

    Parameters
    ----------
    name : str
        Project name.
    local : bool
        Flag to determine if backend is local.
    config : dict
        DHCore env configuration.
    setup_kwargs : dict
        Setup keyword arguments.
    **kwargs : dict
        Keyword arguments.

    Returns
    -------
    Project
        A Project instance with setted context.
    """
    if name is not None:
        return get_project(name=name, local=local, config=config, setup_kwargs=setup_kwargs, **kwargs)
    if filename is not None:
        return import_project(filename, local=local, config=config, setup_kwargs=setup_kwargs)
    raise EntityError("Either name or filename must be provided.")

new_project(name, description=None, git_source=None, labels=None, local=False, config=None, context=None, setup_kwargs=None, **kwargs)

Create project.

Parameters:

Name Type Description Default
name str

Object name.

required
description str

Description of the object (human readable).

None
git_source str

Remote git source for object.

None
labels list[str]

List of labels.

None
local bool

Flag to determine if object will be exported to backend.

False
config dict

DHCore env configuration.

None
context str

The context of the project.

None
setup_kwargs dict

Setup keyword arguments.

None
**kwargs dict

Keyword arguments.

{}

Returns:

Type Description
ProjectData

Project object.

Source code in digitalhub_data/entities/projects/crud.py
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
def new_project(
    name: str,
    description: str | None = None,
    git_source: str | None = None,
    labels: list[str] | None = None,
    local: bool = False,
    config: dict | None = None,
    context: str | None = None,
    setup_kwargs: dict | None = None,
    **kwargs,
) -> Project:
    """
    Create project.

    Parameters
    ----------
    name : str
        Object name.
    description : str
        Description of the object (human readable).
    git_source : str
        Remote git source for object.
    labels : list[str]
        List of labels.
    local : bool
        Flag to determine if object will be exported to backend.
    config : dict
        DHCore env configuration.
    context : str
        The context of the project.
    setup_kwargs : dict
        Setup keyword arguments.
    **kwargs : dict
        Keyword arguments.

    Returns
    -------
    Project
        Project object.
    """
    build_client(local, config)
    obj = create_project(
        name=name,
        kind="project",
        description=description,
        git_source=git_source,
        labels=labels,
        local=local,
        context=context,
        **kwargs,
    )
    obj.save()
    return _setup_project(obj, setup_kwargs)

create_project(**kwargs)

Create a new project.

Parameters:

Name Type Description Default
**kwargs dict

Keyword arguments.

{}

Returns:

Type Description
ProjectMl

A Project instance.

Source code in digitalhub_ml/entities/projects/crud.py
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
def create_project(**kwargs) -> Project:
    """
    Create a new project.

    Parameters
    ----------
    **kwargs : dict
        Keyword arguments.

    Returns
    -------
    Project
        A Project instance.
    """
    return project_from_parameters(**kwargs)

create_project_from_dict(obj)

Create a new Project instance from a dictionary.

Parameters:

Name Type Description Default
obj dict

Dictionary to create object from.

required

Returns:

Type Description
ProjectMl

Project object.

Source code in digitalhub_ml/entities/projects/crud.py
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
def create_project_from_dict(obj: dict) -> Project:
    """
    Create a new Project instance from a dictionary.

    Parameters
    ----------
    obj : dict
        Dictionary to create object from.

    Returns
    -------
    Project
        Project object.
    """
    return project_from_dict(obj)

get_or_create_project(name, local=False, config=None, context=None, setup_kwargs=None, **kwargs)

Get or create a project.

Parameters:

Name Type Description Default
name str

Project name.

required
local bool

Flag to determine if backend is local.

False
config dict

DHCore env configuration.

None
context str

Folder where the project will saves its context locally.

None
setup_kwargs dict

Setup keyword arguments.

None
**kwargs dict

Keyword arguments.

{}

Returns:

Type Description
ProjectMl

A Project instance.

Source code in digitalhub_ml/entities/projects/crud.py
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
def get_or_create_project(
    name: str,
    local: bool = False,
    config: dict | None = None,
    context: str | None = None,
    setup_kwargs: dict | None = None,
    **kwargs,
) -> Project:
    """
    Get or create a project.

    Parameters
    ----------
    name : str
        Project name.
    local : bool
        Flag to determine if backend is local.
    config : dict
        DHCore env configuration.
    context : str
        Folder where the project will saves its context locally.
    setup_kwargs : dict
        Setup keyword arguments.
    **kwargs : dict
        Keyword arguments.

    Returns
    -------
    Project
        A Project instance.
    """
    try:
        return get_project(
            name,
            local=local,
            config=config,
            setup_kwargs=setup_kwargs,
            **kwargs,
        )
    except BackendError:
        return new_project(
            name,
            local=local,
            config=config,
            setup_kwargs=setup_kwargs,
            context=context,
            **kwargs,
        )

get_project(name, local=False, config=None, setup_kwargs=None, **kwargs)

Retrieves project details from backend.

Parameters:

Name Type Description Default
name str

The Project name.

required
local bool

Flag to determine if backend is local.

False
config dict

DHCore env configuration.

None
setup_kwargs dict

Setup keyword arguments.

None
**kwargs dict

Parameters to pass to the API call.

{}

Returns:

Type Description
ProjectMl

Object instance.

Source code in digitalhub_ml/entities/projects/crud.py
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
def get_project(
    name: str,
    local: bool = False,
    config: dict | None = None,
    setup_kwargs: dict | None = None,
    **kwargs,
) -> Project:
    """
    Retrieves project details from backend.

    Parameters
    ----------
    name : str
        The Project name.
    local : bool
        Flag to determine if backend is local.
    config : dict
        DHCore env configuration.
    setup_kwargs : dict
        Setup keyword arguments.
    **kwargs : dict
        Parameters to pass to the API call.

    Returns
    -------
    Project
        Object instance.
    """
    build_client(local, config)
    client = get_client(local)
    obj = read_entity_api_base(client, ENTITY_TYPE, name, **kwargs)
    obj["local"] = local
    project = create_project_from_dict(obj)
    return _setup_project(project, setup_kwargs)

import_project(file, local=False, config=None, setup_kwargs=None)

Import an Project object from a file using the specified file path.

Parameters:

Name Type Description Default
file str

Path to the file.

required
local bool

Flag to determine if backend is local.

False
config dict

DHCore env configuration.

None

Returns:

Type Description
ProjectMl

Object instance.

Source code in digitalhub_ml/entities/projects/crud.py
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
def import_project(
    file: str,
    local: bool = False,
    config: dict | None = None,
    setup_kwargs: dict | None = None,
) -> Project:
    """
    Import an Project object from a file using the specified file path.

    Parameters
    ----------
    file : str
        Path to the file.
    local : bool
        Flag to determine if backend is local.
    config : dict
        DHCore env configuration.

    Returns
    -------
    Project
        Object instance.
    """
    build_client(local, config)
    obj: dict = read_yaml(file)
    obj["local"] = local
    project = create_project_from_dict(obj)
    return _setup_project(project, setup_kwargs)

load_project(name=None, filename=None, local=False, config=None, setup_kwargs=None, **kwargs)

Load project and context from backend or file.

Parameters:

Name Type Description Default
name str

Project name.

None
local bool

Flag to determine if backend is local.

False
config dict

DHCore env configuration.

None
setup_kwargs dict

Setup keyword arguments.

None
**kwargs dict

Keyword arguments.

{}

Returns:

Type Description
ProjectMl

A Project instance with setted context.

Source code in digitalhub_ml/entities/projects/crud.py
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
def load_project(
    name: str | None = None,
    filename: str | None = None,
    local: bool = False,
    config: dict | None = None,
    setup_kwargs: dict | None = None,
    **kwargs,
) -> Project:
    """
    Load project and context from backend or file.

    Parameters
    ----------
    name : str
        Project name.
    local : bool
        Flag to determine if backend is local.
    config : dict
        DHCore env configuration.
    setup_kwargs : dict
        Setup keyword arguments.
    **kwargs : dict
        Keyword arguments.

    Returns
    -------
    Project
        A Project instance with setted context.
    """
    if name is not None:
        return get_project(name=name, local=local, config=config, setup_kwargs=setup_kwargs, **kwargs)
    if filename is not None:
        return import_project(filename, local=local, config=config, setup_kwargs=setup_kwargs)
    raise EntityError("Either name or filename must be provided.")

new_project(name, description=None, git_source=None, labels=None, local=False, config=None, context=None, setup_kwargs=None, **kwargs)

Create project.

Parameters:

Name Type Description Default
name str

Object name.

required
description str

Description of the object (human readable).

None
git_source str

Remote git source for object.

None
labels list[str]

List of labels.

None
local bool

Flag to determine if object will be exported to backend.

False
config dict

DHCore env configuration.

None
context str

The context of the project.

None
setup_kwargs dict

Setup keyword arguments.

None
**kwargs dict

Keyword arguments.

{}

Returns:

Type Description
ProjectMl

Project object.

Source code in digitalhub_ml/entities/projects/crud.py
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
def new_project(
    name: str,
    description: str | None = None,
    git_source: str | None = None,
    labels: list[str] | None = None,
    local: bool = False,
    config: dict | None = None,
    context: str | None = None,
    setup_kwargs: dict | None = None,
    **kwargs,
) -> Project:
    """
    Create project.

    Parameters
    ----------
    name : str
        Object name.
    description : str
        Description of the object (human readable).
    git_source : str
        Remote git source for object.
    labels : list[str]
        List of labels.
    local : bool
        Flag to determine if object will be exported to backend.
    config : dict
        DHCore env configuration.
    context : str
        The context of the project.
    setup_kwargs : dict
        Setup keyword arguments.
    **kwargs : dict
        Keyword arguments.

    Returns
    -------
    Project
        Project object.
    """
    build_client(local, config)
    obj = create_project(
        name=name,
        kind="project",
        description=description,
        git_source=git_source,
        labels=labels,
        local=local,
        context=context,
        **kwargs,
    )
    obj.save()
    return _setup_project(obj, setup_kwargs)