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

Changed CLI View Prefix #774

Merged
merged 8 commits into from
Jun 19, 2022
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
4 changes: 4 additions & 0 deletions contributors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,8 @@ contributors:
-
family-names: Tork
given-names: Parisa
-
family-names: Takada
given-names: Kody
affiliation: "University of Michigan"
...
3 changes: 2 additions & 1 deletion signac/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,8 @@ def main():
"$ signac view $PREFIX $VIEW_PATH -f $FILTERS -d $DOC_FILTERS.",
)
parser_view.add_argument(
"prefix",
"-p",
"--prefix",
type=str,
nargs="?",
default="view",
Expand Down
18 changes: 17 additions & 1 deletion tests/test_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,22 @@ def test_view(self):
"view/a/{}/job".format(sp["a"])
) == os.path.realpath(project.open_job(sp).path)

@pytest.mark.skipif(WINDOWS, reason="Symbolic links are unsupported on Windows.")
def test_view_prefix(self):
self.call("python -m signac init".split())
project = signac.Project()
sps = [{"a": i} for i in range(3)]
for sp in sps:
project.open_job(sp).init()
os.mkdir("view")
self.call("python -m signac view --prefix view/test_dir".split())
for sp in sps:
assert os.path.isdir("view/test_dir/a/{}".format(sp["a"]))
assert os.path.isdir("view/test_dir/a/{}/job".format(sp["a"]))
assert os.path.realpath(
"view/test_dir/a/{}/job".format(sp["a"])
) == os.path.realpath(project.open_job(sp).path)

@pytest.mark.skipif(WINDOWS, reason="Symbolic links are unsupported on Windows.")
def test_view_incomplete_path_spec(self):
self.call("python -m signac init".split())
Expand All @@ -197,7 +213,7 @@ def test_view_incomplete_path_spec(self):
# An error should be raised if the user-provided path function
# doesn't make a 1-1 mapping.
err = self.call(
"python -m signac view view non_unique".split(),
"python -m signac view non_unique".split(),
error=True,
raise_error=False,
)
Expand Down