dbos 0.21.0a4__py3-none-any.whl → 0.21.0a5__py3-none-any.whl

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/_dbos_config.py CHANGED
@@ -123,7 +123,10 @@ def get_dbos_database_url(config_file_path: str = DBOS_CONFIG_PATH) -> str:
123
123
 
124
124
 
125
125
  def load_config(
126
- config_file_path: str = DBOS_CONFIG_PATH, *, use_db_wizard: bool = True
126
+ config_file_path: str = DBOS_CONFIG_PATH,
127
+ *,
128
+ use_db_wizard: bool = True,
129
+ silent: bool = False,
127
130
  ) -> ConfigFile:
128
131
  """
129
132
  Load the DBOS `ConfigFile` from the specified path (typically `dbos-config.yaml`).
@@ -188,18 +191,19 @@ def load_config(
188
191
  # Load the DB connection file. Use its values for missing fields from dbos-config.yaml. Use defaults otherwise.
189
192
  data = cast(ConfigFile, data)
190
193
  db_connection = load_db_connection()
191
- if data["database"].get("hostname"):
192
- print(
193
- "[bold blue]Loading database connection parameters from dbos-config.yaml[/bold blue]"
194
- )
195
- elif db_connection.get("hostname"):
196
- print(
197
- "[bold blue]Loading database connection parameters from .dbos/db_connection[/bold blue]"
198
- )
199
- else:
200
- print(
201
- "[bold blue]Using default database connection parameters (localhost)[/bold blue]"
202
- )
194
+ if not silent:
195
+ if data["database"].get("hostname"):
196
+ print(
197
+ "[bold blue]Loading database connection parameters from dbos-config.yaml[/bold blue]"
198
+ )
199
+ elif db_connection.get("hostname"):
200
+ print(
201
+ "[bold blue]Loading database connection parameters from .dbos/db_connection[/bold blue]"
202
+ )
203
+ else:
204
+ print(
205
+ "[bold blue]Using default database connection parameters (localhost)[/bold blue]"
206
+ )
203
207
 
204
208
  data["database"]["hostname"] = (
205
209
  data["database"].get("hostname") or db_connection.get("hostname") or "localhost"
dbos/_sys_db.py CHANGED
@@ -126,6 +126,15 @@ class GetWorkflowsInput:
126
126
  )
127
127
 
128
128
 
129
+ class GetQueuedWorkflowsInput(TypedDict):
130
+ queue_name: Optional[str]
131
+ status: Optional[str]
132
+ start_time: Optional[str] # Timestamp in ISO 8601 format
133
+ end_time: Optional[str] # Timestamp in ISO 8601 format
134
+ limit: Optional[int] # Return up to this many workflows IDs.
135
+ name: Optional[str] # The name of the workflow function
136
+
137
+
129
138
  class GetWorkflowsOutput:
130
139
  def __init__(self, workflow_uuids: List[str]):
131
140
  self.workflow_uuids = workflow_uuids
@@ -658,7 +667,6 @@ class SystemDatabase:
658
667
  query = sa.select(SystemSchema.workflow_status.c.workflow_uuid).order_by(
659
668
  SystemSchema.workflow_status.c.created_at.desc()
660
669
  )
661
-
662
670
  if input.name:
663
671
  query = query.where(SystemSchema.workflow_status.c.name == input.name)
664
672
  if input.authenticated_user:
@@ -692,6 +700,52 @@ class SystemDatabase:
692
700
 
693
701
  return GetWorkflowsOutput(workflow_uuids)
694
702
 
703
+ def get_queued_workflows(
704
+ self, input: GetQueuedWorkflowsInput
705
+ ) -> GetWorkflowsOutput:
706
+
707
+ query = (
708
+ sa.select(SystemSchema.workflow_queue.c.workflow_uuid)
709
+ .join(
710
+ SystemSchema.workflow_status,
711
+ SystemSchema.workflow_queue.c.workflow_uuid
712
+ == SystemSchema.workflow_status.c.workflow_uuid,
713
+ )
714
+ .order_by(SystemSchema.workflow_status.c.created_at.desc())
715
+ )
716
+
717
+ if input.get("name"):
718
+ query = query.where(SystemSchema.workflow_status.c.name == input["name"])
719
+
720
+ if input.get("queue_name"):
721
+ query = query.where(
722
+ SystemSchema.workflow_queue.c.queue_name == input["queue_name"]
723
+ )
724
+
725
+ if input.get("status"):
726
+ query = query.where(
727
+ SystemSchema.workflow_status.c.status == input["status"]
728
+ )
729
+ if "start_time" in input and input["start_time"] is not None:
730
+ query = query.where(
731
+ SystemSchema.workflow_status.c.created_at
732
+ >= datetime.datetime.fromisoformat(input["start_time"]).timestamp()
733
+ * 1000
734
+ )
735
+ if "end_time" in input and input["end_time"] is not None:
736
+ query = query.where(
737
+ SystemSchema.workflow_status.c.created_at
738
+ <= datetime.datetime.fromisoformat(input["end_time"]).timestamp() * 1000
739
+ )
740
+ if input.get("limit"):
741
+ query = query.limit(input["limit"])
742
+
743
+ with self.engine.begin() as c:
744
+ rows = c.execute(query)
745
+ workflow_uuids = [row[0] for row in rows]
746
+
747
+ return GetWorkflowsOutput(workflow_uuids)
748
+
695
749
  def get_pending_workflows(self, executor_id: str) -> list[str]:
696
750
  with self.engine.begin() as c:
697
751
  rows = c.execute(
@@ -5,6 +5,7 @@ import typer
5
5
  from . import _serialization
6
6
  from ._dbos_config import ConfigFile
7
7
  from ._sys_db import (
8
+ GetQueuedWorkflowsInput,
8
9
  GetWorkflowsInput,
9
10
  GetWorkflowsOutput,
10
11
  SystemDatabase,
@@ -19,8 +20,8 @@ class WorkflowInformation:
19
20
  workflowClassName: Optional[str]
20
21
  workflowConfigName: Optional[str]
21
22
  input: Optional[_serialization.WorkflowInputs] # JSON (jsonpickle)
22
- output: Optional[str] # JSON (jsonpickle)
23
- error: Optional[str] # JSON (jsonpickle)
23
+ output: Optional[str] = None # JSON (jsonpickle)
24
+ error: Optional[str] = None # JSON (jsonpickle)
24
25
  executor_id: Optional[str]
25
26
  app_version: Optional[str]
26
27
  app_id: Optional[str]
@@ -34,17 +35,15 @@ class WorkflowInformation:
34
35
 
35
36
  def list_workflows(
36
37
  config: ConfigFile,
37
- li: int,
38
+ limit: int,
38
39
  user: Optional[str],
39
40
  starttime: Optional[str],
40
41
  endtime: Optional[str],
41
42
  status: Optional[str],
42
43
  request: bool,
43
44
  appversion: Optional[str],
45
+ name: Optional[str],
44
46
  ) -> List[WorkflowInformation]:
45
-
46
- sys_db = None
47
-
48
47
  try:
49
48
  sys_db = SystemDatabase(config)
50
49
 
@@ -55,24 +54,55 @@ def list_workflows(
55
54
  if status is not None:
56
55
  input.status = cast(WorkflowStatuses, status)
57
56
  input.application_version = appversion
58
- input.limit = li
57
+ input.limit = limit
58
+ input.name = name
59
59
 
60
60
  output: GetWorkflowsOutput = sys_db.get_workflows(input)
61
-
62
61
  infos: List[WorkflowInformation] = []
62
+ for workflow_id in output.workflow_uuids:
63
+ info = _get_workflow_info(
64
+ sys_db, workflow_id, request
65
+ ) # Call the method for each ID
66
+ if info is not None:
67
+ infos.append(info)
68
+
69
+ return infos
70
+ except Exception as e:
71
+ typer.echo(f"Error listing workflows: {e}")
72
+ return []
73
+ finally:
74
+ if sys_db:
75
+ sys_db.destroy()
63
76
 
64
- if output.workflow_uuids is None:
65
- typer.echo("No workflows found")
66
- return {}
67
77
 
78
+ def list_queued_workflows(
79
+ config: ConfigFile,
80
+ limit: Optional[int] = None,
81
+ start_time: Optional[str] = None,
82
+ end_time: Optional[str] = None,
83
+ queue_name: Optional[str] = None,
84
+ status: Optional[str] = None,
85
+ name: Optional[str] = None,
86
+ request: bool = False,
87
+ ) -> List[WorkflowInformation]:
88
+ try:
89
+ sys_db = SystemDatabase(config)
90
+ input: GetQueuedWorkflowsInput = {
91
+ "queue_name": queue_name,
92
+ "start_time": start_time,
93
+ "end_time": end_time,
94
+ "status": status,
95
+ "limit": limit,
96
+ "name": name,
97
+ }
98
+ output: GetWorkflowsOutput = sys_db.get_queued_workflows(input)
99
+ infos: List[WorkflowInformation] = []
68
100
  for workflow_id in output.workflow_uuids:
69
101
  info = _get_workflow_info(
70
102
  sys_db, workflow_id, request
71
103
  ) # Call the method for each ID
72
-
73
104
  if info is not None:
74
105
  infos.append(info)
75
-
76
106
  return infos
77
107
  except Exception as e:
78
108
  typer.echo(f"Error listing workflows: {e}")
dbos/cli/cli.py CHANGED
@@ -19,14 +19,21 @@ from .. import load_config
19
19
  from .._app_db import ApplicationDatabase
20
20
  from .._dbos_config import _is_valid_app_name
21
21
  from .._sys_db import SystemDatabase, reset_system_database
22
- from .._workflow_commands import cancel_workflow, get_workflow, list_workflows
22
+ from .._workflow_commands import (
23
+ cancel_workflow,
24
+ get_workflow,
25
+ list_queued_workflows,
26
+ list_workflows,
27
+ )
23
28
  from ..cli._github_init import create_template_from_github
24
29
  from ._template_init import copy_template, get_project_name, get_templates_directory
25
30
 
26
31
  app = typer.Typer()
27
32
  workflow = typer.Typer()
33
+ queue = typer.Typer()
28
34
 
29
35
  app.add_typer(workflow, name="workflow", help="Manage DBOS workflows")
36
+ workflow.add_typer(queue, name="queue", help="Manage enqueued workflows")
30
37
 
31
38
 
32
39
  def _on_windows() -> bool:
@@ -272,18 +279,22 @@ def list(
272
279
  help="Retrieve workflows with this application version",
273
280
  ),
274
281
  ] = None,
282
+ name: Annotated[
283
+ typing.Optional[str],
284
+ typer.Option(
285
+ "--name",
286
+ "-n",
287
+ help="Retrieve workflows with this name",
288
+ ),
289
+ ] = None,
275
290
  request: Annotated[
276
291
  bool,
277
292
  typer.Option("--request", help="Retrieve workflow request information"),
278
293
  ] = True,
279
- appdir: Annotated[
280
- typing.Optional[str],
281
- typer.Option("--app-dir", "-d", help="Specify the application root directory"),
282
- ] = None,
283
294
  ) -> None:
284
- config = load_config()
295
+ config = load_config(silent=True)
285
296
  workflows = list_workflows(
286
- config, limit, user, starttime, endtime, status, request, appversion
297
+ config, limit, user, starttime, endtime, status, request, appversion, name
287
298
  )
288
299
  print(jsonpickle.encode(workflows, unpicklable=False))
289
300
 
@@ -291,16 +302,12 @@ def list(
291
302
  @workflow.command(help="Retrieve the status of a workflow")
292
303
  def get(
293
304
  uuid: Annotated[str, typer.Argument()],
294
- appdir: Annotated[
295
- typing.Optional[str],
296
- typer.Option("--app-dir", "-d", help="Specify the application root directory"),
297
- ] = None,
298
305
  request: Annotated[
299
306
  bool,
300
307
  typer.Option("--request", help="Retrieve workflow request information"),
301
308
  ] = True,
302
309
  ) -> None:
303
- config = load_config()
310
+ config = load_config(silent=True)
304
311
  print(jsonpickle.encode(get_workflow(config, uuid, request), unpicklable=False))
305
312
 
306
313
 
@@ -309,10 +316,6 @@ def get(
309
316
  )
310
317
  def cancel(
311
318
  uuid: Annotated[str, typer.Argument()],
312
- appdir: Annotated[
313
- typing.Optional[str],
314
- typer.Option("--app-dir", "-d", help="Specify the application root directory"),
315
- ] = None,
316
319
  ) -> None:
317
320
  config = load_config()
318
321
  cancel_workflow(config, uuid)
@@ -363,5 +366,70 @@ def restart(
363
366
  print(f"Failed to resume workflow {uuid}. Status code: {response.status_code}")
364
367
 
365
368
 
369
+ @queue.command(name="list", help="List enqueued functions for your application")
370
+ def list_queue(
371
+ limit: Annotated[
372
+ typing.Optional[int],
373
+ typer.Option("--limit", "-l", help="Limit the results returned"),
374
+ ] = None,
375
+ start_time: Annotated[
376
+ typing.Optional[str],
377
+ typer.Option(
378
+ "--start-time",
379
+ "-s",
380
+ help="Retrieve functions starting after this timestamp (ISO 8601 format)",
381
+ ),
382
+ ] = None,
383
+ end_time: Annotated[
384
+ typing.Optional[str],
385
+ typer.Option(
386
+ "--end-time",
387
+ "-e",
388
+ help="Retrieve functions starting before this timestamp (ISO 8601 format)",
389
+ ),
390
+ ] = None,
391
+ status: Annotated[
392
+ typing.Optional[str],
393
+ typer.Option(
394
+ "--status",
395
+ "-S",
396
+ help="Retrieve functions with this status (PENDING, SUCCESS, ERROR, RETRIES_EXCEEDED, ENQUEUED, or CANCELLED)",
397
+ ),
398
+ ] = None,
399
+ queue_name: Annotated[
400
+ typing.Optional[str],
401
+ typer.Option(
402
+ "--queue-name",
403
+ "-q",
404
+ help="Retrieve functions on this queue",
405
+ ),
406
+ ] = None,
407
+ name: Annotated[
408
+ typing.Optional[str],
409
+ typer.Option(
410
+ "--name",
411
+ "-n",
412
+ help="Retrieve functions on this queue",
413
+ ),
414
+ ] = None,
415
+ request: Annotated[
416
+ bool,
417
+ typer.Option("--request", help="Retrieve workflow request information"),
418
+ ] = True,
419
+ ) -> None:
420
+ config = load_config(silent=True)
421
+ workflows = list_queued_workflows(
422
+ config=config,
423
+ limit=limit,
424
+ start_time=start_time,
425
+ end_time=end_time,
426
+ queue_name=queue_name,
427
+ status=status,
428
+ request=request,
429
+ name=name,
430
+ )
431
+ print(jsonpickle.encode(workflows, unpicklable=False))
432
+
433
+
366
434
  if __name__ == "__main__":
367
435
  app()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dbos
3
- Version: 0.21.0a4
3
+ Version: 0.21.0a5
4
4
  Summary: Ultra-lightweight durable execution in Python
5
5
  Author-Email: "DBOS, Inc." <contact@dbos.dev>
6
6
  License: MIT
@@ -1,7 +1,7 @@
1
- dbos-0.21.0a4.dist-info/METADATA,sha256=YFvX-uuQsvFQM0j6IuS3jugWr93rx3QhQAHffV15nkY,5309
2
- dbos-0.21.0a4.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
3
- dbos-0.21.0a4.dist-info/entry_points.txt,sha256=_QOQ3tVfEjtjBlr1jS4sHqHya9lI2aIEIWkz8dqYp14,58
4
- dbos-0.21.0a4.dist-info/licenses/LICENSE,sha256=VGZit_a5-kdw9WT6fY5jxAWVwGQzgLFyPWrcVVUhVNU,1067
1
+ dbos-0.21.0a5.dist-info/METADATA,sha256=1LAPN_Eu4X7ptR9xM02sR1tryFaQ42KeKGkeOm3yCQQ,5309
2
+ dbos-0.21.0a5.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
3
+ dbos-0.21.0a5.dist-info/entry_points.txt,sha256=_QOQ3tVfEjtjBlr1jS4sHqHya9lI2aIEIWkz8dqYp14,58
4
+ dbos-0.21.0a5.dist-info/licenses/LICENSE,sha256=VGZit_a5-kdw9WT6fY5jxAWVwGQzgLFyPWrcVVUhVNU,1067
5
5
  dbos/__init__.py,sha256=CxRHBHEthPL4PZoLbZhp3rdm44-KkRTT2-7DkK9d4QQ,724
6
6
  dbos/_admin_server.py,sha256=PJgneZG9-64TapZrPeJtt73puAswRImCE5uce2k2PKU,4750
7
7
  dbos/_app_db.py,sha256=_tv2vmPjjiaikwgxH3mqxgJ4nUUcG2-0uMXKWCqVu1c,5509
@@ -14,7 +14,7 @@ dbos/_core.py,sha256=nGiXyYgV8H5TRRZG0e8HCd5IZimufYQLmKNr7nBbwbo,36564
14
14
  dbos/_croniter.py,sha256=hbhgfsHBqclUS8VeLnJ9PSE9Z54z6mi4nnrr1aUXn0k,47561
15
15
  dbos/_db_wizard.py,sha256=xgKLna0_6Xi50F3o8msRosXba8NScHlpJR5ICVCkHDQ,7534
16
16
  dbos/_dbos.py,sha256=y5RgXPxdNsnketphphGMlaYZABFEQpr78UK-Xyja6dk,36216
17
- dbos/_dbos_config.py,sha256=h_q1gzudhsAMVkGMD0qQ6kLic6YhdJgzm50YFSIx9Bo,8196
17
+ dbos/_dbos_config.py,sha256=DfiqVVxNqnafkocSzLqBp1Ig5vCviDTDK_GO3zTtQqI,8298
18
18
  dbos/_error.py,sha256=vtaSsG0QW6cRlwfZ4zzZWy_IHCZlomwSlrDyGWuyn8c,4337
19
19
  dbos/_fastapi.py,sha256=ke03vqsSYDnO6XeOtOVFXj0-f-v1MGsOxa9McaROvNc,3616
20
20
  dbos/_flask.py,sha256=DZKUZR5-xOzPI7tYZ53r2PvvHVoAb8SYwLzMVFsVfjI,2608
@@ -41,7 +41,7 @@ dbos/_schemas/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
41
41
  dbos/_schemas/application_database.py,sha256=KeyoPrF7hy_ODXV7QNike_VFSD74QBRfQ76D7QyE9HI,966
42
42
  dbos/_schemas/system_database.py,sha256=rwp4EvCSaXcUoMaRczZCvETCxGp72k3-hvLyGUDkih0,5163
43
43
  dbos/_serialization.py,sha256=YCYv0qKAwAZ1djZisBC7khvKqG-5OcIv9t9EC5PFIog,1743
44
- dbos/_sys_db.py,sha256=dgRD6kMQWktxGSGUtw0ow1CJW4o6gsLdmpULvgQCago,56190
44
+ dbos/_sys_db.py,sha256=DLoSddcraHPUMiA5zWIck9Kes7_UO39RL2CRPqtYyz0,58247
45
45
  dbos/_templates/dbos-db-starter/README.md,sha256=GhxhBj42wjTt1fWEtwNriHbJuKb66Vzu89G4pxNHw2g,930
46
46
  dbos/_templates/dbos-db-starter/__package/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
47
47
  dbos/_templates/dbos-db-starter/__package/main.py,sha256=eI0SS9Nwj-fldtiuSzIlIG6dC91GXXwdRsoHxv6S_WI,2719
@@ -53,11 +53,11 @@ dbos/_templates/dbos-db-starter/migrations/script.py.mako,sha256=MEqL-2qATlST9TA
53
53
  dbos/_templates/dbos-db-starter/migrations/versions/2024_07_31_180642_init.py,sha256=U5thFWGqNN4QLrNXT7wUUqftIFDNE5eSdqD8JNW1mec,942
54
54
  dbos/_templates/dbos-db-starter/start_postgres_docker.py,sha256=lQVLlYO5YkhGPEgPqwGc7Y8uDKse9HsWv5fynJEFJHM,1681
55
55
  dbos/_tracer.py,sha256=rvBY1RQU6DO7rL7EnaJJxGcmd4tP_PpGqUEE6imZnhY,2518
56
- dbos/_workflow_commands.py,sha256=wVX_VdEM0qeuUQJWpdtEPY1RQ4C6quFPLSFtJGnvRi4,4272
56
+ dbos/_workflow_commands.py,sha256=gAynfrq5sAMhdNpMIphiAm_hC2-xk1ZyWEYA-whtfPs,5402
57
57
  dbos/cli/_github_init.py,sha256=Y_bDF9gfO2jB1id4FV5h1oIxEJRWyqVjhb7bNEa5nQ0,3224
58
58
  dbos/cli/_template_init.py,sha256=AfuMaO8bmr9WsPNHr6j2cp7kjVVZDUpH7KpbTg0hhFs,2722
59
- dbos/cli/cli.py,sha256=ZfOl5m791a113zjP94_P_a-qPl6wjBl4_tSfCIGAXK0,12404
59
+ dbos/cli/cli.py,sha256=_tXw2IQrWW7fV_h51f_R99vEBSi6aMLz-vCOxKaENiQ,14155
60
60
  dbos/dbos-config.schema.json,sha256=X5TpXNcARGceX0zQs0fVgtZW_Xj9uBbY5afPt9Rz9yk,5741
61
61
  dbos/py.typed,sha256=QfzXT1Ktfk3Rj84akygc7_42z0lRpCq0Ilh8OXI6Zas,44
62
62
  version/__init__.py,sha256=L4sNxecRuqdtSFdpUGX3TtBi9KL3k7YsZVIvv-fv9-A,1678
63
- dbos-0.21.0a4.dist-info/RECORD,,
63
+ dbos-0.21.0a5.dist-info/RECORD,,