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__(
324
324
self .conductor_websocket : Optional [ConductorWebsocket ] = None
325
325
self ._background_event_loop : BackgroundEventLoop = BackgroundEventLoop ()
326
326
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
+
327
338
init_logger ()
328
339
329
340
# 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):
47
47
admin_port : Optional [int ]
48
48
run_admin_server : Optional [bool ]
49
49
otlp_attributes : Optional [dict [str , str ]]
50
+ application_version : Optional [str ]
51
+ executor_id : Optional [str ]
50
52
51
53
52
54
class RuntimeConfig (TypedDict , total = False ):
Original file line number Diff line number Diff line change @@ -1397,7 +1397,7 @@ def workflow_one(x: int) -> int:
1397
1397
assert GlobalParams .app_version != app_version
1398
1398
1399
1399
# Verify that version can be overriden with an environment variable
1400
- app_version = "12345"
1400
+ app_version = str ( uuid . uuid4 ())
1401
1401
os .environ ["DBOS__APPVERSION" ] = app_version
1402
1402
1403
1403
DBOS .destroy (destroy_registry = True )
@@ -1412,6 +1412,28 @@ def workflow_one(x: int) -> int:
1412
1412
1413
1413
del os .environ ["DBOS__APPVERSION" ]
1414
1414
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
+
1415
1437
1416
1438
def test_recovery_appversion (config : DBOSConfig ) -> None :
1417
1439
input = 5
You can’t perform that action at this time.
0 commit comments