runnable 0.21.0__py3-none-any.whl → 0.22.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.
@@ -244,6 +244,7 @@ class TemplateDefaults(BaseModelWIthConfig):
244
244
  image: str
245
245
  image_pull_policy: Optional[ImagePullPolicy] = Field(default=ImagePullPolicy.Always)
246
246
  resources: Resources = Field(default_factory=Resources)
247
+ env: list[EnvVar | SecretEnvVar] = Field(default_factory=list, exclude=True)
247
248
 
248
249
 
249
250
  # User provides this as part of the argoSpec
@@ -365,6 +366,7 @@ class ArgoExecutor(GenericPipelineExecutor):
365
366
  custom_volumes: Optional[list[CustomVolume]] = Field(
366
367
  default_factory=list[CustomVolume]
367
368
  )
369
+ env: list[EnvVar] = Field(default_factory=list[EnvVar])
368
370
 
369
371
  expose_parameters_as_inputs: bool = True
370
372
  secret_from_k8s: Optional[str] = Field(default=None)
@@ -508,6 +510,10 @@ class ArgoExecutor(GenericPipelineExecutor):
508
510
  )
509
511
 
510
512
  self._set_up_initial_container(container_template=core_container_template)
513
+ self._expose_secrets_to_task(
514
+ working_on=node, container_template=core_container_template
515
+ )
516
+ self._set_env_vars_to_task(node, core_container_template)
511
517
 
512
518
  container_template = ContainerTemplate(
513
519
  container=core_container_template,
@@ -523,12 +529,32 @@ class ArgoExecutor(GenericPipelineExecutor):
523
529
 
524
530
  return container_template
525
531
 
532
+ def _set_env_vars_to_task(
533
+ self, working_on: BaseNode, container_template: CoreContainerTemplate
534
+ ):
535
+ if not isinstance(working_on, TaskNode):
536
+ return
537
+ global_envs: dict[str, str] = {}
538
+
539
+ for env_var in self.env:
540
+ global_envs[env_var.name] = env_var.value
541
+
542
+ node_overide = {}
543
+ if hasattr(working_on, "overides"):
544
+ node_overide = working_on.overides
545
+
546
+ global_envs.update(node_overide.get("env", {}))
547
+ for key, value in global_envs.items():
548
+ env_var_to_add = EnvVar(name=key, value=value)
549
+ container_template.env.append(env_var_to_add)
550
+
526
551
  def _expose_secrets_to_task(
527
552
  self,
528
553
  working_on: BaseNode,
529
554
  container_template: CoreContainerTemplate,
530
555
  ):
531
- assert isinstance(working_on, TaskNode)
556
+ if not isinstance(working_on, TaskNode):
557
+ return
532
558
  secrets = working_on.executable.secrets
533
559
  for secret in secrets:
534
560
  assert self.secret_from_k8s is not None
runnable/utils.py CHANGED
@@ -109,8 +109,16 @@ def apply_variables(
109
109
  raise Exception("Argument Variables should be dict")
110
110
 
111
111
  json_d = json.dumps(apply_to)
112
- transformed = str_template(json_d).substitute(**variables)
113
- return json.loads(transformed)
112
+ string_template = str_template(json_d)
113
+
114
+ template = string_template.safe_substitute(variables)
115
+
116
+ if "$" in template:
117
+ logger.warning(
118
+ "Not all variables found in the config are found in the variables"
119
+ )
120
+
121
+ return json.loads(template)
114
122
 
115
123
 
116
124
  def get_module_and_attr_names(command: str) -> Tuple[str, str]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: runnable
3
- Version: 0.21.0
3
+ Version: 0.22.0
4
4
  Summary: Add your description here
5
5
  Author-email: "Vammi, Vijay" <vijay.vammi@astrazeneca.com>
6
6
  License-File: LICENSE
@@ -15,7 +15,7 @@ extensions/nodes/nodes.py,sha256=ib68QE737ihGLIVp3V2wea13u7lmMZdRvK80bgUkRtA,346
15
15
  extensions/nodes/pyproject.toml,sha256=YTu-ETN3JNFSkMzzWeOwn4m-O2nbRH-PmiPBALDCUw4,278
16
16
  extensions/pipeline_executor/README.md,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  extensions/pipeline_executor/__init__.py,sha256=YnKILiy-SxfnG3rYUoinjh1lfkuAF5QXpPePtn6VxBY,25174
18
- extensions/pipeline_executor/argo.py,sha256=zA-9zeo93Rvyn-7--bLNwRybREUrtmFRC0QL8oXwNio,32154
18
+ extensions/pipeline_executor/argo.py,sha256=81Lv8WO2riYo4KdtgpRabl5YtSgrNGGq8PfMo6YLKUY,33154
19
19
  extensions/pipeline_executor/local.py,sha256=H8s6AdML_9_f-vdGG_6k0y9FbLqAqvA1S_7xMNyARzY,1946
20
20
  extensions/pipeline_executor/local_container.py,sha256=HOT9I-cPDCvgy6_bzNEtl4jPhTyeYSn1GK7lplH3vDA,12515
21
21
  extensions/pipeline_executor/mocked.py,sha256=SuObJ6Myt7p8duW8sylIp1cYIAnFutsJW1avWaOUY3c,5798
@@ -49,9 +49,9 @@ runnable/pickler.py,sha256=ydJ_eti_U1F4l-YacFp7BWm6g5vTn04UXye25S1HVok,2684
49
49
  runnable/sdk.py,sha256=-FvRoIMlbNFOS_8c2kefYA-mlyE_15rNG3GoN6gKumc,33470
50
50
  runnable/secrets.py,sha256=PXcEJw-4WPzeWRLfsatcPPyr1zkqgHzdRWRcS9vvpvM,2354
51
51
  runnable/tasks.py,sha256=YVKpKxSpsRZWcU3MOqoBoqxeo1XSqv5crkOu6kyu63o,28520
52
- runnable/utils.py,sha256=QRGITdXWWSSN7a5mF4jEIDoXV50mAQzwnJZZSMEvn54,19537
53
- runnable-0.21.0.dist-info/METADATA,sha256=K1mbkcVQzpxM5IyAN4cCnNbBj2TPAdP_4oM6RbcFsAU,9945
54
- runnable-0.21.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
55
- runnable-0.21.0.dist-info/entry_points.txt,sha256=seek5WVGvwYALm8lZ0TfPXwG5NaCeUKjU8urF8k3gvY,1621
56
- runnable-0.21.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
57
- runnable-0.21.0.dist-info/RECORD,,
52
+ runnable/utils.py,sha256=HyYo6Xe4O02eHuT_m9oLqzh7dxdhbmtTqKzgFR2bpWE,19712
53
+ runnable-0.22.0.dist-info/METADATA,sha256=KsHHJP5DJOu9S1yv7SEid62OEnSg_eBZfBGbgYUWUiw,9945
54
+ runnable-0.22.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
55
+ runnable-0.22.0.dist-info/entry_points.txt,sha256=seek5WVGvwYALm8lZ0TfPXwG5NaCeUKjU8urF8k3gvY,1621
56
+ runnable-0.22.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
57
+ runnable-0.22.0.dist-info/RECORD,,