Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix anonymous workspace setup with no log dir #478

Merged
merged 1 commit into from
May 4, 2024
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
18 changes: 18 additions & 0 deletions lib/ramble/ramble/test/cmd/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,24 @@ def test_setup_command():
assert os.path.exists(ws.root + '/all_experiments')


def test_setup_command_with_missing_log_dir():
ws_name = "test"
workspace("create", ws_name)

with ramble.workspace.read("test") as ws:
add_basic(ws)
check_basic(ws)
# Missing log directory shouldn't prevent workspace
# setup, as long as the workspace is considered valid
# by the `is_workspace_dir` check.
os.rmdir(ws.log_dir)

workspace("concretize")

workspace("setup")
assert os.path.exists(ws.root + "/all_experiments")


def test_setup_nothing():
ws_name = 'test'
workspace('create', ws_name)
Expand Down
3 changes: 2 additions & 1 deletion lib/ramble/ramble/util/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import llnl.util.tty.color

from contextlib import contextmanager
from pathlib import Path


class Logger(object):
Expand Down Expand Up @@ -43,7 +44,7 @@ def add_log(self, path):
path: File path for the new log file
"""
if isinstance(path, str) and self.enabled:
stream = None
Path(path).parent.mkdir(parents=True, exist_ok=True)
stream = llnl.util.tty.log.Unbuffered(open(path, 'a+'))
self.log_stack.append((path, stream))

Expand Down