aiidalab / aiidalab-qe

AiiDAlab App for Quantum ESPRESSO
https://aiidalab-qe.readthedocs.io/
MIT License
12 stars 14 forks source link

Use try/except to catch error #917

Open superstar54 opened 2 weeks ago

superstar54 commented 2 weeks ago

Fix #916

The error from 916 is because the setup process stopped because the code failed to inspect the qe env. In this PR, we handle this gracefully so that it returns False when failed to inspect qe env.

codecov[bot] commented 2 weeks ago

Codecov Report

Attention: Patch coverage is 7.69231% with 12 lines in your changes missing coverage. Please review.

Project coverage is 66.97%. Comparing base (2924582) to head (3b654d1).

Files with missing lines Patch % Lines
src/aiidalab_qe/setup/codes.py 7.69% 12 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #917 +/- ## ========================================== - Coverage 67.06% 66.97% -0.10% ========================================== Files 51 51 Lines 4715 4723 +8 ========================================== + Hits 3162 3163 +1 - Misses 1553 1560 +7 ``` | [Flag](https://app.codecov.io/gh/aiidalab/aiidalab-qe/pull/917/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiidalab) | Coverage Δ | | |---|---|---| | [python-3.11](https://app.codecov.io/gh/aiidalab/aiidalab-qe/pull/917/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiidalab) | `66.97% <7.69%> (-0.10%)` | :arrow_down: | | [python-3.9](https://app.codecov.io/gh/aiidalab/aiidalab-qe/pull/917/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiidalab) | `66.99% <7.69%> (-0.10%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiidalab#carryforward-flags-in-the-pull-request-comment) to find out more.

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

superstar54 commented 2 weeks ago

Very funny thing: the pre-commit and ruff conflict with each other.

superstar54 commented 2 weeks ago

As suggested by @unkcpz , if the cmd to inspect the env fails, we should raise the error and stop the installation.

unkcpz commented 1 week ago

Very funny thing: the pre-commit and ruff conflict with each other.

What you mean pre-commit and ruff are conflict? We use ruff in pre-commit as linter.

superstar54 commented 1 week ago

I added code required by ruff, in this commit, but pre-commit deleted it later. Then ruff check failed.

unkcpz commented 1 week ago

I added code required by ruff, in this commit, but pre-commit deleted it later. Then ruff check failed.

Because the else was supposed to add after try..except. It is not correct to early return with an else inside the try block.