dbos 0.5.0a5__py3-none-any.whl → 0.5.0a7__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.py CHANGED
@@ -72,7 +72,7 @@ from dbos.error import DBOSException, DBOSNonExistentWorkflowError
72
72
 
73
73
  from .application_database import ApplicationDatabase
74
74
  from .dbos_config import ConfigFile, load_config, set_env_vars
75
- from .logger import config_logger, dbos_logger, init_logger
75
+ from .logger import add_otlp_to_all_loggers, config_logger, dbos_logger, init_logger
76
76
  from .system_database import SystemDatabase
77
77
 
78
78
  # Most DBOS functions are just any callable F, so decorators / wrappers work on F
@@ -204,7 +204,6 @@ class DBOS:
204
204
  cls: Type[DBOS],
205
205
  fastapi: Optional["FastAPI"] = None,
206
206
  config: Optional[ConfigFile] = None,
207
- launch: bool = True,
208
207
  ) -> DBOS:
209
208
  global _dbos_global_instance
210
209
  global _dbos_global_registry
@@ -219,7 +218,7 @@ class DBOS:
219
218
  )
220
219
  config = _dbos_global_registry.config
221
220
  _dbos_global_instance = super().__new__(cls)
222
- _dbos_global_instance.__init__(fastapi=fastapi, config=config, launch=launch) # type: ignore
221
+ _dbos_global_instance.__init__(fastapi=fastapi, config=config) # type: ignore
223
222
  else:
224
223
  if (config is not None and _dbos_global_instance.config is not config) or (
225
224
  _dbos_global_instance.fastapi is not fastapi
@@ -242,7 +241,6 @@ class DBOS:
242
241
  self,
243
242
  fastapi: Optional["FastAPI"] = None,
244
243
  config: Optional[ConfigFile] = None,
245
- launch: bool = True,
246
244
  ) -> None:
247
245
  if hasattr(self, "_initialized") and self._initialized:
248
246
  return
@@ -270,7 +268,6 @@ class DBOS:
270
268
 
271
269
  setup_fastapi_middleware(self.fastapi)
272
270
  self.fastapi.on_event("startup")(self.launch)
273
- launch = False
274
271
 
275
272
  # Register send_stub as a workflow
276
273
  def send_temp_workflow(
@@ -283,8 +280,8 @@ class DBOS:
283
280
  set_temp_workflow_type(send_temp_workflow, "send")
284
281
  self._registry.register_wf_function(TEMP_SEND_WF_NAME, temp_send_wf)
285
282
 
286
- if launch:
287
- self.launch()
283
+ for handler in dbos_logger.handlers:
284
+ handler.flush()
288
285
 
289
286
  @property
290
287
  def executor(self) -> ThreadPoolExecutor:
@@ -342,9 +339,13 @@ class DBOS:
342
339
  self.executor.submit(func, *args, **kwargs)
343
340
  self._registry.pollers = []
344
341
 
345
- dbos_logger.info("DBOS initialized")
342
+ dbos_logger.info("DBOS launched")
343
+
344
+ # Flush handlers and add OTLP to all loggers if enabled
345
+ # to enable their export in DBOS Cloud
346
346
  for handler in dbos_logger.handlers:
347
347
  handler.flush()
348
+ add_otlp_to_all_loggers()
348
349
 
349
350
  def _destroy(self) -> None:
350
351
  self._initialized = False
dbos/logger.py CHANGED
@@ -12,6 +12,7 @@ if TYPE_CHECKING:
12
12
  from dbos.dbos_config import ConfigFile
13
13
 
14
14
  dbos_logger = logging.getLogger("dbos")
15
+ otlp_handler, otlp_transformer = None, None
15
16
 
16
17
 
17
18
  class DBOSLogTransformer(logging.Filter):
@@ -73,25 +74,28 @@ def config_logger(config: "ConfigFile") -> None:
73
74
  export_timeout_millis=5000,
74
75
  )
75
76
  )
77
+ global otlp_handler
76
78
  otlp_handler = LoggingHandler(logger_provider=log_provider)
77
79
 
78
80
  # Attach DBOS-specific attributes to all log entries.
81
+ global otlp_transformer
79
82
  otlp_transformer = DBOSLogTransformer()
80
83
 
81
- # Direct all logs to OTLP
82
- add_otlp_to_all_loggers(otlp_handler, otlp_transformer)
84
+ # Direct DBOS logs to OTLP
85
+ dbos_logger.addHandler(otlp_handler)
86
+ dbos_logger.addFilter(otlp_transformer)
83
87
 
84
88
 
85
- def add_otlp_to_all_loggers(
86
- otlp_handler: LoggingHandler, otlp_transformer: DBOSLogTransformer
87
- ) -> None:
88
- root = logging.root
89
+ def add_otlp_to_all_loggers() -> None:
90
+ if otlp_handler is not None and otlp_transformer is not None:
91
+ root = logging.root
89
92
 
90
- root.addHandler(otlp_handler)
91
- root.addFilter(otlp_transformer)
93
+ root.addHandler(otlp_handler)
94
+ root.addFilter(otlp_transformer)
92
95
 
93
- for logger_name in root.manager.loggerDict:
94
- logger = logging.getLogger(logger_name)
95
- if not logger.propagate:
96
- logger.addHandler(otlp_handler)
97
- logger.addFilter(otlp_transformer)
96
+ for logger_name in root.manager.loggerDict:
97
+ if logger_name != dbos_logger.name:
98
+ logger = logging.getLogger(logger_name)
99
+ if not logger.propagate:
100
+ logger.addHandler(otlp_handler)
101
+ logger.addFilter(otlp_transformer)
dbos/system_database.py CHANGED
@@ -734,7 +734,6 @@ class SystemDatabase:
734
734
  )
735
735
  notification_cursor = self.notification_conn.cursor()
736
736
 
737
- dbos_logger.info("Listening to notifications")
738
737
  notification_cursor.execute("LISTEN dbos_notifications_channel")
739
738
  notification_cursor.execute("LISTEN dbos_workflow_events_channel")
740
739
  while self._run_background_processes:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dbos
3
- Version: 0.5.0a5
3
+ Version: 0.5.0a7
4
4
  Summary: A Python framework for backends that scale
5
5
  Author-Email: "DBOS, Inc." <contact@dbos.dev>
6
6
  License: MIT
@@ -1,7 +1,7 @@
1
- dbos-0.5.0a5.dist-info/METADATA,sha256=WRKFIucNawLOnizlrKNBp1cTcYW2BcuIcaYaQjXq1FU,5420
2
- dbos-0.5.0a5.dist-info/WHEEL,sha256=rSwsxJWe3vzyR5HCwjWXQruDgschpei4h_giTm0dJVE,90
3
- dbos-0.5.0a5.dist-info/entry_points.txt,sha256=3PmOPbM4FYxEmggRRdJw0oAsiBzKR8U0yx7bmwUmMOM,39
4
- dbos-0.5.0a5.dist-info/licenses/LICENSE,sha256=VGZit_a5-kdw9WT6fY5jxAWVwGQzgLFyPWrcVVUhVNU,1067
1
+ dbos-0.5.0a7.dist-info/METADATA,sha256=LdnWhAfO7Lnl85g-bvhXhoFYrCHkz7Jxmj_yqEKpPVc,5420
2
+ dbos-0.5.0a7.dist-info/WHEEL,sha256=rSwsxJWe3vzyR5HCwjWXQruDgschpei4h_giTm0dJVE,90
3
+ dbos-0.5.0a7.dist-info/entry_points.txt,sha256=3PmOPbM4FYxEmggRRdJw0oAsiBzKR8U0yx7bmwUmMOM,39
4
+ dbos-0.5.0a7.dist-info/licenses/LICENSE,sha256=VGZit_a5-kdw9WT6fY5jxAWVwGQzgLFyPWrcVVUhVNU,1067
5
5
  dbos/__init__.py,sha256=X1LdP36NomDtvPfFwoMNtgXf81TO05jj7vltsp79UUw,787
6
6
  dbos/admin_sever.py,sha256=KtzH6aKyskCm4h3yulpy9jb5PIqRlYI2sjctw5mvaKY,3395
7
7
  dbos/application_database.py,sha256=1K3kE96BgGi_QWOd2heXluyNTwFAwlUVuAR6JKKUqf0,5659
@@ -9,12 +9,12 @@ dbos/cli.py,sha256=QnbGtZ8S963q3iyFvXNBcL4DB35r4SFMarlb5DRqN6M,7915
9
9
  dbos/context.py,sha256=JZMV2RtSpTK7lnyyWxeBmGPwrZSB00XZEP6R6MT9ygQ,15690
10
10
  dbos/core.py,sha256=HfKnPpIaQqIBAHzP2hD67aSIchTHp87NgD21CcujKkE,28300
11
11
  dbos/dbos-config.schema.json,sha256=azpfmoDZg7WfSy3kvIsk9iEiKB_-VZt03VEOoXJAkqE,5331
12
- dbos/dbos.py,sha256=HngS2BUWSbWPmloXGr-KE81BQ8dpZtlvOXM4tx4_Qhg,26246
12
+ dbos/dbos.py,sha256=-zrxmo_yN4vPTKQdyDtAcGlZI4-RV4PZBiIFayNSHyI,26342
13
13
  dbos/dbos_config.py,sha256=EkO0c0xaIM7_vAAqqnvNNEAKG5fOJbmmalqnZvaKYZA,5312
14
14
  dbos/decorators.py,sha256=lbPefsLK6Cya4cb7TrOcLglOpGT3pc6qjZdsQKlfZLg,629
15
15
  dbos/error.py,sha256=nBdLC4hxGO_K9V26YbDGOo7xi1CKuN4PsE_cBv7K8Cc,3798
16
16
  dbos/fastapi.py,sha256=ZFcMizyv3pizo5zf0sSF6U4GoR3rQH8LxGipkQIGHfU,2282
17
- dbos/logger.py,sha256=cfybbu6F1zsgYLEPW8D8V6h033u-YedLXnGMnQQM6-4,3341
17
+ dbos/logger.py,sha256=D-aFSZUCHBP34J1IZ5YNkTrJW-rDiH3py_v9jLU4Yrk,3565
18
18
  dbos/migrations/env.py,sha256=38SIGVbmn_VV2x2u1aHLcPOoWgZ84eCymf3g_NljmbU,1626
19
19
  dbos/migrations/script.py.mako,sha256=MEqL-2qATlST9TAOeYgscMn1uy6HUS9NFvDgl93dMj8,635
20
20
  dbos/migrations/versions/5c361fc04708_added_system_tables.py,sha256=QMgFMb0aLgC25YicsvPSr6AHRCA6Zd66hyaRUhwKzrQ,6404
@@ -28,7 +28,7 @@ dbos/scheduler/scheduler.py,sha256=uO4_9jmWW2rLv1ODL3lc1cE_37ZaVTgnvmFx_FAlN50,1
28
28
  dbos/schemas/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
29
  dbos/schemas/application_database.py,sha256=q_Wr2XbiZNBYFkOtu7uKavo1T_cSOBblxKGHThYGGsY,962
30
30
  dbos/schemas/system_database.py,sha256=5V3vqnEzry0Hn7ZbVS9Gs_dJKia8uX8p7mGC82Ru8rk,4303
31
- dbos/system_database.py,sha256=SK24Avj10rbbWFilVUexdPX6VvOL8zC-CoWDhNQj6QM,39698
31
+ dbos/system_database.py,sha256=84c53iAel113SRb7DcgFJ8XQNWBhD4VrCRCb0s5Oe8Y,39635
32
32
  dbos/templates/hello/README.md,sha256=GhxhBj42wjTt1fWEtwNriHbJuKb66Vzu89G4pxNHw2g,930
33
33
  dbos/templates/hello/__package/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
34
  dbos/templates/hello/__package/main.py,sha256=hJgp3S14cseT7zWIZsPwjqdzwTCw1aLo8kPKsTvYz0Y,2976
@@ -42,4 +42,4 @@ dbos/templates/hello/start_postgres_docker.py,sha256=lQVLlYO5YkhGPEgPqwGc7Y8uDKs
42
42
  dbos/tracer.py,sha256=RPW9oxmX9tSc0Yq7O-FAhpQWBg1QT7Ni1Q06uwhtNDk,2237
43
43
  dbos/utils.py,sha256=hWj9iWDrby2cVEhb0pG-IdnrxLqP64NhkaWUXiLc8bA,402
44
44
  version/__init__.py,sha256=L4sNxecRuqdtSFdpUGX3TtBi9KL3k7YsZVIvv-fv9-A,1678
45
- dbos-0.5.0a5.dist-info/RECORD,,
45
+ dbos-0.5.0a7.dist-info/RECORD,,
File without changes