dbos 0.15.0__tar.gz → 0.16.0a1__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.
Potentially problematic release.
This version of dbos might be problematic. Click here for more details.
- {dbos-0.15.0 → dbos-0.16.0a1}/PKG-INFO +1 -1
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_context.py +16 -6
- {dbos-0.15.0 → dbos-0.16.0a1}/pyproject.toml +1 -1
- dbos-0.16.0a1/tests/test_spans.py +80 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/LICENSE +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/README.md +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/__init__.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_admin_server.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_app_db.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_classproperty.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_core.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_croniter.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_dbos.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_dbos_config.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_error.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_fastapi.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_flask.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_kafka.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_kafka_message.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_logger.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_migrations/env.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_migrations/script.py.mako +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_migrations/versions/50f3227f0b4b_fix_job_queue.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_migrations/versions/5c361fc04708_added_system_tables.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_migrations/versions/a3b18ad34abe_added_triggers.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_migrations/versions/d76646551a6b_job_queue_limiter.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_migrations/versions/d76646551a6c_workflow_queue.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_migrations/versions/eab0cc1d9a14_job_queue.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_queue.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_recovery.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_registrations.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_request.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_roles.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_scheduler.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_schemas/__init__.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_schemas/application_database.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_schemas/system_database.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_serialization.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_sys_db.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_templates/hello/README.md +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_templates/hello/__package/__init__.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_templates/hello/__package/main.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_templates/hello/__package/schema.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_templates/hello/alembic.ini +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_templates/hello/dbos-config.yaml.dbos +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_templates/hello/migrations/env.py.dbos +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_templates/hello/migrations/script.py.mako +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_templates/hello/migrations/versions/2024_07_31_180642_init.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_templates/hello/start_postgres_docker.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/_tracer.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/cli.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/dbos-config.schema.json +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/dbos/py.typed +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/tests/__init__.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/tests/atexit_no_ctor.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/tests/atexit_no_launch.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/tests/classdefs.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/tests/conftest.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/tests/more_classdefs.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/tests/test_admin_server.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/tests/test_classdecorators.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/tests/test_concurrency.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/tests/test_config.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/tests/test_croniter.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/tests/test_dbos.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/tests/test_failures.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/tests/test_fastapi.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/tests/test_fastapi_roles.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/tests/test_flask.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/tests/test_kafka.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/tests/test_package.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/tests/test_queue.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/tests/test_scheduler.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/tests/test_schema_migration.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/tests/test_singleton.py +0 -0
- {dbos-0.15.0 → dbos-0.16.0a1}/version/__init__.py +0 -0
|
@@ -98,18 +98,27 @@ class DBOSContext:
|
|
|
98
98
|
wfid = str(uuid.uuid4())
|
|
99
99
|
return wfid
|
|
100
100
|
|
|
101
|
-
def start_workflow(
|
|
101
|
+
def start_workflow(
|
|
102
|
+
self,
|
|
103
|
+
wfid: Optional[str],
|
|
104
|
+
attributes: TracedAttributes,
|
|
105
|
+
is_temp_workflow: bool = False,
|
|
106
|
+
) -> None:
|
|
102
107
|
if wfid is None or len(wfid) == 0:
|
|
103
108
|
wfid = self.assign_workflow_id()
|
|
104
109
|
self.id_assigned_for_next_workflow = ""
|
|
105
110
|
self.workflow_id = wfid
|
|
106
111
|
self.function_id = 0
|
|
107
|
-
|
|
112
|
+
if not is_temp_workflow:
|
|
113
|
+
self._start_span(attributes)
|
|
108
114
|
|
|
109
|
-
def end_workflow(
|
|
115
|
+
def end_workflow(
|
|
116
|
+
self, exc_value: Optional[BaseException], is_temp_workflow: bool = False
|
|
117
|
+
) -> None:
|
|
110
118
|
self.workflow_id = ""
|
|
111
119
|
self.function_id = -1
|
|
112
|
-
|
|
120
|
+
if not is_temp_workflow:
|
|
121
|
+
self._end_span(exc_value)
|
|
113
122
|
|
|
114
123
|
def is_within_workflow(self) -> bool:
|
|
115
124
|
return len(self.workflow_id) > 0
|
|
@@ -349,6 +358,7 @@ class EnterDBOSWorkflow(AbstractContextManager[DBOSContext, Literal[False]]):
|
|
|
349
358
|
def __init__(self, attributes: TracedAttributes) -> None:
|
|
350
359
|
self.created_ctx = False
|
|
351
360
|
self.attributes = attributes
|
|
361
|
+
self.is_temp_workflow = attributes["name"] == "temp_wf"
|
|
352
362
|
|
|
353
363
|
def __enter__(self) -> DBOSContext:
|
|
354
364
|
# Code to create a basic context
|
|
@@ -359,7 +369,7 @@ class EnterDBOSWorkflow(AbstractContextManager[DBOSContext, Literal[False]]):
|
|
|
359
369
|
_set_local_dbos_context(ctx)
|
|
360
370
|
assert not ctx.is_within_workflow()
|
|
361
371
|
ctx.start_workflow(
|
|
362
|
-
None, self.attributes
|
|
372
|
+
None, self.attributes, self.is_temp_workflow
|
|
363
373
|
) # Will get from the context's next workflow ID
|
|
364
374
|
return ctx
|
|
365
375
|
|
|
@@ -371,7 +381,7 @@ class EnterDBOSWorkflow(AbstractContextManager[DBOSContext, Literal[False]]):
|
|
|
371
381
|
) -> Literal[False]:
|
|
372
382
|
ctx = assert_current_dbos_context()
|
|
373
383
|
assert ctx.is_within_workflow()
|
|
374
|
-
ctx.end_workflow(exc_value)
|
|
384
|
+
ctx.end_workflow(exc_value, self.is_temp_workflow)
|
|
375
385
|
# Code to clean up the basic context if we created it
|
|
376
386
|
if self.created_ctx:
|
|
377
387
|
_clear_local_dbos_context()
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
from typing import Tuple
|
|
2
|
+
|
|
3
|
+
from fastapi import FastAPI
|
|
4
|
+
from fastapi.testclient import TestClient
|
|
5
|
+
from opentelemetry.sdk import trace as tracesdk
|
|
6
|
+
from opentelemetry.sdk.trace.export import SimpleSpanProcessor
|
|
7
|
+
from opentelemetry.sdk.trace.export.in_memory_span_exporter import InMemorySpanExporter
|
|
8
|
+
|
|
9
|
+
from dbos import DBOS
|
|
10
|
+
from dbos._tracer import dbos_tracer
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def test_spans(dbos: DBOS) -> None:
|
|
14
|
+
|
|
15
|
+
@DBOS.workflow()
|
|
16
|
+
def test_workflow() -> None:
|
|
17
|
+
test_step()
|
|
18
|
+
|
|
19
|
+
@DBOS.step()
|
|
20
|
+
def test_step() -> None:
|
|
21
|
+
return
|
|
22
|
+
|
|
23
|
+
exporter = InMemorySpanExporter()
|
|
24
|
+
span_processor = SimpleSpanProcessor(exporter)
|
|
25
|
+
provider = tracesdk.TracerProvider()
|
|
26
|
+
provider.add_span_processor(span_processor)
|
|
27
|
+
dbos_tracer.set_provider(provider)
|
|
28
|
+
|
|
29
|
+
test_workflow()
|
|
30
|
+
test_step()
|
|
31
|
+
|
|
32
|
+
spans = exporter.get_finished_spans()
|
|
33
|
+
|
|
34
|
+
assert len(spans) == 3
|
|
35
|
+
|
|
36
|
+
for span in spans:
|
|
37
|
+
assert span.attributes is not None
|
|
38
|
+
assert span.context is not None
|
|
39
|
+
|
|
40
|
+
assert spans[0].name == test_step.__name__
|
|
41
|
+
assert spans[1].name == test_workflow.__name__
|
|
42
|
+
assert spans[2].name == test_step.__name__
|
|
43
|
+
|
|
44
|
+
assert spans[0].parent.span_id == spans[1].context.span_id # type: ignore
|
|
45
|
+
assert spans[1].parent == None
|
|
46
|
+
assert spans[2].parent == None
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def test_temp_wf_fastapi(dbos_fastapi: Tuple[DBOS, FastAPI]) -> None:
|
|
50
|
+
_, app = dbos_fastapi
|
|
51
|
+
|
|
52
|
+
@app.get("/step")
|
|
53
|
+
@DBOS.step()
|
|
54
|
+
def test_step_endpoint() -> str:
|
|
55
|
+
return "test"
|
|
56
|
+
|
|
57
|
+
exporter = InMemorySpanExporter()
|
|
58
|
+
span_processor = SimpleSpanProcessor(exporter)
|
|
59
|
+
provider = tracesdk.TracerProvider()
|
|
60
|
+
provider.add_span_processor(span_processor)
|
|
61
|
+
dbos_tracer.set_provider(provider)
|
|
62
|
+
|
|
63
|
+
client = TestClient(app)
|
|
64
|
+
response = client.get("/step")
|
|
65
|
+
assert response.status_code == 200
|
|
66
|
+
assert response.text == '"test"'
|
|
67
|
+
|
|
68
|
+
spans = exporter.get_finished_spans()
|
|
69
|
+
|
|
70
|
+
assert len(spans) == 2
|
|
71
|
+
|
|
72
|
+
for span in spans:
|
|
73
|
+
assert span.attributes is not None
|
|
74
|
+
assert span.context is not None
|
|
75
|
+
|
|
76
|
+
assert spans[0].name == test_step_endpoint.__name__
|
|
77
|
+
assert spans[1].name == "/step"
|
|
78
|
+
|
|
79
|
+
assert spans[0].parent.span_id == spans[1].context.span_id # type:ignore
|
|
80
|
+
assert spans[1].parent == None
|
|
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
|
{dbos-0.15.0 → dbos-0.16.0a1}/dbos/_templates/hello/migrations/versions/2024_07_31_180642_init.py
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
|