@@ -413,20 +413,26 @@ def create(spec: Dict[str, Any], name: str, namespace: str, **_: Any) -> Dict[st
413
413
# If we find a key ending with '/owner', keep it
414
414
# (for use as an environment variable later)
415
415
instance_owner = "Unknown"
416
+ instance_id = "Unknown"
416
417
for label in material .get ("labels" , []):
417
418
key , value = label .split ("=" )
418
419
deployment_body ["spec" ]["template" ]["metadata" ]["labels" ][key ] = value
419
420
if key .endswith ("/owner" ):
420
421
instance_owner = value
422
+ elif key .endswith ("/instance-id" ):
423
+ instance_id = value
421
424
422
425
# To simplify the dynamic ENV adjustments we're about to make...
423
426
c_env = deployment_body ["spec" ]["template" ]["spec" ]["containers" ][0 ]["env" ]
424
427
425
428
if notebook_interface != "classic" :
426
429
c_env .append ({"name" : "JUPYTER_ENABLE_LAB" , "value" : "true" })
427
430
428
- # Add a Project UUID environment variable
431
+ # Add a Project and Instance UUID environment variables
432
+ # The project comes from the 'material->project' structure
433
+ # the instance comes from the provided "material->label''
429
434
c_env .append ({"name" : "DM_PROJECT_ID" , "value" : str (project_id )})
435
+ c_env .append ({"name" : "DM_INSTANCE_ID" , "value" : str (instance_id )})
430
436
# Add the instance owner (expected to have been extracted from a label)
431
437
c_env .append ({"name" : "DM_INSTANCE_OWNER" , "value" : str (instance_owner )})
432
438
0 commit comments