dbos 2.1.0a1__tar.gz → 2.1.0a2__tar.gz
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.
- {dbos-2.1.0a1 → dbos-2.1.0a2}/PKG-INFO +1 -1
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_core.py +16 -13
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_sys_db.py +21 -1
- {dbos-2.1.0a1 → dbos-2.1.0a2}/pyproject.toml +1 -1
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/test_dbos.py +31 -15
- {dbos-2.1.0a1 → dbos-2.1.0a2}/LICENSE +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/README.md +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/__init__.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/__main__.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_admin_server.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_app_db.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_classproperty.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_client.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_conductor/conductor.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_conductor/protocol.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_context.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_croniter.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_dbos.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_dbos_config.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_debouncer.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_debug.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_docker_pg_helper.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_error.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_event_loop.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_fastapi.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_flask.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_kafka.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_kafka_message.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_logger.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_migration.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_outcome.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_queue.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_recovery.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_registrations.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_roles.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_scheduler.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_schemas/__init__.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_schemas/application_database.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_schemas/system_database.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_serialization.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_sys_db_postgres.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_sys_db_sqlite.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_templates/dbos-db-starter/README.md +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_templates/dbos-db-starter/__package/__init__.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_templates/dbos-db-starter/__package/main.py.dbos +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_templates/dbos-db-starter/__package/schema.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_templates/dbos-db-starter/dbos-config.yaml.dbos +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_templates/dbos-db-starter/migrations/create_table.py.dbos +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_templates/dbos-db-starter/start_postgres_docker.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_tracer.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_utils.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_workflow_commands.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/cli/_github_init.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/cli/_template_init.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/cli/cli.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/cli/migration.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/dbos-config.schema.json +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/py.typed +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/__init__.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/atexit_no_ctor.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/atexit_no_launch.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/classdefs.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/client_collateral.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/client_worker.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/conftest.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/dupname_classdefs1.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/dupname_classdefsa.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/more_classdefs.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/queuedworkflow.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/script_without_fastapi.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/test_admin_server.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/test_async.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/test_async_workflow_management.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/test_classdecorators.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/test_cli.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/test_client.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/test_concurrency.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/test_config.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/test_croniter.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/test_debouncer.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/test_debug.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/test_docker_secrets.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/test_failures.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/test_fastapi.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/test_fastapi_roles.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/test_flask.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/test_kafka.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/test_outcome.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/test_package.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/test_queue.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/test_scheduler.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/test_schema_migration.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/test_singleton.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/test_spans.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/test_sqlalchemy.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/test_streaming.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/test_workflow_introspection.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/tests/test_workflow_management.py +0 -0
- {dbos-2.1.0a1 → dbos-2.1.0a2}/version/__init__.py +0 -0
@@ -1278,21 +1278,24 @@ def recv(dbos: "DBOS", topic: Optional[str] = None, timeout_seconds: float = 60)
|
|
1278
1278
|
def set_event(dbos: "DBOS", key: str, value: Any) -> None:
|
1279
1279
|
cur_ctx = get_local_dbos_context()
|
1280
1280
|
if cur_ctx is not None:
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1281
|
+
if cur_ctx.is_workflow():
|
1282
|
+
# If called from a workflow function, run as a step
|
1283
|
+
attributes: TracedAttributes = {
|
1284
|
+
"name": "set_event",
|
1285
|
+
}
|
1286
|
+
with EnterDBOSStep(attributes):
|
1287
|
+
ctx = assert_current_dbos_context()
|
1288
|
+
dbos._sys_db.set_event_from_workflow(
|
1289
|
+
ctx.workflow_id, ctx.curr_step_function_id, key, value
|
1290
|
+
)
|
1291
|
+
elif cur_ctx.is_step():
|
1292
|
+
dbos._sys_db.set_event_from_step(cur_ctx.workflow_id, key, value)
|
1293
|
+
else:
|
1294
|
+
raise DBOSException(
|
1295
|
+
"set_event() must be called from within a workflow or step"
|
1292
1296
|
)
|
1293
1297
|
else:
|
1294
|
-
|
1295
|
-
raise DBOSException("set_event() must be called from within a workflow")
|
1298
|
+
raise DBOSException("set_event() must be called from within a workflow or step")
|
1296
1299
|
|
1297
1300
|
|
1298
1301
|
def get_event(
|
@@ -1524,7 +1524,7 @@ class SystemDatabase(ABC):
|
|
1524
1524
|
return duration
|
1525
1525
|
|
1526
1526
|
@db_retry()
|
1527
|
-
def
|
1527
|
+
def set_event_from_workflow(
|
1528
1528
|
self,
|
1529
1529
|
workflow_uuid: str,
|
1530
1530
|
function_id: int,
|
@@ -1566,6 +1566,26 @@ class SystemDatabase(ABC):
|
|
1566
1566
|
}
|
1567
1567
|
self._record_operation_result_txn(output, conn=c)
|
1568
1568
|
|
1569
|
+
def set_event_from_step(
|
1570
|
+
self,
|
1571
|
+
workflow_uuid: str,
|
1572
|
+
key: str,
|
1573
|
+
message: Any,
|
1574
|
+
) -> None:
|
1575
|
+
with self.engine.begin() as c:
|
1576
|
+
c.execute(
|
1577
|
+
self.dialect.insert(SystemSchema.workflow_events)
|
1578
|
+
.values(
|
1579
|
+
workflow_uuid=workflow_uuid,
|
1580
|
+
key=key,
|
1581
|
+
value=_serialization.serialize(message),
|
1582
|
+
)
|
1583
|
+
.on_conflict_do_update(
|
1584
|
+
index_elements=["workflow_uuid", "key"],
|
1585
|
+
set_={"value": _serialization.serialize(message)},
|
1586
|
+
)
|
1587
|
+
)
|
1588
|
+
|
1569
1589
|
def get_all_events(self, workflow_id: str) -> Dict[str, Any]:
|
1570
1590
|
"""
|
1571
1591
|
Get all events currently present for a workflow ID.
|
@@ -965,41 +965,57 @@ def test_send_recv_temp_wf(dbos: DBOS) -> None:
|
|
965
965
|
def test_set_get_events(dbos: DBOS) -> None:
|
966
966
|
@DBOS.workflow()
|
967
967
|
def test_setevent_workflow() -> None:
|
968
|
-
|
969
|
-
|
970
|
-
|
968
|
+
DBOS.set_event("key1", "value1")
|
969
|
+
DBOS.set_event("key2", "value2")
|
970
|
+
DBOS.set_event("key3", None)
|
971
|
+
set_event_step()
|
972
|
+
|
973
|
+
@DBOS.step()
|
974
|
+
def set_event_step() -> None:
|
975
|
+
DBOS.set_event("key4", "value4")
|
971
976
|
|
972
977
|
@DBOS.workflow()
|
973
978
|
def test_getevent_workflow(
|
974
|
-
target_uuid: str, key: str,
|
979
|
+
target_uuid: str, key: str, timeout: float = 0.0
|
975
980
|
) -> Optional[str]:
|
976
|
-
msg = dbos.get_event(target_uuid, key,
|
981
|
+
msg = dbos.get_event(target_uuid, key, timeout)
|
977
982
|
return str(msg) if msg is not None else None
|
978
983
|
|
979
|
-
|
980
|
-
with SetWorkflowID(
|
984
|
+
wfid = str(uuid.uuid4())
|
985
|
+
with SetWorkflowID(wfid):
|
981
986
|
test_setevent_workflow()
|
982
|
-
with SetWorkflowID(
|
987
|
+
with SetWorkflowID(wfid):
|
983
988
|
test_setevent_workflow()
|
984
989
|
|
985
|
-
value1 = test_getevent_workflow(
|
990
|
+
value1 = test_getevent_workflow(wfid, "key1")
|
986
991
|
assert value1 == "value1"
|
987
992
|
|
988
|
-
value2 = test_getevent_workflow(
|
993
|
+
value2 = test_getevent_workflow(wfid, "key2")
|
989
994
|
assert value2 == "value2"
|
990
995
|
|
991
996
|
# Run getEvent outside of a workflow
|
992
|
-
value1 =
|
997
|
+
value1 = DBOS.get_event(wfid, "key1", 0)
|
993
998
|
assert value1 == "value1"
|
994
999
|
|
995
|
-
value2 =
|
1000
|
+
value2 = DBOS.get_event(wfid, "key2", 0)
|
996
1001
|
assert value2 == "value2"
|
997
1002
|
|
998
1003
|
begin_time = time.time()
|
999
|
-
value3 = test_getevent_workflow(
|
1004
|
+
value3 = test_getevent_workflow(wfid, "key3")
|
1000
1005
|
assert value3 is None
|
1001
|
-
|
1002
|
-
|
1006
|
+
|
1007
|
+
value4 = DBOS.get_event(wfid, "key4", 0)
|
1008
|
+
assert value4 == "value4"
|
1009
|
+
|
1010
|
+
steps = DBOS.list_workflow_steps(wfid)
|
1011
|
+
assert len(steps) == 4
|
1012
|
+
assert (
|
1013
|
+
steps[0]["function_name"]
|
1014
|
+
== steps[1]["function_name"]
|
1015
|
+
== steps[2]["function_name"]
|
1016
|
+
== "DBOS.setEvent"
|
1017
|
+
)
|
1018
|
+
assert steps[3]["function_name"] == set_event_step.__qualname__
|
1003
1019
|
|
1004
1020
|
# Test OAOO
|
1005
1021
|
timeout_uuid = str(uuid.uuid4())
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{dbos-2.1.0a1 → dbos-2.1.0a2}/dbos/_templates/dbos-db-starter/migrations/create_table.py.dbos
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|