Skip to content

Commit

Permalink
Fix stdout/err log errors introduced by PR #3347 (#3379)
Browse files Browse the repository at this point in the history
PR #3347 attempted to do case-based logging of all the different kinds
of stdout/err specification.

It failed to capture some of the cases involving os.PathLike, and so
after PR #3347, those cases would log an ERROR that the specification
was unknown. This new behavior is only a new ERROR logging message -
PR #3347 did not change other behaviour.

This PR also amends a rich test of stdout/err specification types
introduced in PR #3363 to check that no ERROR messages are logged during
these tests.
  • Loading branch information
benclifford authored Apr 22, 2024
1 parent cd05bf9 commit f07535e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion parsl/dataflow/dflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1426,8 +1426,12 @@ def log_std_stream(name: str, target) -> None:
logger.info(f"{name} for task {tid} will not be redirected.")
elif isinstance(target, str):
logger.info(f"{name} for task {tid} will be redirected to {target}")
elif isinstance(target, tuple) and len(target) == 2:
elif isinstance(target, os.PathLike):
logger.info(f"{name} for task {tid} will be redirected to {os.fspath(target)}")
elif isinstance(target, tuple) and len(target) == 2 and isinstance(target[0], str):
logger.info(f"{name} for task {tid} will be redirected to {target[0]} with mode {target[1]}")
elif isinstance(target, tuple) and len(target) == 2 and isinstance(target[0], os.PathLike):
logger.info(f"{name} for task {tid} will be redirected to {os.fspath(target[0])} with mode {target[1]}")
elif isinstance(target, DataFuture):
logger.info(f"{name} for task {tid} will staged to {target.file_obj.url}")
else:
Expand Down
6 changes: 5 additions & 1 deletion parsl/tests/test_monitoring/test_stdouterr.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Tests monitoring records app name under various decoration patterns.
"""

import logging
import os
import parsl
import pytest
Expand Down Expand Up @@ -55,7 +56,7 @@ def can_stage_out(self, file):
(File("file:///tmp/pl5"), "file:///tmp/pl5"),
])
@pytest.mark.parametrize('stream', ['stdout', 'stderr'])
def test_stdstream_to_monitoring(stdx, expected_stdx, stream, tmpd_cwd):
def test_stdstream_to_monitoring(stdx, expected_stdx, stream, tmpd_cwd, caplog):
"""This tests that various forms of stdout/err specification are
represented in monitoring correctly. The stderr and stdout codepaths
are generally duplicated, rather than factorised, and so this test
Expand Down Expand Up @@ -106,3 +107,6 @@ def count_rows(table: str):
assert expected_stdx(c)
else:
raise RuntimeError("Bad expected_stdx value")

for record in caplog.records:
assert record.levelno < logging.ERROR

0 comments on commit f07535e

Please sign in to comment.