digitalhub 0.14.2__py3-none-any.whl → 0.14.3__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.

@@ -464,6 +464,7 @@ class ExecutableEntity(VersionedEntity):
464
464
  action: str,
465
465
  trigger_kind: str,
466
466
  trigger_name: str,
467
+ template: dict | None = None,
467
468
  **kwargs,
468
469
  ) -> Trigger:
469
470
  """
@@ -475,8 +476,12 @@ class ExecutableEntity(VersionedEntity):
475
476
  Action to execute.
476
477
  trigger_kind : str
477
478
  Trigger kind.
479
+ trigger_name : str
480
+ Trigger name.
481
+ template : dict
482
+ Template for the trigger.
478
483
  **kwargs : dict
479
- Keyword arguments passed to Run builder.
484
+ Keyword arguments passed to trigger builder.
480
485
 
481
486
  Returns
482
487
  -------
@@ -487,17 +492,30 @@ class ExecutableEntity(VersionedEntity):
487
492
  task_kind = entity_factory.get_task_kind_from_action(self.kind, action)
488
493
  task = self._get_or_create_task(task_kind)
489
494
  task_string = task._get_task_string()
495
+ exec_string = self._get_executable_string()
490
496
 
491
497
  # Get run validator for building trigger template
492
498
  run_kind = entity_factory.get_run_kind_from_action(self.kind, action)
493
499
  run_validator: SpecValidator = entity_factory.get_spec_validator(run_kind)
500
+
494
501
  # Override kwargs
495
502
  kwargs["project"] = self.project
496
503
  kwargs["kind"] = trigger_kind
497
504
  kwargs["name"] = trigger_name
498
- kwargs[self.ENTITY_TYPE] = self._get_executable_string()
505
+
506
+ # Template handling
507
+ if template is None:
508
+ template = {}
509
+ if not isinstance(template, dict):
510
+ raise EntityError("Template must be a dictionary")
511
+
512
+ template["task"] = task_string
513
+ template[self.ENTITY_TYPE] = exec_string
514
+ template = run_validator(**template).to_dict()
515
+
516
+ kwargs[self.ENTITY_TYPE] = exec_string
499
517
  kwargs["task"] = task_string
500
- kwargs["template"] = run_validator(**kwargs).to_dict()
518
+ kwargs["template"] = template
501
519
 
502
520
  # Create object instance
503
521
  trigger: Trigger = entity_factory.build_entity_from_params(**kwargs)
@@ -41,6 +41,12 @@ def new_trigger(
41
41
  Object name.
42
42
  kind : str
43
43
  Kind the object.
44
+ task : str
45
+ Task string.
46
+ function : str
47
+ Function string.
48
+ workflow : str
49
+ Workflow string.
44
50
  uuid : str
45
51
  ID of the object.
46
52
  description : str
@@ -63,18 +69,31 @@ def new_trigger(
63
69
  >>> kind="trigger",
64
70
  >>> name="my-trigger",)
65
71
  """
66
- if workflow is None and function is None:
67
- raise ValueError("Workflow or function must be provided")
72
+ if workflow is None:
73
+ if function is None:
74
+ raise ValueError("Workflow or function must be provided")
75
+ executable_type = "function"
76
+ executable = function
77
+ else:
78
+ executable_type = "workflow"
79
+ executable = workflow
80
+
81
+ # Prepare kwargs
68
82
  if kwargs is None:
69
83
  kwargs = {}
84
+ kwargs["task"] = task
85
+ kwargs[executable_type] = executable
86
+
87
+ # Template handling
70
88
  if template is None:
71
89
  template = {}
90
+ if not isinstance(template, dict):
91
+ raise ValueError("Template must be a dictionary")
72
92
  template["task"] = task
73
- if workflow is not None:
74
- template["workflow"] = workflow
75
- if function is not None:
76
- template["function"] = function
93
+ template[executable_type] = executable
94
+ template["local_execution"] = False
77
95
  kwargs["template"] = template
96
+
78
97
  return context_processor.create_context_entity(
79
98
  project=project,
80
99
  name=name,
@@ -136,7 +136,7 @@ class ClientConfigurator:
136
136
  # Therefore, we change the origin to file, where the refresh token is written.
137
137
  # We also try to fetch the PAT from both env and file
138
138
  if self._auth_type == AuthType.EXCHANGE.value:
139
- self.refresh_credentials(retry=True)
139
+ self.refresh_credentials()
140
140
 
141
141
  def refreshable_auth_types(self) -> bool:
142
142
  """
@@ -189,6 +189,9 @@ class ClientConfigurator:
189
189
  """
190
190
  Refresh authentication tokens using OAuth2 flows.
191
191
  """
192
+ if not self.refreshable_auth_types():
193
+ raise ClientError(f"Auth type {self._auth_type} does not support refresh.")
194
+
192
195
  # Get credentials and configuration
193
196
  creds = configurator.get_config_creds()
194
197
 
@@ -220,9 +223,6 @@ class ClientConfigurator:
220
223
  creds : dict
221
224
  Available credential values.
222
225
  """
223
- if not self.refreshable_auth_types():
224
- raise ClientError(f"Auth type {self._auth_type} does not support refresh.")
225
-
226
226
  if (client_id := creds.get(ConfigurationVars.DHCORE_CLIENT_ID.value)) is None:
227
227
  raise ClientError("Client id not set.")
228
228
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: digitalhub
3
- Version: 0.14.2
3
+ Version: 0.14.3
4
4
  Summary: Python SDK for Digitalhub
5
5
  Project-URL: Homepage, https://github.com/scc-digitalhub/digitalhub-sdk
6
6
  Author-email: Fondazione Bruno Kessler <digitalhub@fbk.eu>, Matteo Martini <mmartini@fbk.eu>
@@ -16,7 +16,7 @@ digitalhub/entities/_base/entity/metadata.py,sha256=iX_dwpABPh3EBPTJs5mtSrwnylw4
16
16
  digitalhub/entities/_base/entity/spec.py,sha256=nGlE8xgAZXT5zs1annWaPLvPRYaqxqzjjrhAhvNiQkA,1608
17
17
  digitalhub/entities/_base/entity/status.py,sha256=0txG13WDPJE-vRAUkJQYEHMsSzer6qTvTo7xqzbg66Y,1152
18
18
  digitalhub/entities/_base/executable/__init__.py,sha256=IRY2i9U97wptE3OcC_NO-EBmcAH6-Q36gMCspKetQ0k,107
19
- digitalhub/entities/_base/executable/entity.py,sha256=vDqijNBE852lXDkjsun1eNa-jOWckhb-ADqJtAo-TpY,16013
19
+ digitalhub/entities/_base/executable/entity.py,sha256=5WnO382DkC3QG6MJ0RXCK-Qj9NTqLY6baFHw8jY5nCQ,16515
20
20
  digitalhub/entities/_base/material/__init__.py,sha256=IRY2i9U97wptE3OcC_NO-EBmcAH6-Q36gMCspKetQ0k,107
21
21
  digitalhub/entities/_base/material/entity.py,sha256=EgYQRpS0o8xsYh-3G7zG32dyjrBbU1vVImR3ZnEuNlQ,6658
22
22
  digitalhub/entities/_base/material/spec.py,sha256=7lF_Pv7zGJUAR2ixmmCt-UPnoASgOLxnb9yffqwBVp8,544
@@ -162,7 +162,7 @@ digitalhub/entities/task/_base/models.py,sha256=-7-bM8R-lRTqPkPint9Yw810-wLFkAk2
162
162
  digitalhub/entities/task/_base/spec.py,sha256=TQ7IXW_QnTGxFvVDk0M22DlaqMWm9Klq1Yk6LGBAhEM,2608
163
163
  digitalhub/entities/task/_base/status.py,sha256=9TazT1vKJT8NRvh__ymKJ89CUUcf7UhnLREcvudrFTU,270
164
164
  digitalhub/entities/trigger/__init__.py,sha256=IRY2i9U97wptE3OcC_NO-EBmcAH6-Q36gMCspKetQ0k,107
165
- digitalhub/entities/trigger/crud.py,sha256=vcpdWgkInszxYIPLBkUfgneF0vTW4s7LaRqiRafYj1E,7904
165
+ digitalhub/entities/trigger/crud.py,sha256=gIVWDdV3rpDh8g4jHHjV7n7XDwfWrxsQbvzWPwDgz0M,8341
166
166
  digitalhub/entities/trigger/_base/__init__.py,sha256=IRY2i9U97wptE3OcC_NO-EBmcAH6-Q36gMCspKetQ0k,107
167
167
  digitalhub/entities/trigger/_base/builder.py,sha256=JhRVtp6JMue-05zr-bQ3gjm4Dh_g0bnBhzdJi6OR5Y0,1835
168
168
  digitalhub/entities/trigger/_base/entity.py,sha256=mhDFQ4JOndYU0lQJ4spKRR6pxuJU6G-6Cz639JtPRP8,1279
@@ -200,7 +200,7 @@ digitalhub/stores/client/__init__.py,sha256=0NWCFXlcnb45II98tUAGtvXUNVMXsIbFePmo
200
200
  digitalhub/stores/client/api_builder.py,sha256=RrAVQRHzm0Z68hsH3TO8-VsR3_7X7y3maluCTO0aW98,4452
201
201
  digitalhub/stores/client/builder.py,sha256=y58cKn93t-2QQkyCocFPE_Zus34uNHOLNcCb9DIwdGo,872
202
202
  digitalhub/stores/client/client.py,sha256=cfMhMC_9atcKTWNockvBA8IsFNEoJqoyMNnireqqjaA,9566
203
- digitalhub/stores/client/configurator.py,sha256=_5vWMhmKleM2dFqBoRQAQdvZxKtzqJE3j3nATrDIuyQ,13504
203
+ digitalhub/stores/client/configurator.py,sha256=UFf3WMSS_-qxE2vweEVNDaHUglp2TwXtyKAUHrv7Yl8,13494
204
204
  digitalhub/stores/client/enums.py,sha256=lCM5W3xOSPt1YarY1sqoNCHWfx_NKldgk3byTk9bJ8U,908
205
205
  digitalhub/stores/client/error_parser.py,sha256=lJNRC_rXA1pVpkF-g_lOp5TXOBsTpt6CArSRTVRswiY,4572
206
206
  digitalhub/stores/client/header_manager.py,sha256=iCDyy1G6ISGWG4r5ptluE0kVZaJgoCwjyjAVpLQFgDA,1774
@@ -253,8 +253,8 @@ digitalhub/utils/logger.py,sha256=hH3gGE35L8jRxrg8EPXGZZAK1OA5-CvWnayuBZzteBM,54
253
253
  digitalhub/utils/store_utils.py,sha256=Nuj5BzcAll-qIIgAgvp00S3yfV50NyWdTZEabJAqxDE,1013
254
254
  digitalhub/utils/types.py,sha256=orCxY43zXMJfKZsOj6FUR85u9wRBPJ0wdkzrBHTnVW8,217
255
255
  digitalhub/utils/uri_utils.py,sha256=Go787CxAOo2MMjFIEt8XssomtyV8vTdIrpyjSQK3gAM,4408
256
- digitalhub-0.14.2.dist-info/METADATA,sha256=QgydhVI9VRHdV-uuO9RQhtPoYBuf5jN-Z9EJXfdpQYA,18127
257
- digitalhub-0.14.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
258
- digitalhub-0.14.2.dist-info/licenses/AUTHORS,sha256=iDleK_2EAMmh0o8Te_E9mdXQCP4rBfFr9dW9d0-pCno,301
259
- digitalhub-0.14.2.dist-info/licenses/LICENSE,sha256=z3xQCHfGmTnigfoUe3uidW_GUSVeFBdos30w9VNTRec,11361
260
- digitalhub-0.14.2.dist-info/RECORD,,
256
+ digitalhub-0.14.3.dist-info/METADATA,sha256=JLlNWu_muIK8JRmS0ZMUUPTdTrii-G2VgNYRatzvrb8,18127
257
+ digitalhub-0.14.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
258
+ digitalhub-0.14.3.dist-info/licenses/AUTHORS,sha256=iDleK_2EAMmh0o8Te_E9mdXQCP4rBfFr9dW9d0-pCno,301
259
+ digitalhub-0.14.3.dist-info/licenses/LICENSE,sha256=z3xQCHfGmTnigfoUe3uidW_GUSVeFBdos30w9VNTRec,11361
260
+ digitalhub-0.14.3.dist-info/RECORD,,