-
Notifications
You must be signed in to change notification settings - Fork 10
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
Configure the pyMBE virtual environment #12
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2a9af7a
Set up pyMBE virtual environment
jngrad c594a42
Set up pyMBE Jupyter kernel
jngrad 9dae0b5
Add clarifying note to README, fix paths and imports in all scripts
pm-blanco df5c64b
Set up virtual environment for cluster users
jngrad 92411a0
Bugfix
jngrad 02f7795
Improve README with more details about venv, the path to espresso. So…
pm-blanco 5895abc
fix dependencies version number, add new folders to README
pm-blanco File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import os | ||
import argparse | ||
import sysconfig | ||
try: | ||
import espressomd | ||
espressomd_found = True | ||
except ModuleNotFoundError: | ||
espressomd_found = False | ||
|
||
|
||
def make_pth(name, path): | ||
if not os.path.isdir(path): | ||
raise ValueError(f"Folder '{path}' doesn't exist") | ||
site_packages = sysconfig.get_path("platlib") | ||
with open(os.path.join(site_packages, f"{name}.pth"), "w") as f: | ||
f.write(os.path.realpath(path)) | ||
|
||
|
||
parser = argparse.ArgumentParser(description="Configure pyBME and ESPResSo module paths") | ||
parser.add_argument("--espresso_path", type=str, required=not espressomd_found, | ||
help="Path to the ESPResSo build folder") | ||
args = parser.parse_args() | ||
|
||
if not os.environ.get("VIRTUAL_ENV"): | ||
raise RuntimeError("This script should be run in a virtual environment") | ||
|
||
if not espressomd_found: | ||
make_pth("espresso", os.path.join(args.espresso_path, "src", "python")) | ||
make_pth("pymbe", os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Note: I tried to encapsulate the pyMBE kernel into the virtual environment itself, but Jupyter only seems to detect the ones installed in the user's
$HOME
folder:I couldn't find a way to detect the local folders. I tried to generate a default Jupyter config file in the virtual environment, thinking I could adapt something a path in there, but Jupyter ended up writing the default config file in my
$HOME
folder directly... So be careful if you want to tinker with Jupyter settings in the virtual environment.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.
@jngrad I followed the instructions and it was pretty clear to me how to set up and use the new virtual environment of pyMBE. I fixed all paths in the scripts and removed the previous logic to import pyMBE.
I have to say that this new pyMBE environment is very cool and I think that it could be very helpful to make our lives easier to use both espresso and pyMBE. It is, however, not clear to me how to setup pyMBE when using it in a cluster when you do not now the path in which espresso was built. I tried to import the espresso module built-in in the cluster we use at NTNU and then following the instructions but I failed:
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.
@pinedaps could you please check this new feature (see #12)? clone the forked pyMBE repository of @jngrad in here, follow the new instructions to set up and use pyMBE in the README file and let us now if they are clear to you
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.
I am too used to building ESPResSo myself on clusters 😀
The
configure_venv.py
now detects if ESPResSo is already available as a module, so that cluster users can module load ESPResSo. I had to adapt theargparse
syntax, because positional arguments cannot be made optional. Theconfigure_venv.py
script is now tested in CI as well.There is also a
venv
option to only install the subset of Python packages that are not already loaded with ESPResSo; this should avoid the broken Python dependency tree you observed on the cluster. This is now documented in the readme file too.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.
@pm-blanco @jngrad, I was following the new instructions and I got this error while running
In order to check that the provided path was right, I did 'ls' to the folder and it normally showed the content.
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.
Could you please check if the issue persists after replacing
__file__
byos.path.abspath(__file__)
at line 29?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.
I did it and it worked. Now, It complained when installing the requirements because it could not find a version that satisfies the requirement pint-pandas==0.5. While looking for an explanation, we realized that my python's version is 3.8 while Pablo's version is 3.10 (it runs without problems). Could it be that the previous error is related to this fact as well? If so then should be worthy to specify which is the minimum required version of python.
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.
pint-pandas
is not packaged for Python 3.8. It is probably related to NEP 29 - Recommend Python and Numpy version support as a community policy standard. Major Python packages likematplotlib
,jupyter
andscipy
had already adopted NEP 29 in 2020 (around the time whenpint-pandas
got its first release). ESPResSo eventually adopted NEP 29 in 2022 because maintaining support for older Python versions was not worth the trouble. According to the NEP 29 drop schedule, Python 3.8 is no longer officially supprted by the NumPy ecosystem since early 2023, and they'll drop support for Python 3.9 next month.