Skip to content

Commit 85da3a5

Browse files
committed
Enhance logging and testing configuration
- Updated logging format in `runtime.py` to include the logger's name for better context in log messages. - Changed info log statements to debug level for state manager URI and API key fallback, reducing log verbosity. - Added pytest configuration options in `pyproject.toml` to specify asyncio mode and test paths, improving test execution setup.
1 parent 64fa183 commit 85da3a5

2 files changed

Lines changed: 15 additions & 8 deletions

File tree

python-sdk/exospherehost/runtime.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def _setup_default_logging():
3333
# Setup basic configuration with clean formatting
3434
logging.basicConfig(
3535
level=log_level,
36-
format='%(asctime)s | %(levelname)s | %(message)s',
36+
format='%(asctime)s | %(levelname)s | %(name)s | %(message)s',
3737
datefmt='%Y-%m-%d %H:%M:%S'
3838
)
3939

@@ -107,10 +107,10 @@ def _set_config_from_env(self):
107107
Set configuration from environment variables if not provided.
108108
"""
109109
if self._state_manager_uri is None:
110-
logger.info("State manager URI not provided, using environment variable EXOSPHERE_STATE_MANAGER_URI")
110+
logger.debug("State manager URI not provided, falling back to environment variable EXOSPHERE_STATE_MANAGER_URI")
111111
self._state_manager_uri = os.environ.get("EXOSPHERE_STATE_MANAGER_URI")
112112
if self._key is None:
113-
logger.info("API key not provided, using environment variable EXOSPHERE_API_KEY")
113+
logger.debug("API key not provided, falling back to environment variable EXOSPHERE_API_KEY")
114114
self._key = os.environ.get("EXOSPHERE_API_KEY")
115115

116116
def _validate_runtime(self):
@@ -233,8 +233,9 @@ async def _enqueue(self):
233233
logger.info(f"Enqueued states: {len(data.get('states', []))}")
234234
except Exception as e:
235235
logger.error(f"Error enqueuing states: {e}")
236-
raise
237-
236+
await sleep(self._poll_interval * 2)
237+
continue
238+
238239
await sleep(self._poll_interval)
239240

240241
async def _notify_executed(self, state_id: str, outputs: List[BaseNode.Outputs]):
@@ -256,7 +257,6 @@ async def _notify_executed(self, state_id: str, outputs: List[BaseNode.Outputs])
256257
if response.status != 200:
257258
logger.error(f"Failed to notify executed state {state_id}: {res}")
258259

259-
logger.info(f"Notified executed state {state_id} with outputs: {outputs} for node {self._node_mapping[state_id].__name__}")
260260

261261
async def _notify_errored(self, state_id: str, error: str):
262262
"""
@@ -277,7 +277,6 @@ async def _notify_errored(self, state_id: str, error: str):
277277
if response.status != 200:
278278
logger.error(f"Failed to notify errored state {state_id}: {res}")
279279

280-
logger.info(f"Notified errored state {state_id} with error: {error} for node {self._node_mapping[state_id].__name__}")
281280

282281
async def _get_secrets(self, state_id: str) -> Dict[str, str]:
283282
"""
@@ -364,6 +363,7 @@ async def _worker(self, idx: int):
364363

365364
while True:
366365
state = await self._state_queue.get()
366+
node = None
367367

368368
try:
369369
node = self._node_mapping[state["node_name"]]
@@ -382,12 +382,14 @@ async def _worker(self, idx: int):
382382
outputs = [outputs]
383383

384384
await self._notify_executed(state["state_id"], outputs)
385+
logger.info(f"Notified executed state {state['state_id']} for node {node.__name__ if node else "unknown"}")
385386

386387
except Exception as e:
387-
logger.error(f"Error executing state {state['state_id']} for node {node.__name__}: {e}")
388+
logger.error(f"Error executing state {state['state_id']} for node {node.__name__ if node else "unknown"}: {e}")
388389
logger.error(traceback.format_exc())
389390

390391
await self._notify_errored(state["state_id"], str(e))
392+
logger.info(f"Notified errored state {state['state_id']} for node {node.__name__ if node else "unknown"}")
391393

392394
self._state_queue.task_done() # type: ignore
393395

python-sdk/pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,8 @@ dev = [
3535
"pytest-cov>=5.0.0",
3636
"pytest-asyncio>=0.24.0",
3737
]
38+
39+
[tool.pytest.ini_options]
40+
asyncio_mode = "auto"
41+
addopts = "-ra"
42+
testpaths = ["tests"]

0 commit comments

Comments
 (0)