File tree Expand file tree Collapse file tree 3 files changed +36
-1
lines changed Expand file tree Collapse file tree 3 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -324,6 +324,17 @@ def __init__(
324324 self .conductor_websocket : Optional [ConductorWebsocket ] = None
325325 self ._background_event_loop : BackgroundEventLoop = BackgroundEventLoop ()
326326
327+ # Globally set the application version and executor ID.
328+ # In DBOS Cloud, instead use the values supplied through environment variables.
329+ if not os .environ .get ("DBOS__CLOUD" ) == "true" :
330+ if (
331+ "application_version" in config
332+ and config ["application_version" ] is not None
333+ ):
334+ GlobalParams .app_version = config ["application_version" ]
335+ if "executor_id" in config and config ["executor_id" ] is not None :
336+ GlobalParams .executor_id = config ["executor_id" ]
337+
327338 init_logger ()
328339
329340 # Translate user provided config to an internal format
Original file line number Diff line number Diff line change @@ -47,6 +47,8 @@ class DBOSConfig(TypedDict, total=False):
4747 admin_port : Optional [int ]
4848 run_admin_server : Optional [bool ]
4949 otlp_attributes : Optional [dict [str , str ]]
50+ application_version : Optional [str ]
51+ executor_id : Optional [str ]
5052
5153
5254class RuntimeConfig (TypedDict , total = False ):
Original file line number Diff line number Diff line change @@ -1397,7 +1397,7 @@ def workflow_one(x: int) -> int:
13971397 assert GlobalParams .app_version != app_version
13981398
13991399 # Verify that version can be overriden with an environment variable
1400- app_version = "12345"
1400+ app_version = str ( uuid . uuid4 ())
14011401 os .environ ["DBOS__APPVERSION" ] = app_version
14021402
14031403 DBOS .destroy (destroy_registry = True )
@@ -1412,6 +1412,28 @@ def workflow_one(x: int) -> int:
14121412
14131413 del os .environ ["DBOS__APPVERSION" ]
14141414
1415+ # Verify that version and executor ID can be overriden with a config parameter
1416+ app_version = str (uuid .uuid4 ())
1417+ executor_id = str (uuid .uuid4 ())
1418+
1419+ DBOS .destroy (destroy_registry = True )
1420+ config ["application_version" ] = app_version
1421+ config ["executor_id" ] = executor_id
1422+ DBOS (config = config )
1423+
1424+ @DBOS .workflow ()
1425+ def test_workflow () -> str :
1426+ assert DBOS .workflow_id
1427+ return DBOS .workflow_id
1428+
1429+ DBOS .launch ()
1430+ assert GlobalParams .app_version == app_version
1431+ assert GlobalParams .executor_id == executor_id
1432+ wfid = test_workflow ()
1433+ handle : WorkflowHandle [str ] = DBOS .retrieve_workflow (wfid )
1434+ assert handle .get_status ().app_version == app_version
1435+ assert handle .get_status ().executor_id == executor_id
1436+
14151437
14161438def test_recovery_appversion (config : DBOSConfig ) -> None :
14171439 input = 5
You can’t perform that action at this time.
0 commit comments