-
Notifications
You must be signed in to change notification settings - Fork 0
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
CloudStorage #34
CloudStorage #34
Conversation
Co-authored-by: Martijn Visser <[email protected]>
Co-authored-by: Martijn Visser <[email protected]>
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.
Pushed a commit and left some comments.
|
||
@dataclass | ||
class Cloud: | ||
data_dir: Union[str, Path] = RIBASIM_NL_DATA_DIR |
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 see you convert to Path in __post_init__
. Can't we not drop the Union here and make sure it is Path from the start?
I prefer to be less flexible to keep this code as simple as possible.
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.
- From the user-perspective; most readers accept Path and str-type paths; e.g. gpd.read_file(Path("my_file.shp")) and gpd.read_file("my_file.shp") both work.
- It will be a string (or None) if users do or do not supply
RIBASIM_NL_DATA_DIR
or the data_dir at__init__
if self.data_dir is None:
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.
Yeah I'm not saying we should not accept strings from the user, just that in our class it seemed like it would be easier if we convert it at the door to this class. But I don't directly have a suggestion how to do this, so feel free to ignore.
src/ribasim_nl/ribasim_nl/cloud.py
Outdated
def is_dir(item): | ||
return Path(item).suffix == "" |
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.
Why not use Path.is_dir()
? I don't think we need this function.
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.
Is used in
Ribasim-NL/src/ribasim_nl/ribasim_nl/cloud.py
Line 250 in a3aa8b8
if is_dir(item): |
Path("my_dir").is_dir()
is only True if path is directory ánd the directory exists. If you have better code, please provide.
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.
Ah ok it wasn't clear to me that this should be true if the directory doesn't exist. Would be good to clarify in a docstring.
Should we perhaps use this: https://github.com/fsspec/universal_pathlib? |
Cool, let's do it 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.
Would be good to add the is_dir
docstring, otherwise this can be merged. I made #35 for possible follow-up improvements.
- `RIBASIM_NL_DATA_DIR`: directory with your local copy of data in the Ribasim-NL cloud | ||
|
||
## Initialize the cloud | ||
Import the `Cloud`` and initialize it |
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.
Import the `Cloud`` and initialize it | |
Import the `CloudStorage` and initialize it |
Cloud class for #32