aiida-core icon indicating copy to clipboard operation
aiida-core copied to clipboard

Support stashed directory cleaning in `verdi node delete --clean-workdir`

Open Copilot opened this issue 3 months ago • 1 comments

The --clean-workdir flag only cleaned remote_folder outputs but ignored remote_stash outputs created by the stashing mechanism.

Changes

  • src/aiida/orm/utils/remote.py: Added get_calcjob_stashed_paths() and clean_mapping_stashed_paths() to query and clean stashed data, mirroring the existing remote folder functions

  • src/aiida/orm/nodes/data/remote/stash/: Implemented _clean() methods:

    • RemoteStashFolderData: removes target directory via clean_remote()
    • RemoteStashCompressedData: removes compressed file via transport.remove()
    • RemoteStashCustomData: raises NotImplementedError with message "I don't know how to delete remote files of RemoteStashCustomData"
    • Added KEY_EXTRA_CLEANED constant and get_authinfo() helper to base class
  • src/aiida/cmdline/commands/cmd_node.py: Extended node_delete to query both remote_folder and remote_stash outputs when --clean-workdir is specified

Behavior

# Now cleans both remote work directories and stashed directories
verdi node delete --clean-workdir <node_pk>

# For RemoteStashCustomData nodes, raises:
# Critical: I don't know how to delete remote files of RemoteStashCustomData. 
#          Please manually clean the stashed data for node <pk>.

Cleaned status is tracked via the cleaned extra on both RemoteData and RemoteStashData nodes.

Original prompt

This section details on the original issue you should resolve

<issue_title>CLI: verdi node delete --clean-workdir potentially could also support removing stashed directories.</issue_title> <issue_description>Following PR https://github.com/aiidateam/aiida-core/pull/6756 , which provides verdi node delete --clean-workdir functionality at first place:

While still designing and developing aiidateam/aiida-core#6764 stashing, I could not foresee if verdi node delete --clean-workdir should also clean stashed directories, and even if so, how should that be done.

Therefore, I document here, so after completing aiidateam/aiida-core#6764, we can come back here, think through and develop verdi node delete --clean-workdir further. </issue_description>

<agent_instructions>I think we should also support this. With one exception, if the the type is RemoteStashCustomData you just raise: "I don't know how to delete remote files of RemoteStashCustomData"</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@khsrali Hi @Muhammad-Rebaal

Thanks for your interest.

This issue is mainly for future, when we put stashing fully in place. Right now it's not possible to solve it, because we have not finalized the stashing interface yet.</comment_new>

  • Fixes aiidateam/aiida-core#6781

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot avatar Dec 10 '25 11:12 Copilot

Codecov Report

:x: Patch coverage is 4.90196% with 97 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 29.14%. Comparing base (5014979) to head (1d5f8cb).

Files with missing lines Patch % Lines
src/aiida/orm/utils/remote.py 0.00% 56 Missing :warning:
src/aiida/cmdline/commands/cmd_node.py 0.00% 15 Missing :warning:
src/aiida/orm/nodes/data/remote/stash/compress.py 6.67% 14 Missing :warning:
src/aiida/orm/nodes/data/remote/stash/folder.py 10.00% 9 Missing :warning:
src/aiida/orm/nodes/data/remote/stash/base.py 50.00% 3 Missing :warning:
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #7149       +/-   ##
===========================================
- Coverage   79.62%   29.14%   -50.48%     
===========================================
  Files         566      566               
  Lines       43576    43628       +52     
===========================================
- Hits        34694    12709    -21985     
- Misses       8882    30919    +22037     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Dec 10 '25 13:12 codecov[bot]