-
Notifications
You must be signed in to change notification settings - Fork 52
filesystem warehouse usability improvements #2155
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
Draft
atravitz
wants to merge
4
commits into
epic/execution_improvements
Choose a base branch
from
dev/warehouse_usability
base: epic/execution_improvements
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+89
−51
Draft
Changes from all commits
Commits
Show all changes
4 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| # This code is part of OpenFE and is licensed under the MIT license. | ||
| # For details, see https://github.com/OpenFreeEnergy/gufe | ||
| from __future__ import annotations | ||
|
|
||
| import json | ||
| import pathlib | ||
| import re | ||
|
|
@@ -398,8 +400,8 @@ class FileSystemWarehouse(WarehouseBaseClass): | |
|
|
||
| Parameters | ||
| ---------- | ||
| root_dir : str, optional | ||
| Root directory for the warehouse storage, by default "warehouse". | ||
| root_dir : pathlib.Path, optional | ||
| Root directory in which to create the warehouse storage. | ||
|
|
||
| Notes | ||
| ----- | ||
|
|
@@ -408,14 +410,16 @@ class FileSystemWarehouse(WarehouseBaseClass): | |
| for results and other data types. | ||
| """ | ||
|
|
||
| def __init__(self, name): | ||
| # TODO: should name and location be different? | ||
| self.root_dir = pathlib.Path(f"{name}") | ||
| def __init__(self, root_dir: pathlib.Path, exist_okay=False): | ||
| self.root_dir = pathlib.Path(root_dir) | ||
| if self.root_dir.is_dir() and not exist_okay: | ||
| raise ValueError( | ||
| "`root_dir` already exists. To load an existing Warehouse, use FileSystemWarehouse.load(`root_dir`)" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the error, but I am a little concerned about how it gets passed down to a user. If a user reruns a command using this under the hood will it make sense? Do we even care about that here? |
||
| ) | ||
| setup_store = FileStorage(f"{self.root_dir}/setup") | ||
| result_store = FileStorage(f"{self.root_dir}/result") | ||
| shared_store = FileStorage(f"{self.root_dir}/shared") | ||
| tasks_store = FileStorage(f"{self.root_dir}/tasks") | ||
| # TODO: we can store dags in setup if we have a performant way of accessing them | ||
| protocol_dag_store = FileStorage(f"{self.root_dir}/protocol_dags") | ||
| stores = WarehouseStores( | ||
| setup=setup_store, | ||
|
|
@@ -424,4 +428,14 @@ def __init__(self, name): | |
| tasks=tasks_store, | ||
| protocol_dags=protocol_dag_store, | ||
| ) | ||
| super().__init__(stores, name) | ||
| name = self.root_dir.resolve().name | ||
| super().__init__(stores=stores, name=name) | ||
|
|
||
| @classmethod | ||
| def load(cls, root_dir: pathlib.Path) -> FileSystemWarehouse: | ||
|
atravitz marked this conversation as resolved.
|
||
| root_dir = pathlib.Path(root_dir) | ||
| if not root_dir.is_dir(): | ||
| raise ValueError( | ||
| "`root_dir` must be an existing filepath. To create a new Warehouse, use FileSystemWarehouse(`root_dir`)" | ||
| ) | ||
| return cls(root_dir=root_dir, exist_okay=True) | ||
This file contains hidden or 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 hidden or 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 hidden or 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.
I am sure you are aware but seems there are changes to this in Python 3.14 https://docs.python.org/3.14/whatsnew/3.14.html#from-future-import-annotations
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.
thanks for the link! I think this is fine in this instance, since it's pulling in Python 3.14 functionality.