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 unintended directory stripping during cylc install #4931

Merged
merged 7 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ in `global.cylc[install]source dirs`.

### Fixes

[#4931](https://github.com/cylc/cylc-flow/pull/4931) - Fix cylc install for
installing workflows from multi-level directories.

[#4926](https://github.com/cylc/cylc-flow/pull/4926) - Fix a docstring
formatting problem presenting in the UI mutation flow argument info.

Expand Down
3 changes: 2 additions & 1 deletion cylc/flow/workflow_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -1907,7 +1907,8 @@ def get_source_workflow_name(source: Path) -> str:
else the basename of the given path."""
hjoliver marked this conversation as resolved.
Show resolved Hide resolved
for dir_ in get_source_dirs():
try:
return str(source.relative_to(dir_))
workflow_name = str(source.relative_to(Path(dir_).expanduser()))
return workflow_name
datamel marked this conversation as resolved.
Show resolved Hide resolved
except ValueError:
continue
return source.name
Expand Down
11 changes: 6 additions & 5 deletions tests/unit/test_workflow_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import logging
import os
from pathlib import Path
from posixpath import expanduser
datamel marked this conversation as resolved.
Show resolved Hide resolved
import pytest
import re
import shutil
Expand Down Expand Up @@ -1526,9 +1527,9 @@ def test_search_install_source_dirs_empty(mock_glbl_cfg: Callable):
@pytest.mark.parametrize(
'path, expected',
[
('/isla/nublar/dennis/nedry', 'dennis/nedry'),
('/isla/sorna/paul/kirby', 'paul/kirby'),
('/mos/eisley/owen/skywalker', 'skywalker')
('~/isla/nublar/dennis/nedry', 'dennis/nedry'),
('~/isla/sorna/paul/kirby', 'paul/kirby'),
('~/mos/eisley/owen/skywalker', 'skywalker')
]
)
def test_get_source_workflow_name(
Expand All @@ -1540,10 +1541,10 @@ def test_get_source_workflow_name(
'cylc.flow.workflow_files.glbl_cfg',
'''
[install]
source dirs = /isla/nublar, /isla/sorna
source dirs = ~/isla/nublar, ~/isla/sorna
datamel marked this conversation as resolved.
Show resolved Hide resolved
'''
)
assert get_source_workflow_name(Path(path)) == expected
assert get_source_workflow_name(Path(path).expanduser()) == expected


@pytest.mark.parametrize(
Expand Down