Skip to content

Commit

Permalink
Instantiate QueueAdapter only once per folder
Browse files Browse the repository at this point in the history
In case both clusters.yaml and queues.yaml are present in a resource folder,
the old code created two (equivalent) queue adapters.
  • Loading branch information
pmrv committed Jul 20, 2024
1 parent f3f701d commit a145ff2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions pyiron_base/state/queue_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ def __init__(self):

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

@property
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/state/test_queue_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def tearDownClass(cls) -> None:

def test_construction(self):
self.assertEqual(
3,
2,
len(queue_adapters._adapters),
msg="The zeroth resource does not have yaml files and should not produce a queue",
)
Expand Down

0 comments on commit a145ff2

Please sign in to comment.