Skip to content

Commit

Permalink
Merge pull request #1528 from pyiron/exeresolve
Browse files Browse the repository at this point in the history
Use resolver classes from pyiron_snippets
  • Loading branch information
pmrv authored Jul 21, 2024
2 parents 27bc37f + a356410 commit 6cd07ac
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .ci_support/environment-old.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies:
- pint =0.18
- psutil =5.8.0
- pyfileindex =0.0.16
- pyiron_snippets =0.1.1
- pyiron_snippets =0.1.3
- executorlib =0.0.1
- pysqa =0.1.12
- pytables =3.6.1
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ jobs:
python-version: '3.10'
label: linux-64-py-3-10

- operating-system: ubuntu-latest
python-version: 3.9
label: linux-64-py-3-9

steps:
- uses: actions/checkout@v4
- name: Setup Mambaforge
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unittests_old.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v3
with:
python-version: '3.9'
python-version: '3.10'
miniforge-variant: Mambaforge
channels: conda-forge
channel-priority: strict
Expand Down
57 changes: 12 additions & 45 deletions pyiron_base/jobs/job/extension/executable.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import os

from pyiron_snippets.resources import ExecutableResolver

from pyiron_base.interfaces.has_dict import HasDict
from pyiron_base.state import state
from pyiron_base.storage.datacontainer import DataContainer
Expand Down Expand Up @@ -49,26 +51,11 @@ def __init__(
if path_binary_codes is None:
path_binary_codes = state.settings.resource_paths
self.storage.version = None
if codename is not None and module is not None:
self.storage.name = codename.lower()
code_path_lst = [
os.path.join(path, module, "bin") for path in path_binary_codes
]
backwards_compatible_path_lst = [
os.path.join(path, self.storage.name) for path in path_binary_codes
]
self.path_bin = [
exe_path
for exe_path in (code_path_lst + backwards_compatible_path_lst)
if os.path.exists(exe_path)
]
else: # Backwards compatibility
self.storage.name = codename.lower()
self.path_bin = [
os.path.join(path, self.storage.name)
for path in path_binary_codes
if os.path.exists(os.path.join(path, self.storage.name))
]
self.storage.name = codename.lower()
if module is None:
module = self.storage.name
self._module = module
self.path_bin = path_binary_codes
if overwrite_nt_flag:
self.storage.operation_system_nt = False
else:
Expand Down Expand Up @@ -284,31 +271,11 @@ def _executable_versions_list(self):
Returns:
dict: list of the available version
"""
if self.storage.operation_system_nt:
extension = ".bat"
else:
extension = ".sh"
try:
executable_dict = {}
for path in self.path_bin:
for executable in os.listdir(path):
if (
executable.startswith("run_" + self.storage.name + "_")
& executable.endswith(extension)
and executable[
len("run_" + self.storage.name) + 1 : -len(extension)
]
not in executable_dict.keys()
):
executable_dict[
executable[
len("run_" + self.storage.name) + 1 : -len(extension)
]
] = os.path.join(path, executable).replace("\\", "/")
return executable_dict
# No executable exists - This is the case for GenericJob and other abstract job classes.
except OSError:
return dict()
return ExecutableResolver(
resource_paths=self.path_bin,
code=self.storage.name,
module=self._module,
).dict()

def _executable_select(self):
"""
Expand Down
27 changes: 13 additions & 14 deletions pyiron_base/state/queue_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import os

from pyiron_snippets.resources import ResourceResolver
from pyiron_snippets.singleton import Singleton
from pysqa import QueueAdapter as PySQAAdpter

Expand Down Expand Up @@ -45,20 +46,18 @@ def __init__(self):

def construct_adapters(self) -> None:
"""Read through the resources and construct queue adapters for all the queue configuration files found."""
self._adapters = []
for resource_path in settings.configuration["resource_paths"]:
if (
os.path.exists(resource_path)
and "queues" in os.listdir(resource_path)
and (
"queue.yaml" in os.listdir(os.path.join(resource_path, "queues"))
or "clusters.yaml"
in os.listdir(os.path.join(resource_path, "queues"))
)
):
self._adapters.append(
PySQAAdpter(directory=os.path.join(resource_path, "queues"))
)
queue_folders = set(
map(
os.path.dirname,
ResourceResolver(
settings.resource_paths,
"queues",
).search(["queue.yaml", "clusters.yaml"]),
)
)
self._adapters = [
PySQAAdpter(directory=queue_folder) for queue_folder in queue_folders
]

@property
def adapter(self) -> PySQAAdpter:
Expand Down

0 comments on commit 6cd07ac

Please sign in to comment.