-
Notifications
You must be signed in to change notification settings - Fork 15
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
Check pyiron installation #1131
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import os | ||
import stat | ||
import glob | ||
import pandas | ||
|
||
try: | ||
from conda.cli import python_api | ||
|
||
conda_imported_successful = True | ||
except ImportError: | ||
conda_imported_successful = False | ||
|
||
from pyiron_base import state | ||
|
||
conda_package_dict = { | ||
"atomicrex": "atomicrex", | ||
"cp2k": "cp2k", | ||
"damask": "damask", | ||
"mlip": "mlip", | ||
"lammps": "lammps", | ||
"quantumespresso": "qe", | ||
"randspg": "randspg", | ||
"runner": "runner", | ||
"sphinx": "sphinxdft", | ||
} | ||
|
||
|
||
def check_for_conda_package(name): | ||
lst = [l for l in python_api.run_command("list")[0].split("\n") if name + " " in l] | ||
if len(lst) == 0: | ||
return False | ||
else: | ||
return True | ||
|
||
|
||
def check_executable_bit(resource_paths): | ||
def check_bit(script_path): | ||
filemode = os.stat(script_path).st_mode | ||
return bool( | ||
filemode & stat.S_IXUSR | ||
or filemode & stat.S_IXGRP | ||
or filemode & stat.S_IXOTH | ||
) | ||
|
||
path_lst = [] | ||
for res_path in resource_paths: | ||
path_lst += glob.glob(res_path + "/*/*/*.sh") | ||
return {p: check_bit(script_path=p) for p in path_lst} | ||
|
||
|
||
def check_executables_status(): | ||
executables_dict = check_executable_bit( | ||
resource_paths=state.settings.configuration["resource_paths"] | ||
) | ||
if conda_imported_successful: | ||
conda_lst = [ | ||
check_for_conda_package(name=conda_package_dict[f]) | ||
if f is not None and f in conda_package_dict.keys() | ||
else False | ||
for f in [ | ||
p.split("/")[-3] if "/share/pyiron/" in p else None | ||
for p in executables_dict.keys() | ||
] | ||
] | ||
return pandas.DataFrame( | ||
{ | ||
"name": [p.split("/")[-3] for p in executables_dict.keys()], | ||
"path": list(executables_dict.keys()), | ||
"executable_bit": list(executables_dict.values()), | ||
"conda_package_installed": conda_lst, | ||
} | ||
) | ||
else: | ||
return pandas.DataFrame( | ||
{ | ||
"name": [p.split("/")[-3] for p in executables_dict.keys()], | ||
"path": list(executables_dict.keys()), | ||
"executable_bit": list(executables_dict.values()), | ||
} | ||
) |
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.
This feels very fragile. It looks to me like this requires all executables to be at exactly the third level of depth. This may be the case right now, but so we specify or document this anywhere? Do we anticipate other sh files appearing here, or is it safe to run an endswith command recursively inside the resource path instead?
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.
Right now it needs to be exactly at the third level because the expected structure is
/$resources/$module_name/bin/$exe.sh
. The documentation for this is here, though it could be more explicit.I have a little class that codifies this in tinybase which could be moved to base. Replacing this everywhere might be a bit more effort, so imo it's ok to do it in a separate PR.
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'm ok with codefying it as long as we're sufficiently explicit. One option I see is to search for scripts at exactly three levels deep and also searching for them anywhere in the resource tree, then giving the user a warning if the lists aren't the same.
Actually, I think I really like that, and it should be straightforward to make a test setup in static to make sure both aspects work.
Similarly we should also be checking if non-supported codes have directories. I'm on mobile so I can't easily bail on this comment to check if that's already done, but this would be another nice thing to give a warning about.