-
Notifications
You must be signed in to change notification settings - Fork 14
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
Support QE conda env in /opt/conda #784
Conversation
When building the QEApp Docker container, the Quantum Espresso installation into a conda environment is a step that's completely independent from the others. By putting it into a separate Docker build stage, it can be build in parallel (when using buildkit), as: DOCKER_BUILDKIT=1 docker build .
@@ -134,7 +139,7 @@ def setup_codes(): | |||
try: | |||
run(["python", "-c", python_code], capture_output=True, check=True) | |||
except CalledProcessError as error: | |||
raise RuntimeError(f"Failed to setup codes: {error}") | |||
raise RuntimeError(f"Failed to setup codes: {error}") from None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just to make stack traces nicer. Here's the correspoding flake8-bugbear rule as explained by ruff
❯ ruff rule B904
# raise-without-from-inside-except (B904)
Derived from the **flake8-bugbear** linter.
## What it does
Checks for `raise` statements in exception handlers that lack a `from`
clause.
## Why is this bad?
In Python, `raise` can be used with or without an exception from which the
current exception is derived. This is known as exception chaining. When
printing the stack trace, chained exceptions are displayed in such a way
so as make it easier to trace the exception back to its root cause.
When raising an exception from within an `except` clause, always include a
`from` clause to facilitate exception chaining. If the exception is not
chained, it will be difficult to trace the exception back to its root cause.
Example
try:
...
except FileNotFoundError:
if ...:
raise RuntimeError("...")
else:
raise UserWarning("...")
Use instead:
try:
...
except FileNotFoundError as exc:
if ...:
raise RuntimeError("...") from None
else:
raise UserWarning("...") from exc
References
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, how you find these good thing? Is it from your LSP?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is from ruff, which I have setup as LSP in neovim.
While the pre-commit in this repo uses ruff, it doesn't have any ruff-specific configuration. I think we should copy over the configuration from AWB. I think we have a good experience with that set and it will make things consistent across the two repos.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #784 +/- ##
==========================================
- Coverage 68.28% 68.21% -0.07%
==========================================
Files 45 45
Lines 4143 4147 +4
==========================================
Hits 2829 2829
- Misses 1314 1318 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A small note from my side. All good, thanks @danielhollas
def get_qe_env(): | ||
# QE is already pre-installed in the QE image | ||
path = Path(f"/opt/conda/envs/quantum-espresso-{QE_VERSION}") | ||
if path.exists(): | ||
return path | ||
else: | ||
return Path.home().joinpath(".conda", "envs", f"quantum-espresso-{QE_VERSION}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can cause an edge problem that when the container is started with qeapp image and then shifted to using full-stack image. The QE not able to be accessed.
We were trying to provide full-stack
, qe-app
, base-with-server
images in demo server. But as suggested by @giovannipizzi, we agree on only keep qe-app
image. This change then wont be a problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. But hopefully that will not happen in practice, and the solution is simply to re-install the app. By the way, in this case the current solution with the symlink would not work anyway since the symlink would be broken, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in this case the current solution with the symlink would not work anyway since the symlink would be broken, right?
I think it won't work.
Change
setup_codes.py
to support QE conda environment located in/opt/conda
Built on top of #783. Separated from #781.