@@ -54,6 +54,11 @@ class TextEncoding(enum.Enum):
54
54
JINJA2_3_0 = 1 # Encoding that complies with Jinja2 v3.0.x
55
55
56
56
57
+ def get_job_key (collection : str , job : str ) -> str :
58
+ """Returns the job Key, a string formed from "<collection>|<job>."""
59
+ return f"{ collection } |{ job } "
60
+
61
+
57
62
def validate_manifest_schema (manifest : Dict [str , Any ]) -> Optional [str ]:
58
63
"""Checks the Job Definition Manifest (a preloaded job-definition dictionary)
59
64
against the built-in schema. If there's an error the error text is
@@ -298,6 +303,22 @@ def get_environment_assets(job_definition: Dict[str, Any]) -> List[Dict[str, str
298
303
return env_assets
299
304
300
305
306
+ def get_jobs_replaced (job_definition : Dict [str , Any ]) -> Optional [List [str ]]:
307
+ """Given a Job Definition this function returns the Jobs it replaces.
308
+ The returned list is a list of jobs identified by collection and
309
+ job delimited with '|', e.g. string like "test-collection|test-job".
310
+ """
311
+ replaces_list : List [Dict [str , str ]] = job_definition .get ("replaces" , [])
312
+ if not replaces_list :
313
+ return None
314
+ replaced : Set [str ] = set ()
315
+ for replaces in replaces_list :
316
+ r_collection : str = replaces ["collection" ]
317
+ r_job : str = replaces ["job" ]
318
+ replaced .add (get_job_key (r_collection , r_job ))
319
+ return list (replaced )
320
+
321
+
301
322
def decode (
302
323
template_text : str ,
303
324
variable_map : Optional [Dict [str , str ]],
0 commit comments