dbos 0.23.0a5__py3-none-any.whl → 0.23.0a8__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/_croniter.py CHANGED
@@ -5,14 +5,14 @@ Copyright (C) 2010-2012 Matsumoto Taichi.
5
5
 
6
6
  Permission is hereby granted, free of charge, to any person obtaining a copy of this
7
7
  software and associated documentation files (the "Software"), to deal in the Software
8
- without restriction, including without limitation the rights to use, copy, modify,
8
+ without restriction, including without limitation the rights to use, copy, modify,
9
9
  merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
10
10
  persons to whom the Software is furnished to do so, subject to the following conditions:
11
11
 
12
12
  The above copyright notice and this permission notice shall be included in all
13
13
  copies or substantial portions of the Software.
14
14
 
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16
16
  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
17
17
  PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
18
18
  FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
@@ -2,7 +2,7 @@
2
2
  Add system tables.
3
3
 
4
4
  Revision ID: 5c361fc04708
5
- Revises:
5
+ Revises:
6
6
  Create Date: 2024-07-21 13:06:13.724602
7
7
  # mypy: allow-untyped-defs, allow-untyped-calls
8
8
  """
dbos/_sys_db.py CHANGED
@@ -14,9 +14,7 @@ from typing import (
14
14
  Optional,
15
15
  Sequence,
16
16
  Set,
17
- Tuple,
18
17
  TypedDict,
19
- cast,
20
18
  )
21
19
 
22
20
  import psycopg
@@ -126,6 +124,7 @@ class GetWorkflowsInput:
126
124
  self.offset: Optional[int] = (
127
125
  None # Offset into the matching records for pagination
128
126
  )
127
+ self.sort_desc: bool = False # If true, sort by created_at in DESC order. Default false (in ASC order).
129
128
 
130
129
 
131
130
  class GetQueuedWorkflowsInput(TypedDict):
@@ -136,6 +135,7 @@ class GetQueuedWorkflowsInput(TypedDict):
136
135
  limit: Optional[int] # Return up to this many workflows IDs.
137
136
  offset: Optional[int] # Offset into the matching records for pagination
138
137
  name: Optional[str] # The name of the workflow function
138
+ sort_desc: Optional[bool] # Sort by created_at in DESC or ASC order
139
139
 
140
140
 
141
141
  class GetWorkflowsOutput:
@@ -149,25 +149,6 @@ class GetPendingWorkflowsOutput:
149
149
  self.queue_name: Optional[str] = queue_name
150
150
 
151
151
 
152
- class WorkflowInformation(TypedDict, total=False):
153
- workflow_uuid: str
154
- status: WorkflowStatuses # The status of the workflow.
155
- name: str # The name of the workflow function.
156
- workflow_class_name: str # The class name holding the workflow function.
157
- workflow_config_name: (
158
- str # The name of the configuration, if the class needs configuration
159
- )
160
- authenticated_user: str # The user who ran the workflow. Empty string if not set.
161
- assumed_role: str
162
- # The role used to run this workflow. Empty string if authorization is not required.
163
- authenticated_roles: List[str]
164
- # All roles the authenticated user has, if any.
165
- input: Optional[_serialization.WorkflowInputs]
166
- output: Optional[str]
167
- error: Optional[str]
168
- request: Optional[str]
169
-
170
-
171
152
  _dbos_null_topic = "__null__topic__"
172
153
  _buffer_flush_batch_size = 100
173
154
  _buffer_flush_interval_secs = 1.0
@@ -637,9 +618,11 @@ class SystemDatabase:
637
618
  return inputs
638
619
 
639
620
  def get_workflows(self, input: GetWorkflowsInput) -> GetWorkflowsOutput:
640
- query = sa.select(SystemSchema.workflow_status.c.workflow_uuid).order_by(
641
- SystemSchema.workflow_status.c.created_at.asc()
642
- )
621
+ query = sa.select(SystemSchema.workflow_status.c.workflow_uuid)
622
+ if input.sort_desc:
623
+ query = query.order_by(SystemSchema.workflow_status.c.created_at.desc())
624
+ else:
625
+ query = query.order_by(SystemSchema.workflow_status.c.created_at.asc())
643
626
  if input.name:
644
627
  query = query.where(SystemSchema.workflow_status.c.name == input.name)
645
628
  if input.authenticated_user:
@@ -683,15 +666,15 @@ class SystemDatabase:
683
666
  self, input: GetQueuedWorkflowsInput
684
667
  ) -> GetWorkflowsOutput:
685
668
 
686
- query = (
687
- sa.select(SystemSchema.workflow_queue.c.workflow_uuid)
688
- .join(
689
- SystemSchema.workflow_status,
690
- SystemSchema.workflow_queue.c.workflow_uuid
691
- == SystemSchema.workflow_status.c.workflow_uuid,
692
- )
693
- .order_by(SystemSchema.workflow_status.c.created_at.asc())
669
+ query = sa.select(SystemSchema.workflow_queue.c.workflow_uuid).join(
670
+ SystemSchema.workflow_status,
671
+ SystemSchema.workflow_queue.c.workflow_uuid
672
+ == SystemSchema.workflow_status.c.workflow_uuid,
694
673
  )
674
+ if input["sort_desc"]:
675
+ query = query.order_by(SystemSchema.workflow_status.c.created_at.desc())
676
+ else:
677
+ query = query.order_by(SystemSchema.workflow_status.c.created_at.asc())
695
678
 
696
679
  if input.get("name"):
697
680
  query = query.where(SystemSchema.workflow_status.c.name == input["name"])
@@ -2,7 +2,7 @@
2
2
  Initialize application database.
3
3
 
4
4
  Revision ID: c6b516e182b2
5
- Revises:
5
+ Revises:
6
6
  Create Date: 2024-07-31 18:06:42.500040
7
7
  """
8
8
 
@@ -49,6 +49,7 @@ def list_workflows(
49
49
  name: Optional[str] = None,
50
50
  limit: Optional[int] = None,
51
51
  offset: Optional[int] = None,
52
+ sort_desc: bool = False,
52
53
  ) -> List[WorkflowInformation]:
53
54
  input = GetWorkflowsInput()
54
55
  input.workflow_ids = workflow_ids
@@ -61,6 +62,7 @@ def list_workflows(
61
62
  input.limit = limit
62
63
  input.name = name
63
64
  input.offset = offset
65
+ input.sort_desc = sort_desc
64
66
 
65
67
  output: GetWorkflowsOutput = sys_db.get_workflows(input)
66
68
  infos: List[WorkflowInformation] = []
@@ -82,6 +84,7 @@ def list_queued_workflows(
82
84
  name: Optional[str] = None,
83
85
  request: bool = False,
84
86
  offset: Optional[int] = None,
87
+ sort_desc: bool = False,
85
88
  ) -> List[WorkflowInformation]:
86
89
  input: GetQueuedWorkflowsInput = {
87
90
  "queue_name": queue_name,
@@ -91,6 +94,7 @@ def list_queued_workflows(
91
94
  "limit": limit,
92
95
  "name": name,
93
96
  "offset": offset,
97
+ "sort_desc": sort_desc,
94
98
  }
95
99
  output: GetWorkflowsOutput = sys_db.get_queued_workflows(input)
96
100
  infos: List[WorkflowInformation] = []
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dbos
3
- Version: 0.23.0a5
3
+ Version: 0.23.0a8
4
4
  Summary: Ultra-lightweight durable execution in Python
5
5
  Author-Email: "DBOS, Inc." <contact@dbos.dev>
6
6
  License: MIT
@@ -78,6 +78,9 @@ You can use DBOS to add reliable background jobs or cron scheduling or queues to
78
78
  Install and configure with:
79
79
 
80
80
  ```shell
81
+ python3 -m venv dbos-example/.venv
82
+ cd dbos-example
83
+ source .venv/bin/activate
81
84
  pip install dbos
82
85
  dbos init --config
83
86
  ```
@@ -103,7 +106,7 @@ def step_two():
103
106
  def dbos_workflow():
104
107
  step_one()
105
108
  for _ in range(5):
106
- print("Press Control + \ to stop the app...")
109
+ print("Press Control + C twice to stop the app...")
107
110
  DBOS.sleep(1)
108
111
  step_two()
109
112
 
@@ -114,7 +117,7 @@ def fastapi_endpoint():
114
117
 
115
118
  Save the program into `main.py` and start it with `fastapi run`.
116
119
  Visit `localhost:8000` in your browser to start the workflow.
117
- When prompted, press `Control + \` to force quit your application.
120
+ When prompted, press `Control + C` (You may need to press `Control + C` twice quickly, or press `Control + \`, if `Control + C` is not effective in your environment) to force quit your application.
118
121
  It should crash midway through the workflow, having completed step one but not step two.
119
122
  Then, restart your app with `fastapi run`.
120
123
  It should resume the workflow from where it left off, completing step two without re-executing step one.
@@ -1,7 +1,7 @@
1
- dbos-0.23.0a5.dist-info/METADATA,sha256=saWbNoKPc4hy7CWVchMo64BhlRX3rBrl8q49PC4GCAY,5309
2
- dbos-0.23.0a5.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
3
- dbos-0.23.0a5.dist-info/entry_points.txt,sha256=_QOQ3tVfEjtjBlr1jS4sHqHya9lI2aIEIWkz8dqYp14,58
4
- dbos-0.23.0a5.dist-info/licenses/LICENSE,sha256=VGZit_a5-kdw9WT6fY5jxAWVwGQzgLFyPWrcVVUhVNU,1067
1
+ dbos-0.23.0a8.dist-info/METADATA,sha256=BKJpwbpeqY4J_-TQ6XHnlBaUUNPpnk63uHr0R8Cht3M,5523
2
+ dbos-0.23.0a8.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
3
+ dbos-0.23.0a8.dist-info/entry_points.txt,sha256=_QOQ3tVfEjtjBlr1jS4sHqHya9lI2aIEIWkz8dqYp14,58
4
+ dbos-0.23.0a8.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=YiVn5lywz2Vg8_juyNHOYl0HVEy48--7b4phwK7r92o,5732
7
7
  dbos/_app_db.py,sha256=_tv2vmPjjiaikwgxH3mqxgJ4nUUcG2-0uMXKWCqVu1c,5509
@@ -11,7 +11,7 @@ dbos/_cloudutils/cloudutils.py,sha256=YC7jGsIopT0KveLsqbRpQk2KlRBk-nIRC_UCgep4f3
11
11
  dbos/_cloudutils/databases.py,sha256=_shqaqSvhY4n2ScgQ8IP5PDZvzvcx3YBKV8fj-cxhSY,8543
12
12
  dbos/_context.py,sha256=Ue5qu3rzLfRmPkz-UUZi9ZS8iXpapRN0NTM4mbA2QmQ,17738
13
13
  dbos/_core.py,sha256=MWIa8r-KwnadYQtGSod2KdAaeQ4gTJAUMPhMGaM0u2c,36613
14
- dbos/_croniter.py,sha256=hbhgfsHBqclUS8VeLnJ9PSE9Z54z6mi4nnrr1aUXn0k,47561
14
+ dbos/_croniter.py,sha256=XHAyUyibs_59sJQfSNWkP7rqQY6_XrlfuuCxk4jYqek,47559
15
15
  dbos/_db_wizard.py,sha256=6tfJaCRa1NtkUdNW75a2yvi_mEgnPJ9C1HP2zPG1hCU,8067
16
16
  dbos/_dbos.py,sha256=JNAFYQ3kVjnZsUl0qJ-JWeaSHKI51VGE3JBXdaPD8Oo,39054
17
17
  dbos/_dbos_config.py,sha256=DfiqVVxNqnafkocSzLqBp1Ig5vCviDTDK_GO3zTtQqI,8298
@@ -25,7 +25,7 @@ dbos/_migrations/env.py,sha256=38SIGVbmn_VV2x2u1aHLcPOoWgZ84eCymf3g_NljmbU,1626
25
25
  dbos/_migrations/script.py.mako,sha256=MEqL-2qATlST9TAOeYgscMn1uy6HUS9NFvDgl93dMj8,635
26
26
  dbos/_migrations/versions/04ca4f231047_workflow_queues_executor_id.py,sha256=ICLPl8CN9tQXMsLDsAj8z1TsL831-Z3F8jSBvrR-wyw,736
27
27
  dbos/_migrations/versions/50f3227f0b4b_fix_job_queue.py,sha256=ZBYrtTdxy64HxIAlOes89fVIk2P1gNaJack7wuC_epg,873
28
- dbos/_migrations/versions/5c361fc04708_added_system_tables.py,sha256=QMgFMb0aLgC25YicsvPSr6AHRCA6Zd66hyaRUhwKzrQ,6404
28
+ dbos/_migrations/versions/5c361fc04708_added_system_tables.py,sha256=Xr9hBDJjkAtymlauOmAy00yUHj0VVUaEz7kNwEM9IwE,6403
29
29
  dbos/_migrations/versions/a3b18ad34abe_added_triggers.py,sha256=Rv0ZsZYZ_WdgGEULYsPfnp4YzaO5L198gDTgYY39AVA,2022
30
30
  dbos/_migrations/versions/d76646551a6b_job_queue_limiter.py,sha256=8PyFi8rd6CN-mUro43wGhsg5wcQWKZPRHD6jw8R5pVc,986
31
31
  dbos/_migrations/versions/d76646551a6c_workflow_queue.py,sha256=G942nophZ2uC2vc4hGBC02Ptng1715roTjY3xiyzZU4,729
@@ -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=tyBQicOkkf563CU83MwZubENpI5AmCYFyz2tSbQ9XQ4,61045
44
+ dbos/_sys_db.py,sha256=9Knaq-zsnTebFx0vS6vIwxL-tFITpUf7Bh-xUSB7cyE,60637
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
@@ -50,15 +50,15 @@ dbos/_templates/dbos-db-starter/alembic.ini,sha256=VKBn4Gy8mMuCdY7Hip1jmo3wEUJ1V
50
50
  dbos/_templates/dbos-db-starter/dbos-config.yaml.dbos,sha256=OMlcpdYUJKjyAme7phOz3pbn9upcIRjm42iwEThWUEQ,495
51
51
  dbos/_templates/dbos-db-starter/migrations/env.py.dbos,sha256=GUV6sjkDzf9Vl6wkGEd0RSkK-ftRfV6EUwSQdd0qFXg,2392
52
52
  dbos/_templates/dbos-db-starter/migrations/script.py.mako,sha256=MEqL-2qATlST9TAOeYgscMn1uy6HUS9NFvDgl93dMj8,635
53
- dbos/_templates/dbos-db-starter/migrations/versions/2024_07_31_180642_init.py,sha256=U5thFWGqNN4QLrNXT7wUUqftIFDNE5eSdqD8JNW1mec,942
53
+ dbos/_templates/dbos-db-starter/migrations/versions/2024_07_31_180642_init.py,sha256=MpS7LGaJS0CpvsjhfDkp9EJqvMvVCjRPfUp4c0aE2ys,941
54
54
  dbos/_templates/dbos-db-starter/start_postgres_docker.py,sha256=lQVLlYO5YkhGPEgPqwGc7Y8uDKse9HsWv5fynJEFJHM,1681
55
55
  dbos/_tracer.py,sha256=_Id9j9kCrptSNpEpLiRk_g5VPp-DrTWP1WNZInd5BA4,2439
56
56
  dbos/_utils.py,sha256=wjOJzxN66IzL9p4dwcEmQACRQah_V09G6mJI2exQfOM,155
57
- dbos/_workflow_commands.py,sha256=ZAdVccVuSFlcZ_kEdo6MwQ9xaslVXn_MMRTybJlkyQw,4652
57
+ dbos/_workflow_commands.py,sha256=Z1PwprvR_A8PXV2FNhcMrvV8B4NlDI9dc5naMeeNKGw,4774
58
58
  dbos/cli/_github_init.py,sha256=Y_bDF9gfO2jB1id4FV5h1oIxEJRWyqVjhb7bNEa5nQ0,3224
59
59
  dbos/cli/_template_init.py,sha256=AfuMaO8bmr9WsPNHr6j2cp7kjVVZDUpH7KpbTg0hhFs,2722
60
60
  dbos/cli/cli.py,sha256=BJWFT94I14uKTmMYSI4ITscPMBgidgjV0RBx5_LyNKI,14849
61
61
  dbos/dbos-config.schema.json,sha256=X5TpXNcARGceX0zQs0fVgtZW_Xj9uBbY5afPt9Rz9yk,5741
62
62
  dbos/py.typed,sha256=QfzXT1Ktfk3Rj84akygc7_42z0lRpCq0Ilh8OXI6Zas,44
63
63
  version/__init__.py,sha256=L4sNxecRuqdtSFdpUGX3TtBi9KL3k7YsZVIvv-fv9-A,1678
64
- dbos-0.23.0a5.dist-info/RECORD,,
64
+ dbos-0.23.0a8.dist-info/RECORD,,