digitalhub 0.13.3__py3-none-any.whl → 0.14.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of digitalhub might be problematic. Click here for more details.

Files changed (116) hide show
  1. digitalhub/__init__.py +3 -8
  2. digitalhub/context/api.py +1 -5
  3. digitalhub/context/builder.py +1 -5
  4. digitalhub/context/context.py +15 -9
  5. digitalhub/entities/_base/_base/entity.py +0 -15
  6. digitalhub/entities/_base/context/entity.py +1 -1
  7. digitalhub/entities/_base/entity/builder.py +5 -5
  8. digitalhub/entities/_base/entity/entity.py +0 -8
  9. digitalhub/entities/_base/executable/entity.py +169 -79
  10. digitalhub/entities/_base/material/entity.py +6 -22
  11. digitalhub/entities/_base/material/utils.py +1 -4
  12. digitalhub/entities/_base/runtime_entity/builder.py +53 -18
  13. digitalhub/entities/_base/unversioned/entity.py +1 -1
  14. digitalhub/entities/_base/versioned/entity.py +1 -1
  15. digitalhub/entities/_commons/enums.py +1 -31
  16. digitalhub/entities/_commons/utils.py +83 -21
  17. digitalhub/entities/_constructors/_resources.py +151 -0
  18. digitalhub/entities/{_base/entity/_constructors → _constructors}/name.py +18 -0
  19. digitalhub/entities/_processors/base/__init__.py +3 -0
  20. digitalhub/entities/_processors/{base.py → base/crud.py} +14 -226
  21. digitalhub/entities/_processors/base/import_export.py +123 -0
  22. digitalhub/entities/_processors/base/processor.py +302 -0
  23. digitalhub/entities/_processors/base/special_ops.py +108 -0
  24. digitalhub/entities/_processors/context/__init__.py +3 -0
  25. digitalhub/entities/_processors/context/crud.py +652 -0
  26. digitalhub/entities/_processors/context/import_export.py +242 -0
  27. digitalhub/entities/_processors/context/material.py +123 -0
  28. digitalhub/entities/_processors/context/processor.py +400 -0
  29. digitalhub/entities/_processors/context/special_ops.py +476 -0
  30. digitalhub/entities/_processors/processors.py +12 -0
  31. digitalhub/entities/_processors/utils.py +12 -11
  32. digitalhub/entities/artifact/crud.py +58 -22
  33. digitalhub/entities/artifact/utils.py +3 -3
  34. digitalhub/entities/dataitem/crud.py +63 -20
  35. digitalhub/entities/dataitem/table/entity.py +24 -22
  36. digitalhub/entities/dataitem/utils.py +15 -15
  37. digitalhub/entities/function/_base/entity.py +3 -3
  38. digitalhub/entities/function/crud.py +55 -24
  39. digitalhub/entities/model/_base/entity.py +62 -20
  40. digitalhub/entities/model/crud.py +58 -22
  41. digitalhub/entities/model/utils.py +3 -3
  42. digitalhub/entities/project/_base/entity.py +321 -152
  43. digitalhub/entities/project/crud.py +15 -23
  44. digitalhub/entities/run/_base/builder.py +0 -4
  45. digitalhub/entities/run/_base/entity.py +70 -63
  46. digitalhub/entities/run/crud.py +79 -26
  47. digitalhub/entities/secret/_base/entity.py +1 -5
  48. digitalhub/entities/secret/crud.py +29 -26
  49. digitalhub/entities/task/_base/builder.py +0 -4
  50. digitalhub/entities/task/_base/entity.py +5 -5
  51. digitalhub/entities/task/_base/models.py +13 -16
  52. digitalhub/entities/task/crud.py +61 -29
  53. digitalhub/entities/trigger/_base/entity.py +1 -5
  54. digitalhub/entities/trigger/crud.py +64 -24
  55. digitalhub/entities/workflow/_base/entity.py +3 -3
  56. digitalhub/entities/workflow/crud.py +55 -21
  57. digitalhub/factory/entity.py +283 -0
  58. digitalhub/factory/enums.py +18 -0
  59. digitalhub/factory/registry.py +197 -0
  60. digitalhub/factory/runtime.py +44 -0
  61. digitalhub/factory/utils.py +3 -54
  62. digitalhub/runtimes/_base.py +2 -2
  63. digitalhub/stores/client/_base/enums.py +39 -0
  64. digitalhub/stores/client/_base/key_builder.py +2 -2
  65. digitalhub/stores/client/_base/params_builder.py +48 -0
  66. digitalhub/stores/client/api.py +6 -10
  67. digitalhub/stores/client/builder.py +4 -4
  68. digitalhub/stores/client/dhcore/api_builder.py +2 -1
  69. digitalhub/stores/client/dhcore/client.py +85 -429
  70. digitalhub/stores/client/dhcore/configurator.py +109 -328
  71. digitalhub/stores/client/dhcore/enums.py +0 -16
  72. digitalhub/stores/client/dhcore/error_parser.py +0 -4
  73. digitalhub/stores/client/dhcore/header_manager.py +61 -0
  74. digitalhub/stores/client/dhcore/http_handler.py +133 -0
  75. digitalhub/stores/client/dhcore/params_builder.py +147 -134
  76. digitalhub/stores/client/dhcore/response_processor.py +102 -0
  77. digitalhub/stores/client/dhcore/utils.py +6 -72
  78. digitalhub/stores/client/local/api_builder.py +1 -1
  79. digitalhub/stores/client/local/client.py +79 -47
  80. digitalhub/stores/client/local/params_builder.py +18 -41
  81. digitalhub/stores/credentials/api.py +0 -4
  82. digitalhub/stores/credentials/configurator.py +2 -28
  83. digitalhub/stores/credentials/enums.py +3 -0
  84. digitalhub/stores/credentials/handler.py +0 -12
  85. digitalhub/stores/credentials/ini_module.py +0 -22
  86. digitalhub/stores/credentials/store.py +0 -4
  87. digitalhub/stores/data/_base/store.py +0 -16
  88. digitalhub/stores/data/builder.py +1 -5
  89. digitalhub/stores/data/local/store.py +0 -103
  90. digitalhub/stores/data/remote/store.py +0 -4
  91. digitalhub/stores/data/s3/configurator.py +60 -14
  92. digitalhub/stores/data/s3/store.py +49 -16
  93. digitalhub/stores/data/sql/configurator.py +0 -8
  94. digitalhub/stores/data/sql/store.py +21 -10
  95. digitalhub/stores/readers/data/factory.py +0 -8
  96. digitalhub/stores/readers/data/pandas/reader.py +0 -16
  97. digitalhub/utils/file_utils.py +0 -17
  98. digitalhub/utils/generic_utils.py +0 -12
  99. digitalhub/utils/git_utils.py +0 -8
  100. digitalhub/utils/io_utils.py +0 -12
  101. digitalhub/utils/store_utils.py +44 -0
  102. {digitalhub-0.13.3.dist-info → digitalhub-0.14.0.dist-info}/METADATA +3 -2
  103. {digitalhub-0.13.3.dist-info → digitalhub-0.14.0.dist-info}/RECORD +111 -95
  104. digitalhub/entities/_processors/context.py +0 -1450
  105. digitalhub/entities/task/_base/utils.py +0 -22
  106. digitalhub/factory/factory.py +0 -381
  107. digitalhub/stores/client/dhcore/models.py +0 -40
  108. digitalhub/stores/data/s3/utils.py +0 -78
  109. /digitalhub/entities/{_base/entity/_constructors → _constructors}/__init__.py +0 -0
  110. /digitalhub/entities/{_base/entity/_constructors → _constructors}/metadata.py +0 -0
  111. /digitalhub/entities/{_base/entity/_constructors → _constructors}/spec.py +0 -0
  112. /digitalhub/entities/{_base/entity/_constructors → _constructors}/status.py +0 -0
  113. /digitalhub/entities/{_base/entity/_constructors → _constructors}/uuid.py +0 -0
  114. {digitalhub-0.13.3.dist-info → digitalhub-0.14.0.dist-info}/WHEEL +0 -0
  115. {digitalhub-0.13.3.dist-info → digitalhub-0.14.0.dist-info}/licenses/AUTHORS +0 -0
  116. {digitalhub-0.13.3.dist-info → digitalhub-0.14.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,1450 +0,0 @@
1
- # SPDX-FileCopyrightText: © 2025 DSLab - Fondazione Bruno Kessler
2
- #
3
- # SPDX-License-Identifier: Apache-2.0
4
-
5
- from __future__ import annotations
6
-
7
- import typing
8
- from typing import Any
9
-
10
- from digitalhub.entities._commons.enums import ApiCategories, BackendOperations, Relationship, State
11
- from digitalhub.entities._processors.utils import (
12
- get_context_from_identifier,
13
- get_context_from_project,
14
- parse_identifier,
15
- )
16
- from digitalhub.factory.factory import factory
17
- from digitalhub.utils.exceptions import EntityAlreadyExistsError, EntityError, EntityNotExistsError
18
- from digitalhub.utils.io_utils import read_yaml
19
- from digitalhub.utils.types import SourcesOrListOfSources
20
-
21
- if typing.TYPE_CHECKING:
22
- from digitalhub.context.context import Context
23
- from digitalhub.entities._base.context.entity import ContextEntity
24
- from digitalhub.entities._base.executable.entity import ExecutableEntity
25
- from digitalhub.entities._base.material.entity import MaterialEntity
26
- from digitalhub.entities._base.unversioned.entity import UnversionedEntity
27
-
28
-
29
- class ContextEntityOperationsProcessor:
30
- """
31
- Processor for context entity operations.
32
-
33
- This class handles CRUD operations and other entity management tasks
34
- for context-level entities (artifacts, functions, workflows, runs, etc.)
35
- within projects. It manages the full lifecycle of versioned and
36
- unversioned entities including creation, reading, updating, deletion,
37
- import/export, and specialized operations like file uploads and metrics.
38
- """
39
-
40
- ##############################
41
- # CRUD context entity
42
- ##############################
43
-
44
- def _create_context_entity(
45
- self,
46
- context: Context,
47
- entity_type: str,
48
- entity_dict: dict,
49
- ) -> dict:
50
- """
51
- Create a context entity in the backend.
52
-
53
- Builds the appropriate API endpoint and sends a create request
54
- to the backend for context-level entities within a project.
55
-
56
- Parameters
57
- ----------
58
- context : Context
59
- The project context instance.
60
- entity_type : str
61
- The type of entity to create (e.g., 'artifact', 'function').
62
- entity_dict : dict
63
- The entity data dictionary to create.
64
-
65
- Returns
66
- -------
67
- dict
68
- The created entity data returned from the backend.
69
- """
70
- api = context.client.build_api(
71
- ApiCategories.CONTEXT.value,
72
- BackendOperations.CREATE.value,
73
- project=context.name,
74
- entity_type=entity_type,
75
- )
76
- return context.client.create_object(api, entity_dict)
77
-
78
- def create_context_entity(
79
- self,
80
- _entity: ContextEntity | None = None,
81
- **kwargs,
82
- ) -> ContextEntity:
83
- """
84
- Create a context entity in the backend.
85
-
86
- Creates a new context entity either from an existing entity object
87
- or by building one from the provided parameters. Handles entity
88
- creation within a project context.
89
-
90
- Parameters
91
- ----------
92
- _entity : ContextEntity, optional
93
- An existing context entity object to create. If None,
94
- a new entity will be built from kwargs.
95
- **kwargs : dict
96
- Parameters for entity creation, including 'project' and
97
- entity-specific parameters.
98
-
99
- Returns
100
- -------
101
- ContextEntity
102
- The created context entity with backend data populated.
103
- """
104
- if _entity is not None:
105
- context = _entity._context()
106
- obj = _entity
107
- else:
108
- context = get_context_from_project(kwargs["project"])
109
- obj: ContextEntity = factory.build_entity_from_params(**kwargs)
110
- new_obj = self._create_context_entity(context, obj.ENTITY_TYPE, obj.to_dict())
111
- return factory.build_entity_from_dict(new_obj)
112
-
113
- def log_material_entity(
114
- self,
115
- **kwargs,
116
- ) -> MaterialEntity:
117
- """
118
- Create a material entity in the backend and upload associated files.
119
-
120
- Creates a new material entity (artifact, dataitem, or model) and
121
- handles file upload operations. Manages upload state transitions
122
- and error handling during the upload process.
123
-
124
- Parameters
125
- ----------
126
- **kwargs : dict
127
- Parameters for entity creation including:
128
- - 'source': file source(s) to upload
129
- - 'project': project name
130
- - other entity-specific parameters
131
-
132
- Returns
133
- -------
134
- MaterialEntity
135
- The created material entity with uploaded files.
136
-
137
- Raises
138
- ------
139
- EntityError
140
- If file upload fails during the process.
141
- """
142
- source: SourcesOrListOfSources = kwargs.pop("source")
143
- context = get_context_from_project(kwargs["project"])
144
- obj = factory.build_entity_from_params(**kwargs)
145
- if context.is_running:
146
- obj.add_relationship(Relationship.PRODUCEDBY.value, context.get_run_ctx())
147
-
148
- new_obj: MaterialEntity = self._create_context_entity(context, obj.ENTITY_TYPE, obj.to_dict())
149
- new_obj = factory.build_entity_from_dict(new_obj)
150
-
151
- new_obj.status.state = State.UPLOADING.value
152
- new_obj = self._update_material_entity(new_obj)
153
-
154
- # Handle file upload
155
- try:
156
- new_obj.upload(source)
157
- uploaded = True
158
- msg = None
159
- except Exception as e:
160
- uploaded = False
161
- msg = str(e.args)
162
-
163
- new_obj.status.message = msg
164
-
165
- # Update status after upload
166
- if uploaded:
167
- new_obj.status.state = State.READY.value
168
- new_obj = self._update_material_entity(new_obj)
169
- else:
170
- new_obj.status.state = State.ERROR.value
171
- new_obj = self._update_material_entity(new_obj)
172
- raise EntityError(msg)
173
-
174
- return new_obj
175
-
176
- def _read_context_entity(
177
- self,
178
- context: Context,
179
- identifier: str,
180
- entity_type: str | None = None,
181
- project: str | None = None,
182
- entity_id: str | None = None,
183
- **kwargs,
184
- ) -> dict:
185
- """
186
- Read a context entity from the backend.
187
-
188
- Retrieves entity data from the backend using either entity ID
189
- for direct access or entity name for latest version lookup.
190
- Handles both specific version reads and latest version queries.
191
-
192
- Parameters
193
- ----------
194
- context : Context
195
- The project context instance.
196
- identifier : str
197
- Entity key (store://...) or entity name identifier.
198
- entity_type : str, optional
199
- The type of entity to read.
200
- project : str, optional
201
- Project name (used for identifier parsing).
202
- entity_id : str, optional
203
- Specific entity ID to read.
204
- **kwargs : dict
205
- Additional parameters to pass to the API call.
206
-
207
- Returns
208
- -------
209
- dict
210
- The entity data retrieved from the backend.
211
- """
212
- project, entity_type, _, entity_name, entity_id = parse_identifier(
213
- identifier,
214
- project=project,
215
- entity_type=entity_type,
216
- entity_id=entity_id,
217
- )
218
-
219
- if entity_id is None:
220
- kwargs["entity_name"] = entity_name
221
- kwargs = context.client.build_parameters(
222
- ApiCategories.CONTEXT.value,
223
- BackendOperations.READ.value,
224
- **kwargs,
225
- )
226
-
227
- if entity_id is None:
228
- api = context.client.build_api(
229
- ApiCategories.CONTEXT.value,
230
- BackendOperations.LIST.value,
231
- project=context.name,
232
- entity_type=entity_type,
233
- )
234
- return context.client.list_first_object(api, **kwargs)
235
-
236
- api = context.client.build_api(
237
- ApiCategories.CONTEXT.value,
238
- BackendOperations.READ.value,
239
- project=context.name,
240
- entity_type=entity_type,
241
- entity_id=entity_id,
242
- )
243
- return context.client.read_object(api, **kwargs)
244
-
245
- def read_context_entity(
246
- self,
247
- identifier: str,
248
- entity_type: str | None = None,
249
- project: str | None = None,
250
- entity_id: str | None = None,
251
- **kwargs,
252
- ) -> ContextEntity:
253
- """
254
- Read a context entity from the backend.
255
-
256
- Retrieves entity data from the backend and constructs a context
257
- entity object. Handles post-processing for metrics and file info.
258
-
259
- Parameters
260
- ----------
261
- identifier : str
262
- Entity key (store://...) or entity name identifier.
263
- entity_type : str, optional
264
- The type of entity to read.
265
- project : str, optional
266
- Project name for context resolution.
267
- entity_id : str, optional
268
- Specific entity ID to read.
269
- **kwargs : dict
270
- Additional parameters to pass to the API call.
271
-
272
- Returns
273
- -------
274
- ContextEntity
275
- The context entity object populated with backend data.
276
- """
277
- context = get_context_from_identifier(identifier, project)
278
- obj = self._read_context_entity(
279
- context,
280
- identifier,
281
- entity_type=entity_type,
282
- project=project,
283
- entity_id=entity_id,
284
- **kwargs,
285
- )
286
- entity = factory.build_entity_from_dict(obj)
287
- return self._post_process_get(entity)
288
-
289
- def read_unversioned_entity(
290
- self,
291
- identifier: str,
292
- entity_type: str | None = None,
293
- project: str | None = None,
294
- entity_id: str | None = None,
295
- **kwargs,
296
- ) -> UnversionedEntity:
297
- """
298
- Read an unversioned entity from the backend.
299
-
300
- Retrieves unversioned entity data (runs, tasks) from the backend.
301
- Handles identifier parsing for entities that don't follow the
302
- standard versioned naming convention.
303
-
304
- Parameters
305
- ----------
306
- identifier : str
307
- Entity key (store://...) or entity ID.
308
- entity_type : str, optional
309
- The type of entity to read.
310
- project : str, optional
311
- Project name for context resolution.
312
- entity_id : str, optional
313
- Specific entity ID to read.
314
- **kwargs : dict
315
- Additional parameters to pass to the API call.
316
-
317
- Returns
318
- -------
319
- UnversionedEntity
320
- The unversioned entity object populated with backend data.
321
- """
322
- if not identifier.startswith("store://"):
323
- entity_id = identifier
324
- else:
325
- splt = identifier.split(":")
326
- if len(splt) == 3:
327
- identifier = f"{splt[0]}:{splt[1]}"
328
- return self.read_context_entity(
329
- identifier,
330
- entity_type=entity_type,
331
- project=project,
332
- entity_id=entity_id,
333
- **kwargs,
334
- )
335
-
336
- def import_context_entity(
337
- self,
338
- file: str,
339
- ) -> ContextEntity:
340
- """
341
- Import a context entity from a YAML file and create it in the backend.
342
-
343
- Reads entity configuration from a YAML file and creates a new
344
- context entity in the backend. Raises an error if the entity
345
- already exists.
346
-
347
- Parameters
348
- ----------
349
- file : str
350
- Path to the YAML file containing entity configuration.
351
-
352
- Returns
353
- -------
354
- ContextEntity
355
- The imported and created context entity.
356
-
357
- Raises
358
- ------
359
- EntityError
360
- If the entity already exists in the backend.
361
- """
362
- dict_obj: dict = read_yaml(file)
363
- dict_obj["status"] = {}
364
- context = get_context_from_project(dict_obj["project"])
365
- obj = factory.build_entity_from_dict(dict_obj)
366
- try:
367
- self._create_context_entity(context, obj.ENTITY_TYPE, obj.to_dict())
368
- except EntityAlreadyExistsError:
369
- raise EntityError(f"Entity {obj.name} already exists. If you want to update it, use load instead.")
370
- return obj
371
-
372
- def import_executable_entity(
373
- self,
374
- file: str,
375
- ) -> ExecutableEntity:
376
- """
377
- Import an executable entity from a YAML file and create it in the backend.
378
-
379
- Reads executable entity configuration from a YAML file and creates
380
- a new executable entity (function or workflow) in the backend.
381
- Also imports associated task definitions if present in the file.
382
-
383
- Parameters
384
- ----------
385
- file : str
386
- Path to the YAML file containing executable entity configuration.
387
- Can contain a single entity or a list with the executable and tasks.
388
-
389
- Returns
390
- -------
391
- ExecutableEntity
392
- The imported and created executable entity.
393
-
394
- Raises
395
- ------
396
- EntityError
397
- If the entity already exists in the backend.
398
- """
399
- dict_obj: dict | list[dict] = read_yaml(file)
400
- if isinstance(dict_obj, list):
401
- exec_dict = dict_obj[0]
402
- exec_dict["status"] = {}
403
- tsk_dicts = []
404
- for i in dict_obj[1:]:
405
- i["status"] = {}
406
- tsk_dicts.append(i)
407
- else:
408
- exec_dict = dict_obj
409
- tsk_dicts = []
410
-
411
- context = get_context_from_project(exec_dict["project"])
412
- obj: ExecutableEntity = factory.build_entity_from_dict(exec_dict)
413
- try:
414
- self._create_context_entity(context, obj.ENTITY_TYPE, obj.to_dict())
415
- except EntityAlreadyExistsError:
416
- raise EntityError(f"Entity {obj.name} already exists. If you want to update it, use load instead.")
417
-
418
- obj.import_tasks(tsk_dicts)
419
-
420
- return obj
421
-
422
- def load_context_entity(
423
- self,
424
- file: str,
425
- ) -> ContextEntity:
426
- """
427
- Load a context entity from a YAML file and update it in the backend.
428
-
429
- Reads entity configuration from a YAML file and updates an existing
430
- entity in the backend. If the entity doesn't exist, it creates a
431
- new one.
432
-
433
- Parameters
434
- ----------
435
- file : str
436
- Path to the YAML file containing entity configuration.
437
-
438
- Returns
439
- -------
440
- ContextEntity
441
- The loaded and updated context entity.
442
- """
443
- dict_obj: dict = read_yaml(file)
444
- context = get_context_from_project(dict_obj["project"])
445
- obj: ContextEntity = factory.build_entity_from_dict(dict_obj)
446
- try:
447
- self._update_context_entity(context, obj.ENTITY_TYPE, obj.id, obj.to_dict())
448
- except EntityNotExistsError:
449
- self._create_context_entity(context, obj.ENTITY_TYPE, obj.to_dict())
450
- return obj
451
-
452
- def load_executable_entity(
453
- self,
454
- file: str,
455
- ) -> ExecutableEntity:
456
- """
457
- Load an executable entity from a YAML file and update it in the backend.
458
-
459
- Reads executable entity configuration from a YAML file and updates
460
- an existing executable entity in the backend. If the entity doesn't
461
- exist, it creates a new one. Also handles task imports.
462
-
463
- Parameters
464
- ----------
465
- file : str
466
- Path to the YAML file containing executable entity configuration.
467
- Can contain a single entity or a list with the executable and tasks.
468
-
469
- Returns
470
- -------
471
- ExecutableEntity
472
- The loaded and updated executable entity.
473
- """
474
- dict_obj: dict | list[dict] = read_yaml(file)
475
- if isinstance(dict_obj, list):
476
- exec_dict = dict_obj[0]
477
- tsk_dicts = dict_obj[1:]
478
- else:
479
- exec_dict = dict_obj
480
- tsk_dicts = []
481
-
482
- context = get_context_from_project(exec_dict["project"])
483
- obj: ExecutableEntity = factory.build_entity_from_dict(exec_dict)
484
-
485
- try:
486
- self._update_context_entity(context, obj.ENTITY_TYPE, obj.id, obj.to_dict())
487
- except EntityNotExistsError:
488
- self._create_context_entity(context, obj.ENTITY_TYPE, obj.to_dict())
489
- obj.import_tasks(tsk_dicts)
490
- return obj
491
-
492
- def _read_context_entity_versions(
493
- self,
494
- context: Context,
495
- identifier: str,
496
- entity_type: str | None = None,
497
- project: str | None = None,
498
- **kwargs,
499
- ) -> list[dict]:
500
- """
501
- Read all versions of a context entity from the backend.
502
-
503
- Retrieves all available versions of a named entity from the
504
- backend using the entity name identifier.
505
-
506
- Parameters
507
- ----------
508
- context : Context
509
- The project context instance.
510
- identifier : str
511
- Entity key (store://...) or entity name identifier.
512
- entity_type : str, optional
513
- The type of entity to read versions for.
514
- project : str, optional
515
- Project name (used for identifier parsing).
516
- **kwargs : dict
517
- Additional parameters to pass to the API call.
518
-
519
- Returns
520
- -------
521
- list[dict]
522
- List of entity data dictionaries for all versions.
523
- """
524
- project, entity_type, _, entity_name, _ = parse_identifier(
525
- identifier,
526
- project=project,
527
- entity_type=entity_type,
528
- )
529
-
530
- kwargs = context.client.build_parameters(
531
- ApiCategories.CONTEXT.value,
532
- BackendOperations.READ_ALL_VERSIONS.value,
533
- entity_name=entity_name,
534
- **kwargs,
535
- )
536
-
537
- api = context.client.build_api(
538
- ApiCategories.CONTEXT.value,
539
- BackendOperations.LIST.value,
540
- project=context.name,
541
- entity_type=entity_type,
542
- )
543
- return context.client.list_objects(api, **kwargs)
544
-
545
- def read_context_entity_versions(
546
- self,
547
- identifier: str,
548
- entity_type: str | None = None,
549
- project: str | None = None,
550
- **kwargs,
551
- ) -> list[ContextEntity]:
552
- """
553
- Read all versions of a context entity from the backend.
554
-
555
- Retrieves all available versions of a named entity and constructs
556
- context entity objects for each version. Applies post-processing
557
- for metrics and file info.
558
-
559
- Parameters
560
- ----------
561
- identifier : str
562
- Entity key (store://...) or entity name identifier.
563
- entity_type : str, optional
564
- The type of entity to read versions for.
565
- project : str, optional
566
- Project name for context resolution.
567
- **kwargs : dict
568
- Additional parameters to pass to the API call.
569
-
570
- Returns
571
- -------
572
- list[ContextEntity]
573
- List of context entity objects for all versions.
574
- """
575
- context = get_context_from_identifier(identifier, project)
576
- objs = self._read_context_entity_versions(
577
- context,
578
- identifier,
579
- entity_type=entity_type,
580
- project=project,
581
- **kwargs,
582
- )
583
- objects = []
584
- for o in objs:
585
- entity: ContextEntity = factory.build_entity_from_dict(o)
586
- entity = self._post_process_get(entity)
587
- objects.append(entity)
588
- return objects
589
-
590
- def _list_context_entities(
591
- self,
592
- context: Context,
593
- entity_type: str,
594
- **kwargs,
595
- ) -> list[dict]:
596
- """
597
- List context entities from the backend.
598
-
599
- Retrieves a list of entities of a specific type from the backend
600
- within the project context.
601
-
602
- Parameters
603
- ----------
604
- context : Context
605
- The project context instance.
606
- entity_type : str
607
- The type of entities to list.
608
- **kwargs : dict
609
- Additional parameters to pass to the API call for filtering
610
- or pagination.
611
-
612
- Returns
613
- -------
614
- list[dict]
615
- List of entity data dictionaries from the backend.
616
- """
617
- api = context.client.build_api(
618
- ApiCategories.CONTEXT.value,
619
- BackendOperations.LIST.value,
620
- project=context.name,
621
- entity_type=entity_type,
622
- )
623
- return context.client.list_objects(api, **kwargs)
624
-
625
- def list_context_entities(
626
- self,
627
- project: str,
628
- entity_type: str,
629
- **kwargs,
630
- ) -> list[ContextEntity]:
631
- """
632
- List all latest version context entities from the backend.
633
-
634
- Retrieves a list of entities of a specific type from the backend
635
- and constructs context entity objects. Only returns the latest
636
- version of each entity. Applies post-processing for metrics and
637
- file info.
638
-
639
- Parameters
640
- ----------
641
- project : str
642
- The project name to list entities from.
643
- entity_type : str
644
- The type of entities to list.
645
- **kwargs : dict
646
- Additional parameters to pass to the API call for filtering
647
- or pagination.
648
-
649
- Returns
650
- -------
651
- list[ContextEntity]
652
- List of context entity objects (latest versions only).
653
- """
654
- context = get_context_from_project(project)
655
- objs = self._list_context_entities(context, entity_type, **kwargs)
656
- objects = []
657
- for o in objs:
658
- entity: ContextEntity = factory.build_entity_from_dict(o)
659
- entity = self._post_process_get(entity)
660
- objects.append(entity)
661
- return objects
662
-
663
- def _update_material_entity(
664
- self,
665
- new_obj: MaterialEntity,
666
- ) -> dict:
667
- """
668
- Update a material entity using a shortcut method.
669
-
670
- Convenience method for updating material entities during
671
- file upload operations.
672
-
673
- Parameters
674
- ----------
675
- new_obj : MaterialEntity
676
- The material entity object to update.
677
-
678
- Returns
679
- -------
680
- dict
681
- Response data from the backend update operation.
682
- """
683
- return self.update_context_entity(
684
- new_obj.project,
685
- new_obj.ENTITY_TYPE,
686
- new_obj.id,
687
- new_obj.to_dict(),
688
- )
689
-
690
- def _update_context_entity(
691
- self,
692
- context: Context,
693
- entity_type: str,
694
- entity_id: str,
695
- entity_dict: dict,
696
- **kwargs,
697
- ) -> dict:
698
- """
699
- Update a context entity in the backend.
700
-
701
- Updates an existing context entity with new data. Entity
702
- specifications are typically immutable, so this primarily
703
- updates status and metadata.
704
-
705
- Parameters
706
- ----------
707
- context : Context
708
- The project context instance.
709
- entity_type : str
710
- The type of entity to update.
711
- entity_id : str
712
- The unique identifier of the entity to update.
713
- entity_dict : dict
714
- The updated entity data dictionary.
715
- **kwargs : dict
716
- Additional parameters to pass to the API call.
717
-
718
- Returns
719
- -------
720
- dict
721
- Response data from the backend update operation.
722
- """
723
- api = context.client.build_api(
724
- ApiCategories.CONTEXT.value,
725
- BackendOperations.UPDATE.value,
726
- project=context.name,
727
- entity_type=entity_type,
728
- entity_id=entity_id,
729
- )
730
- return context.client.update_object(api, entity_dict, **kwargs)
731
-
732
- def update_context_entity(
733
- self,
734
- project: str,
735
- entity_type: str,
736
- entity_id: str,
737
- entity_dict: dict,
738
- **kwargs,
739
- ) -> ContextEntity:
740
- """
741
- Update a context entity in the backend.
742
-
743
- Updates an existing context entity with new data and returns
744
- the updated context entity object. Entity specifications are
745
- typically immutable.
746
-
747
- Parameters
748
- ----------
749
- project : str
750
- The project name containing the entity.
751
- entity_type : str
752
- The type of entity to update.
753
- entity_id : str
754
- The unique identifier of the entity to update.
755
- entity_dict : dict
756
- The updated entity data dictionary.
757
- **kwargs : dict
758
- Additional parameters to pass to the API call.
759
-
760
- Returns
761
- -------
762
- ContextEntity
763
- The updated context entity object.
764
- """
765
- context = get_context_from_project(project)
766
- obj = self._update_context_entity(
767
- context,
768
- entity_type,
769
- entity_id,
770
- entity_dict,
771
- **kwargs,
772
- )
773
- return factory.build_entity_from_dict(obj)
774
-
775
- def _delete_context_entity(
776
- self,
777
- context: Context,
778
- identifier: str,
779
- entity_type: str | None = None,
780
- project: str | None = None,
781
- entity_id: str | None = None,
782
- **kwargs,
783
- ) -> dict:
784
- """
785
- Delete a context entity from the backend.
786
-
787
- Removes an entity from the backend, with options for deleting
788
- specific versions or all versions of a named entity. Handles
789
- cascade deletion if supported.
790
-
791
- Parameters
792
- ----------
793
- context : Context
794
- The project context instance.
795
- identifier : str
796
- Entity key (store://...) or entity name identifier.
797
- entity_type : str, optional
798
- The type of entity to delete.
799
- project : str, optional
800
- Project name (used for identifier parsing).
801
- entity_id : str, optional
802
- Specific entity ID to delete.
803
- **kwargs : dict
804
- Additional parameters including:
805
- - 'delete_all_versions': delete all versions of named entity
806
- - 'cascade': cascade deletion options
807
-
808
- Returns
809
- -------
810
- dict
811
- Response data from the backend delete operation.
812
- """
813
- project, entity_type, _, entity_name, entity_id = parse_identifier(
814
- identifier,
815
- project=project,
816
- entity_type=entity_type,
817
- entity_id=entity_id,
818
- )
819
-
820
- delete_all_versions: bool = kwargs.pop("delete_all_versions", False)
821
- kwargs = context.client.build_parameters(
822
- ApiCategories.CONTEXT.value,
823
- BackendOperations.DELETE.value,
824
- entity_id=entity_id,
825
- entity_name=entity_name,
826
- cascade=kwargs.pop("cascade", None),
827
- delete_all_versions=delete_all_versions,
828
- **kwargs,
829
- )
830
-
831
- if delete_all_versions:
832
- api = context.client.build_api(
833
- ApiCategories.CONTEXT.value,
834
- BackendOperations.LIST.value,
835
- project=context.name,
836
- entity_type=entity_type,
837
- )
838
- else:
839
- api = context.client.build_api(
840
- ApiCategories.CONTEXT.value,
841
- BackendOperations.DELETE.value,
842
- project=context.name,
843
- entity_type=entity_type,
844
- entity_id=entity_id,
845
- )
846
- return context.client.delete_object(api, **kwargs)
847
-
848
- def delete_context_entity(
849
- self,
850
- identifier: str,
851
- project: str | None = None,
852
- entity_type: str | None = None,
853
- entity_id: str | None = None,
854
- **kwargs,
855
- ) -> dict:
856
- """
857
- Delete a context entity from the backend.
858
-
859
- Removes an entity from the backend with support for deleting
860
- specific versions or all versions of a named entity.
861
-
862
- Parameters
863
- ----------
864
- identifier : str
865
- Entity key (store://...) or entity name identifier.
866
- project : str, optional
867
- Project name for context resolution.
868
- entity_type : str, optional
869
- The type of entity to delete.
870
- entity_id : str, optional
871
- Specific entity ID to delete.
872
- **kwargs : dict
873
- Additional parameters including deletion options.
874
-
875
- Returns
876
- -------
877
- dict
878
- Response data from the backend delete operation.
879
- """
880
- context = get_context_from_identifier(identifier, project)
881
- return self._delete_context_entity(
882
- context,
883
- identifier,
884
- entity_type,
885
- context.name,
886
- entity_id,
887
- **kwargs,
888
- )
889
-
890
- def _post_process_get(self, entity: ContextEntity) -> ContextEntity:
891
- """
892
- Post-process a retrieved context entity.
893
-
894
- Applies additional processing to entities after retrieval,
895
- including loading metrics and file information if available.
896
-
897
- Parameters
898
- ----------
899
- entity : ContextEntity
900
- The entity to post-process.
901
-
902
- Returns
903
- -------
904
- ContextEntity
905
- The post-processed entity with additional data loaded.
906
- """
907
- if hasattr(entity.status, "metrics"):
908
- entity._get_metrics()
909
- if hasattr(entity.status, "files"):
910
- entity._get_files_info()
911
- return entity
912
-
913
- ##############################
914
- # Context entity operations
915
- ##############################
916
-
917
- def _build_context_entity_key(
918
- self,
919
- context: Context,
920
- entity_type: str,
921
- entity_kind: str,
922
- entity_name: str,
923
- entity_id: str | None = None,
924
- ) -> str:
925
- """
926
- Build a storage key for a context entity.
927
-
928
- Creates a standardized key string for context entity identification
929
- and storage within a project context.
930
-
931
- Parameters
932
- ----------
933
- context : Context
934
- The project context instance.
935
- entity_type : str
936
- The type of entity.
937
- entity_kind : str
938
- The kind/subtype of entity.
939
- entity_name : str
940
- The name of the entity.
941
- entity_id : str, optional
942
- The unique identifier of the entity version.
943
-
944
- Returns
945
- -------
946
- str
947
- The constructed context entity key string.
948
- """
949
- return context.client.build_key(
950
- ApiCategories.CONTEXT.value,
951
- project=context.name,
952
- entity_type=entity_type,
953
- entity_kind=entity_kind,
954
- entity_name=entity_name,
955
- entity_id=entity_id,
956
- )
957
-
958
- def build_context_entity_key(
959
- self,
960
- project: str,
961
- entity_type: str,
962
- entity_kind: str,
963
- entity_name: str,
964
- entity_id: str | None = None,
965
- ) -> str:
966
- """
967
- Build a storage key for a context entity.
968
-
969
- Creates a standardized key string for context entity identification
970
- and storage, resolving the project context automatically.
971
-
972
- Parameters
973
- ----------
974
- project : str
975
- The project name containing the entity.
976
- entity_type : str
977
- The type of entity.
978
- entity_kind : str
979
- The kind/subtype of entity.
980
- entity_name : str
981
- The name of the entity.
982
- entity_id : str, optional
983
- The unique identifier of the entity version.
984
-
985
- Returns
986
- -------
987
- str
988
- The constructed context entity key string.
989
- """
990
- context = get_context_from_project(project)
991
- return self._build_context_entity_key(context, entity_type, entity_kind, entity_name, entity_id)
992
-
993
- def read_secret_data(
994
- self,
995
- project: str,
996
- entity_type: str,
997
- **kwargs,
998
- ) -> dict:
999
- """
1000
- Read secret data from the backend.
1001
-
1002
- Retrieves secret data stored in the backend for a specific
1003
- project and entity type.
1004
-
1005
- Parameters
1006
- ----------
1007
- project : str
1008
- The project name containing the secrets.
1009
- entity_type : str
1010
- The type of entity (typically 'secret').
1011
- **kwargs : dict
1012
- Additional parameters to pass to the API call.
1013
-
1014
- Returns
1015
- -------
1016
- dict
1017
- Secret data retrieved from the backend.
1018
- """
1019
- context = get_context_from_project(project)
1020
- api = context.client.build_api(
1021
- ApiCategories.CONTEXT.value,
1022
- BackendOperations.DATA.value,
1023
- project=context.name,
1024
- entity_type=entity_type,
1025
- )
1026
- return context.client.read_object(api, **kwargs)
1027
-
1028
- def update_secret_data(
1029
- self,
1030
- project: str,
1031
- entity_type: str,
1032
- data: dict,
1033
- **kwargs,
1034
- ) -> None:
1035
- """
1036
- Update secret data in the backend.
1037
-
1038
- Stores or updates secret data in the backend for a specific
1039
- project and entity type.
1040
-
1041
- Parameters
1042
- ----------
1043
- project : str
1044
- The project name to store secrets in.
1045
- entity_type : str
1046
- The type of entity (typically 'secret').
1047
- data : dict
1048
- The secret data dictionary to store.
1049
- **kwargs : dict
1050
- Additional parameters to pass to the API call.
1051
-
1052
- Returns
1053
- -------
1054
- None
1055
- """
1056
- context = get_context_from_project(project)
1057
- api = context.client.build_api(
1058
- ApiCategories.CONTEXT.value,
1059
- BackendOperations.DATA.value,
1060
- project=context.name,
1061
- entity_type=entity_type,
1062
- )
1063
- context.client.update_object(api, data, **kwargs)
1064
-
1065
- def read_run_logs(
1066
- self,
1067
- project: str,
1068
- entity_type: str,
1069
- entity_id: str,
1070
- **kwargs,
1071
- ) -> dict:
1072
- """
1073
- Read execution logs from the backend.
1074
-
1075
- Retrieves logs for a specific run or task execution from
1076
- the backend.
1077
-
1078
- Parameters
1079
- ----------
1080
- project : str
1081
- The project name containing the entity.
1082
- entity_type : str
1083
- The type of entity (typically 'run' or 'task').
1084
- entity_id : str
1085
- The unique identifier of the entity to get logs for.
1086
- **kwargs : dict
1087
- Additional parameters to pass to the API call.
1088
-
1089
- Returns
1090
- -------
1091
- dict
1092
- Log data retrieved from the backend.
1093
- """
1094
- context = get_context_from_project(project)
1095
- api = context.client.build_api(
1096
- ApiCategories.CONTEXT.value,
1097
- BackendOperations.LOGS.value,
1098
- project=context.name,
1099
- entity_type=entity_type,
1100
- entity_id=entity_id,
1101
- )
1102
- return context.client.read_object(api, **kwargs)
1103
-
1104
- def stop_entity(
1105
- self,
1106
- project: str,
1107
- entity_type: str,
1108
- entity_id: str,
1109
- **kwargs,
1110
- ) -> None:
1111
- """
1112
- Stop a running entity in the backend.
1113
-
1114
- Sends a stop signal to halt execution of a running entity
1115
- such as a workflow or long-running task.
1116
-
1117
- Parameters
1118
- ----------
1119
- project : str
1120
- The project name containing the entity.
1121
- entity_type : str
1122
- The type of entity to stop.
1123
- entity_id : str
1124
- The unique identifier of the entity to stop.
1125
- **kwargs : dict
1126
- Additional parameters to pass to the API call.
1127
-
1128
- Returns
1129
- -------
1130
- None
1131
- """
1132
- context = get_context_from_project(project)
1133
- api = context.client.build_api(
1134
- ApiCategories.CONTEXT.value,
1135
- BackendOperations.STOP.value,
1136
- project=context.name,
1137
- entity_type=entity_type,
1138
- entity_id=entity_id,
1139
- )
1140
- context.client.create_object(api, **kwargs)
1141
-
1142
- def resume_entity(
1143
- self,
1144
- project: str,
1145
- entity_type: str,
1146
- entity_id: str,
1147
- **kwargs,
1148
- ) -> None:
1149
- """
1150
- Resume a stopped entity in the backend.
1151
-
1152
- Sends a resume signal to restart execution of a previously
1153
- stopped entity such as a workflow or task.
1154
-
1155
- Parameters
1156
- ----------
1157
- project : str
1158
- The project name containing the entity.
1159
- entity_type : str
1160
- The type of entity to resume.
1161
- entity_id : str
1162
- The unique identifier of the entity to resume.
1163
- **kwargs : dict
1164
- Additional parameters to pass to the API call.
1165
-
1166
- Returns
1167
- -------
1168
- None
1169
- """
1170
- context = get_context_from_project(project)
1171
- api = context.client.build_api(
1172
- ApiCategories.CONTEXT.value,
1173
- BackendOperations.RESUME.value,
1174
- project=context.name,
1175
- entity_type=entity_type,
1176
- entity_id=entity_id,
1177
- )
1178
- context.client.create_object(api, **kwargs)
1179
-
1180
- def read_files_info(
1181
- self,
1182
- project: str,
1183
- entity_type: str,
1184
- entity_id: str,
1185
- **kwargs,
1186
- ) -> list[dict]:
1187
- """
1188
- Read file information from the backend.
1189
-
1190
- Retrieves metadata about files associated with an entity,
1191
- including file paths, sizes, and other attributes.
1192
-
1193
- Parameters
1194
- ----------
1195
- project : str
1196
- The project name containing the entity.
1197
- entity_type : str
1198
- The type of entity to get file info for.
1199
- entity_id : str
1200
- The unique identifier of the entity.
1201
- **kwargs : dict
1202
- Additional parameters to pass to the API call.
1203
-
1204
- Returns
1205
- -------
1206
- list[dict]
1207
- List of file information dictionaries from the backend.
1208
- """
1209
- context = get_context_from_project(project)
1210
- api = context.client.build_api(
1211
- ApiCategories.CONTEXT.value,
1212
- BackendOperations.FILES.value,
1213
- project=context.name,
1214
- entity_type=entity_type,
1215
- entity_id=entity_id,
1216
- )
1217
- return context.client.read_object(api, **kwargs)
1218
-
1219
- def update_files_info(
1220
- self,
1221
- project: str,
1222
- entity_type: str,
1223
- entity_id: str,
1224
- entity_list: list[dict],
1225
- **kwargs,
1226
- ) -> None:
1227
- """
1228
- Get files info from backend.
1229
-
1230
- Parameters
1231
- ----------
1232
- project : str
1233
- Project name.
1234
- entity_type : str
1235
- Entity type.
1236
- entity_id : str
1237
- Entity ID.
1238
- entity_list : list[dict]
1239
- Entity list.
1240
- **kwargs : dict
1241
- Parameters to pass to the API call.
1242
-
1243
- Returns
1244
- -------
1245
- None
1246
- """
1247
- context = get_context_from_project(project)
1248
- api = context.client.build_api(
1249
- ApiCategories.CONTEXT.value,
1250
- BackendOperations.FILES.value,
1251
- project=context.name,
1252
- entity_type=entity_type,
1253
- entity_id=entity_id,
1254
- )
1255
- return context.client.update_object(api, entity_list, **kwargs)
1256
-
1257
- def read_metrics(
1258
- self,
1259
- project: str,
1260
- entity_type: str,
1261
- entity_id: str,
1262
- metric_name: str | None = None,
1263
- **kwargs,
1264
- ) -> dict:
1265
- """
1266
- Read metrics from the backend for a specific entity.
1267
-
1268
- Retrieves metrics data associated with an entity. Can fetch either
1269
- all metrics or a specific metric by name. Used for performance
1270
- monitoring and analysis of entity operations.
1271
-
1272
- Parameters
1273
- ----------
1274
- project : str
1275
- The project name containing the entity.
1276
- entity_type : str
1277
- The type of entity to read metrics from.
1278
- entity_id : str
1279
- The unique identifier of the entity.
1280
- metric_name : str, optional
1281
- The name of a specific metric to retrieve.
1282
- If None, retrieves all available metrics.
1283
- **kwargs : dict
1284
- Additional parameters to pass to the API call.
1285
-
1286
- Returns
1287
- -------
1288
- dict
1289
- Dictionary containing metric data from the backend.
1290
- """
1291
- context = get_context_from_project(project)
1292
- api = context.client.build_api(
1293
- ApiCategories.CONTEXT.value,
1294
- BackendOperations.METRICS.value,
1295
- project=context.name,
1296
- entity_type=entity_type,
1297
- entity_id=entity_id,
1298
- metric_name=metric_name,
1299
- )
1300
- return context.client.read_object(api, **kwargs)
1301
-
1302
- def update_metric(
1303
- self,
1304
- project: str,
1305
- entity_type: str,
1306
- entity_id: str,
1307
- metric_name: str,
1308
- metric_value: Any,
1309
- **kwargs,
1310
- ) -> None:
1311
- """
1312
- Update or create a metric value for an entity in the backend.
1313
-
1314
- Updates an existing metric or creates a new one with the specified
1315
- value. Metrics are used for tracking performance, status, and
1316
- other quantitative aspects of entity operations.
1317
-
1318
- Parameters
1319
- ----------
1320
- project : str
1321
- The project name containing the entity.
1322
- entity_type : str
1323
- The type of entity to update metrics for.
1324
- entity_id : str
1325
- The unique identifier of the entity.
1326
- metric_name : str
1327
- The name of the metric to update or create.
1328
- metric_value : Any
1329
- The value to set for the metric.
1330
- Can be numeric, string, or other supported types.
1331
- **kwargs : dict
1332
- Additional parameters to pass to the API call.
1333
-
1334
- Returns
1335
- -------
1336
- None
1337
- """
1338
- context = get_context_from_project(project)
1339
- api = context.client.build_api(
1340
- ApiCategories.CONTEXT.value,
1341
- BackendOperations.METRICS.value,
1342
- project=context.name,
1343
- entity_type=entity_type,
1344
- entity_id=entity_id,
1345
- metric_name=metric_name,
1346
- )
1347
- context.client.update_object(api, metric_value, **kwargs)
1348
-
1349
- def _search(
1350
- self,
1351
- context: Context,
1352
- **kwargs,
1353
- ) -> dict:
1354
- """
1355
- Execute search query against the backend API.
1356
-
1357
- Internal method that performs the actual search operation
1358
- by building API parameters, executing the search request,
1359
- and processing the results into entity objects.
1360
-
1361
- Parameters
1362
- ----------
1363
- context : Context
1364
- The context instance containing client and project information.
1365
- **kwargs : dict
1366
- Search parameters and filters to pass to the API call.
1367
-
1368
- Returns
1369
- -------
1370
- dict
1371
- List of context entity objects matching the search criteria.
1372
- """
1373
- kwargs = context.client.build_parameters(
1374
- ApiCategories.CONTEXT.value,
1375
- BackendOperations.SEARCH.value,
1376
- **kwargs,
1377
- )
1378
- api = context.client.build_api(
1379
- ApiCategories.CONTEXT.value,
1380
- BackendOperations.SEARCH.value,
1381
- project=context.name,
1382
- )
1383
- entities_dict = context.client.read_object(api, **kwargs)
1384
- return [self.read_context_entity(entity["key"]) for entity in entities_dict["content"]]
1385
-
1386
- def search_entity(
1387
- self,
1388
- project: str,
1389
- query: str | None = None,
1390
- entity_types: list[str] | None = None,
1391
- name: str | None = None,
1392
- kind: str | None = None,
1393
- created: str | None = None,
1394
- updated: str | None = None,
1395
- description: str | None = None,
1396
- labels: list[str] | None = None,
1397
- **kwargs,
1398
- ) -> list[ContextEntity]:
1399
- """
1400
- Search for entities in the backend using various criteria.
1401
-
1402
- Performs a flexible search across multiple entity attributes,
1403
- allowing for complex queries and filtering. Returns matching
1404
- entities from the project context.
1405
-
1406
- Parameters
1407
- ----------
1408
- project : str
1409
- The project name to search within.
1410
- query : str, optional
1411
- Free-text search query to match against entity content.
1412
- entity_types : list[str], optional
1413
- List of entity types to filter by.
1414
- If None, searches all entity types.
1415
- name : str, optional
1416
- Entity name pattern to match.
1417
- kind : str, optional
1418
- Entity kind to filter by.
1419
- created : str, optional
1420
- Creation date filter (ISO format).
1421
- updated : str, optional
1422
- Last update date filter (ISO format).
1423
- description : str, optional
1424
- Description pattern to match.
1425
- labels : list[str], optional
1426
- List of label patterns to match.
1427
- **kwargs : dict
1428
- Additional search parameters to pass to the API call.
1429
-
1430
- Returns
1431
- -------
1432
- list[ContextEntity]
1433
- List of matching entity instances from the search.
1434
- """
1435
- context = get_context_from_project(project)
1436
- return self._search(
1437
- context,
1438
- query=query,
1439
- entity_types=entity_types,
1440
- name=name,
1441
- kind=kind,
1442
- created=created,
1443
- updated=updated,
1444
- description=description,
1445
- labels=labels,
1446
- **kwargs,
1447
- )
1448
-
1449
-
1450
- context_processor = ContextEntityOperationsProcessor()