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

cylc clean 3: targeted clean #4237

Merged
merged 22 commits into from
Jun 29, 2021
Merged

cylc clean 3: targeted clean #4237

merged 22 commits into from
Jun 29, 2021

Conversation

MetRonnie
Copy link
Member

@MetRonnie MetRonnie commented Jun 2, 2021

These changes partially address #3887

  1. A targeted version of [cylc clean]...

Implement targeted clean:

  # Remove the workflow's log directory
  $ cylc clean foo/bar --rm log

  # Remove the log and work directories
  $ cylc clean foo/bar --rm log:work
  # or
  $ cylc clean foo/bar --rm log --rm work

  # Remove all job log files from the 2020 cycle points
  cylc clean foo/bar --rm 'log/job/2020*'

  # Remove all .csv files
  $ cylc clean foo/bar --rm '**/*.csv'

  # Only remove the workflow on the local filesystem
  $ cylc clean foo/bar --local-only

  # Only remove the workflow on remote install targets
  $ cylc clean foo/bar --remote-only

These changes also close #4133

Requirements check-list

  • I have read CONTRIBUTING.md and added my name as a Code Contributor.
  • Contains logically grouped changes (else tidy your branch by rebase).
  • Does not contain off-topic changes (use other PRs for other changes).
  • Applied any dependency changes to both setup.py and
    conda-environment.yml.
  • Appropriate tests are included (unit and functional).
  • Appropriate change log entry included.
  • Documentation will be handled by Document cylc clean cylc-doc#256

@MetRonnie MetRonnie added this to the cylc-8.0b2 milestone Jun 2, 2021
@MetRonnie MetRonnie self-assigned this Jun 2, 2021
@MetRonnie MetRonnie added this to In progress in rose suite-run to cylc via automation Jun 2, 2021
@MetRonnie
Copy link
Member Author

Fast tests failure on MacOS seems unrelated

Copy link
Member

@oliver-sanders oliver-sanders left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, run some basic tests, still need to get my head around what it's doing with symlinks.

Some small comments:

cylc/flow/exceptions.py Outdated Show resolved Hide resolved
Comment on lines +119 to +124
def __init__(self, exc: Exception) -> None:
CylcError.__init__(
self,
f"{exc}. This is probably a temporary issue with the filesystem, "
"not a problem with Cylc."
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(minor comment more for future sake)

A pattern that is a bit nicer for Python interfaces and testing is to store exc as an attribute on the FileRemovalError and handle the representation in the __str__ method.

Will get around to refactoring the other errors one day when we have less to do 😆.

cylc/flow/pathutil.py Outdated Show resolved Hide resolved
cylc/flow/pathutil.py Outdated Show resolved Hide resolved
cylc/flow/pathutil.py Outdated Show resolved Hide resolved
cylc/flow/workflow_files.py Outdated Show resolved Hide resolved
cylc/flow/workflow_files.py Outdated Show resolved Hide resolved
@MetRonnie MetRonnie marked this pull request as draft June 10, 2021 10:09
This filters out all redundant matches, i.e. matches that are subpaths
of other matches (except for the std symlink dirs - we need to return
these as we need to follow their targets).

As was implemented in a previous commit, it still also filters out
subpaths of symlinks as we don't want to follow symlinks (again except
for the std symlink dirs).
@MetRonnie MetRonnie marked this pull request as ready for review June 11, 2021 17:29
@@ -44,7 +44,7 @@
remove_dir_or_file
)

from tests.unit.conftest import MonkeyMock
Copy link
Member Author

@MetRonnie MetRonnie Jun 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyone know why this import stopped working suddenly on GH Actions? The absolute import is still working locally for me

_________________ ERROR collecting tests/unit/test_pathutil.py _________________
tests/unit/test_pathutil.py:47: in <module>
    from tests.unit.conftest import MonkeyMock
E   ModuleNotFoundError: No module named 'tests'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be the difference between the editable install you will likely have for local development and the regular install on GH actions. I think the editable install will put the tests folder in PYTHONPATH.

The tests folder shouldn't be imported directly like that (hasn't been configured as a Python package, has no __init__.py so will be interpreted as a namespace package?).

Copy link
Member

@oliver-sanders oliver-sanders left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gone through the changes since last review, looks good to me.

cylc/flow/workflow_files.py Outdated Show resolved Hide resolved
cylc/flow/workflow_files.py Outdated Show resolved Hide resolved
cylc/flow/workflow_files.py Outdated Show resolved Hide resolved
tests/unit/test_workflow_files.py Show resolved Hide resolved
Do not retry a failed clean on an install target using the next platform in the list if the remote clean command failed due to a non-SSH reason (if ret code != 255).
@MetRonnie MetRonnie mentioned this pull request Jun 24, 2021
Copy link
Contributor

@datamel datamel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'm happy with the change, thanks @MetRonnie.
I have minor comments (one note to self for my pr once this is merged), nothing that should affect merge.

@@ -83,29 +83,29 @@ def create_client_keys(srvd, install_target):
os.umask(old_umask)


def remote_init(install_target, rund, *dirs_to_symlink):
def remote_init(install_target: str, rund: str, *dirs_to_symlink: str) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have memories of @oliver-sanders saying that *args is a list?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*args is a tuple, **kwargs is a dict, how mypy works with this is a whole other kettle of fish.

I found an example in the docs which suggests that *args: str means that all *args should be str (i.e. the tuple thing is implicit).

https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html#when-you-re-puzzled-or-when-things-are-complicated

SHARE_CYCLE_DIR, SHARE_DIR, LOG_DIR, WORK_DIR, ''
])
"""The paths of the symlink dirs that may be set in
global.cylc[symlink dirs], relative to the run dir
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is changing into [install] symlink dirs but I can change it on my pr: #4250

Copy link
Member

@oliver-sanders oliver-sanders left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(went through and resolved outstanding comments)

Copy link
Member

@oliver-sanders oliver-sanders left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested as best I can, everything looks good to me, edge cases well handled.

@oliver-sanders oliver-sanders merged commit 6e28784 into cylc:master Jun 29, 2021
rose suite-run to cylc automation moved this from In progress to Done Jun 29, 2021
@MetRonnie MetRonnie deleted the cylc-clean branch June 29, 2021 13:04
@MetRonnie MetRonnie linked an issue Jun 29, 2021 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

cylc clean clean: traceback removing local files
3 participants