Give a node's fluksio module the logger the SDK exports
Inside a worker `import fluksio` is the reporter, which had emit and the artifact calls but no logger — so `fluksio.logger.info(...)`, written against the SDK's top-level export, died with AttributeError after the training it was reporting on had already succeeded. Its records go to the same capture a print does; the handler resolves sys.stderr per record because a call runs under redirect_stderr. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019Hra4ndWMCLU5F3KjUuVAc
This commit is contained in:
@@ -69,6 +69,24 @@ def test_a_node_returns_its_value_and_what_it_printed(pool, capsys):
|
||||
assert "seen 21" in capsys.readouterr().out
|
||||
|
||||
|
||||
def test_a_node_can_log_through_the_module_it_imports(pool, capsys):
|
||||
"""The SDK exports `logger`; inside a worker `fluksio` is the reporter.
|
||||
|
||||
Without it, `fluksio.logger.info(...)` died with AttributeError — after
|
||||
the training it was reporting on had already succeeded.
|
||||
"""
|
||||
result = run(
|
||||
pool,
|
||||
"import fluksio\n\n\n"
|
||||
"def process(value):\n"
|
||||
" fluksio.logger.info('tuned %s', value)\n"
|
||||
" return {'out': value}\n",
|
||||
value=7,
|
||||
)
|
||||
assert result == {"out": 7}
|
||||
assert "tuned 7" in capsys.readouterr().out
|
||||
|
||||
|
||||
def test_a_failure_keeps_its_class_and_points_at_the_node(pool):
|
||||
with pytest.raises(Exception) as caught:
|
||||
run(pool, "def process():\n raise ValueError('bad input')\n")
|
||||
|
||||
Reference in New Issue
Block a user