dbos 0.25.0a16__py3-none-any.whl → 0.26.0__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.
dbos/_registrations.py CHANGED
@@ -34,6 +34,7 @@ def set_temp_workflow_type(f: Any, name: TempWorkflowType) -> None:
34
34
 
35
35
  @dataclass
36
36
  class DBOSClassInfo:
37
+ registered_name: str
37
38
  def_required_roles: Optional[List[str]] = None
38
39
 
39
40
 
@@ -50,14 +51,20 @@ class DBOSFuncInfo:
50
51
  class_info: Optional[DBOSClassInfo] = None
51
52
  func_type: DBOSFuncType = DBOSFuncType.Unknown
52
53
  required_roles: Optional[List[str]] = None
53
- max_recovery_attempts: int = DEFAULT_MAX_RECOVERY_ATTEMPTS
54
+ max_recovery_attempts: Optional[int] = DEFAULT_MAX_RECOVERY_ATTEMPTS
54
55
 
55
56
 
56
- def get_or_create_class_info(cls: Type[Any]) -> DBOSClassInfo:
57
+ def get_or_create_class_info(
58
+ cls: Type[Any], provided_name: Optional[str] = None
59
+ ) -> DBOSClassInfo:
57
60
  if hasattr(cls, "dbos_class_decorator_info"):
58
61
  ci: DBOSClassInfo = getattr(cls, "dbos_class_decorator_info")
59
62
  return ci
60
- ci = DBOSClassInfo()
63
+ class_name = _class_fqn(cls)
64
+ # Use the provided name instead of the class name if it is not None
65
+ if provided_name is not None:
66
+ class_name = provided_name
67
+ ci = DBOSClassInfo(registered_name=class_name)
61
68
  setattr(cls, "dbos_class_decorator_info", ci)
62
69
 
63
70
  # Tell all DBOS functions about this
@@ -166,16 +173,24 @@ def get_config_name(
166
173
  return None
167
174
 
168
175
 
176
+ def _class_fqn(cls: type) -> str:
177
+ """Returns the registered name of the given class. If the class name was not overridden at registration time, it returns the qualified name of the class."""
178
+ ci = get_class_info(cls)
179
+ if ci is not None:
180
+ return ci.registered_name
181
+ return cls.__qualname__
182
+
183
+
169
184
  def get_dbos_class_name(
170
185
  fi: Optional[DBOSFuncInfo], func: Callable[..., Any], args: Tuple[Any, ...]
171
186
  ) -> Optional[str]:
172
187
  if fi and fi.func_type != DBOSFuncType.Unknown and len(args) > 0:
173
188
  if fi.func_type == DBOSFuncType.Instance:
174
189
  first_arg = args[0]
175
- return str(first_arg.__class__.__name__)
190
+ return _class_fqn(first_arg.__class__)
176
191
  if fi.func_type == DBOSFuncType.Class:
177
192
  first_arg = args[0]
178
- return str(first_arg.__name__)
193
+ return _class_fqn(first_arg)
179
194
  return None
180
195
 
181
196
  # Check for improperly-registered functions
dbos/_scheduler.py CHANGED
@@ -52,7 +52,7 @@ def scheduled(
52
52
  )
53
53
 
54
54
  global scheduler_queue
55
- scheduler_queue = Queue("_dbos_internal_queue")
55
+ scheduler_queue = dbosreg.get_internal_queue()
56
56
  stop_event = threading.Event()
57
57
  dbosreg.register_poller(stop_event, scheduler_loop, func, cron, stop_event)
58
58
  return func
@@ -25,6 +25,7 @@ class ApplicationSchema:
25
25
  Column("txn_id", Text, nullable=True),
26
26
  Column("txn_snapshot", Text),
27
27
  Column("executor_id", Text, nullable=True),
28
+ Column("function_name", Text, nullable=False, server_default=""),
28
29
  Column(
29
30
  "created_at",
30
31
  BigInteger,
@@ -54,7 +54,9 @@ class SystemSchema:
54
54
  nullable=True,
55
55
  server_default=text("'0'::bigint"),
56
56
  ),
57
- Column("queue_name", Text),
57
+ Column("queue_name", Text, nullable=True),
58
+ Column("workflow_timeout_ms", BigInteger, nullable=True),
59
+ Column("workflow_deadline_epoch_ms", BigInteger, nullable=True),
58
60
  Index("workflow_status_created_at_index", "created_at"),
59
61
  Index("workflow_status_executor_id_index", "executor_id"),
60
62
  )