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

CLI: If gotocomputer is not implemented, do not raise but show the remote_workdir #6525

Merged
merged 1 commit into from
Jul 10, 2024

Conversation

khsrali
Copy link
Contributor

@khsrali khsrali commented Jul 9, 2024

gotocomputer is not implemented in aiida-firecrest meanwhile many users found this command useful to understand where is the remote directory of a particular process.

As it is right now, verdi calcjob gotocomputer prints long scary errors.

This PR suppresses a raise in such case and simply reports the working directory instead.

This was suggested by @mikibonacci who is actively using aiida-firecrest.

@khsrali khsrali requested a review from mikibonacci July 9, 2024 14:40
Copy link

codecov bot commented Jul 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.82%. Comparing base (ef60b66) to head (45059a5).
Report is 116 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6525      +/-   ##
==========================================
+ Coverage   77.51%   77.82%   +0.32%     
==========================================
  Files         560      562       +2     
  Lines       41444    41862     +418     
==========================================
+ Hits        32120    32577     +457     
+ Misses       9324     9285      -39     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@sphuber sphuber left a comment

Choose a reason for hiding this comment

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

Thanks @khsrali . All good, could you just add a quick test please.

echo.echo_report('going to the remote work directory...')
os.system(command)
except NotImplementedError:
echo.echo_report(f'gotocomputer is not implemented for {transport.__str__()}')
Copy link
Contributor

Choose a reason for hiding this comment

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

When adding a variable in an f-string, the __str__ method is automatically called

Suggested change
echo.echo_report(f'gotocomputer is not implemented for {transport.__str__()}')
echo.echo_report(f'gotocomputer is not implemented for {transport}')

def test_calcjob_gotocomputer(self, monkeypatch):
"""Test verdi calcjob gotocomputer"""

from unittest.mock import patch
Copy link
Contributor

Choose a reason for hiding this comment

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

why use unittest.mock when there is monkeypatch? Fine to keep the former if you prefer (even though we typically use the monkeypatch fixture) but if you do, get rid of the monkeypatch argument

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, you're right, I deleted monkeypatch.
Here I preferred patch because I could use it as context manager.

tests/cmdline/commands/test_calcjob.py Show resolved Hide resolved
tests/cmdline/commands/test_calcjob.py Show resolved Hide resolved
@khsrali khsrali force-pushed the gotocomputer-noscarymessage branch from 385d3df to 45059a5 Compare July 10, 2024 11:42
@sphuber sphuber merged commit 120c8ac into aiidateam:main Jul 10, 2024
11 checks passed
@sphuber
Copy link
Contributor

sphuber commented Jul 10, 2024

Thanks @khsrali

@khsrali khsrali deleted the gotocomputer-noscarymessage branch July 16, 2024 12:25
mikibonacci pushed a commit to mikibonacci/aiida-core that referenced this pull request Sep 3, 2024
…dateam#6525)

Not all transport plugins implement the `gotocomputer` method.
Instead of excepting, the remote working directory is now displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants