Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ environment variables:
DUCT_REPORT_INTERVAL=120.0

# Set default output location
DUCT_OUTPUT_PREFIX=~/duct-logs/{datetime_filesafe}-{pid}_
DUCT_OUTPUT_PREFIX=~/duct-logs/{datetime}-{pid}_

# Add execution notes (multiline)
DUCT_MESSAGE="Experiment run for paper revision
Expand Down Expand Up @@ -173,11 +173,10 @@ options:
File string format to be used as a prefix for the
files -- the captured stdout and stderr and the
resource usage logs. The understood variables are
{datetime}, {datetime_filesafe}, and {pid}. Leading
directories will be created if they do not exist. You
can also provide value via DUCT_OUTPUT_PREFIX env
variable. (default:
.duct/logs/{datetime_filesafe}-{pid}_)
{datetime} and {pid}. Leading directories will be
created if they do not exist. You can also provide
value via DUCT_OUTPUT_PREFIX env variable. (default:
.duct/logs/{datetime}-{pid}_)
--summary-format SUMMARY_FORMAT
Output template to use when printing the summary
following execution. Accepts custom conversion flags:
Expand Down
4 changes: 1 addition & 3 deletions src/con_duct/_duct_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@

lgr = logging.getLogger("con-duct")

DUCT_OUTPUT_PREFIX = os.getenv(
"DUCT_OUTPUT_PREFIX", ".duct/logs/{datetime_filesafe}-{pid}_"
)
DUCT_OUTPUT_PREFIX = os.getenv("DUCT_OUTPUT_PREFIX", ".duct/logs/{datetime}-{pid}_")
EXECUTION_SUMMARY_FORMAT = (
"Summary:\n"
"Exit Code: {exit_code!E}\n"
Expand Down
7 changes: 6 additions & 1 deletion src/con_duct/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,12 @@ def __iter__(self) -> Iterator[tuple[str, str]]:
def create(cls, output_prefix: str, pid: None | int = None) -> LogPaths:
datetime_filesafe = datetime.now().strftime("%Y.%m.%dT%H.%M.%S")
formatted_prefix = output_prefix.format(
pid=pid, datetime_filesafe=datetime_filesafe
pid=pid,
datetime=datetime_filesafe,
# Use of the `datetime_filesafe` format field is deprecated.
# The setting of it here is to provide for backwards compatibility
# It should be removed eventually
datetime_filesafe=datetime_filesafe,
)
return cls(
stdout=f"{formatted_prefix}{SUFFIXES['stdout']}",
Expand Down
4 changes: 2 additions & 2 deletions src/con_duct/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def _replay_early_logs(log_buffer: List[tuple[str, str]]) -> None:
DUCT_REPORT_INTERVAL=120.0

# Set default output location
DUCT_OUTPUT_PREFIX=~/duct-logs/{{datetime_filesafe}}-{{pid}}_
DUCT_OUTPUT_PREFIX=~/duct-logs/{{datetime}}-{{pid}}_

# Add execution notes (multiline)
DUCT_MESSAGE="Experiment run for paper revision
Expand Down Expand Up @@ -267,7 +267,7 @@ def _create_run_parser() -> argparse.ArgumentParser:
default=DUCT_OUTPUT_PREFIX,
help="File string format to be used as a prefix for the files -- the captured "
"stdout and stderr and the resource usage logs. The understood variables are "
"{datetime}, {datetime_filesafe}, and {pid}. "
"{datetime} and {pid}. "
"Leading directories will be created if they do not exist. "
"You can also provide value via DUCT_OUTPUT_PREFIX env variable. ",
)
Expand Down
10 changes: 9 additions & 1 deletion test/duct_main/test_log_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@
from con_duct._models import LogPaths, Outputs


def test_log_paths_filesafe_datetime_prefix() -> None:
def test_log_paths_datetime_prefix() -> None:
log_paths = LogPaths.create("start_{datetime}")
pattern = r"^start_\d{4}\.\d{2}\.\d{2}T\d{2}\.\d{2}\.\d{2}.*"
for path in asdict(log_paths).values():
assert re.match(pattern, path) is not None


def test_log_paths_deprecated_datetime_filesafe_prefix() -> None:
"""Ensure deprecated {datetime_filesafe} format field still works."""
log_paths = LogPaths.create("start_{datetime_filesafe}")
pattern = r"^start_\d{4}\.\d{2}\.\d{2}T\d{2}\.\d{2}\.\d{2}.*"
for path in asdict(log_paths).values():
Expand Down