-
Notifications
You must be signed in to change notification settings - Fork 29
Item builder #268
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
Item builder #268
Conversation
15ecb34 to
b9f5384
Compare
80d492b to
03459ce
Compare
27ec0e4 to
95d5237
Compare
b50151e to
b5d0d4b
Compare
TomAugspurger
left a comment
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 mentioned this on a call earlier, but this is a pattern built on fsspec that I've found helpful.
https://github.com/TomAugspurger/era5/blob/main/src/stactools/era5/stac.py#L150-L155
The create_item includes the protocol and storage_options keywords.
def create_item(
path: str,
kind: str,
protocol: str,
storage_options: dict[str, Any] | None = None,
) -> pystac.Item:And then the usage internally is
storage_options = storage_options or {}
fs = fsspec.filesystem(protocol, **storage_options)And all paths are relative to the dataset root. All path-like operations within create_item would use fsspec. In theory, this lets you use the same code for STAC items that might live on different filesystems (S3, Azure Blob Storage, local, ...). Hope that's helpful :)
| from pystac import Asset | ||
|
|
||
| builder = Builder() | ||
| builder.add_asset("an-asset", Asset(href="a-file.dat")) |
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.
Style question: what's the motivation for builder = Builder(); builder.add_asset pattern rather than defining what Builder.create_item will do in the class definitation?
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.
Partially, it's my procedural background, but I do find that leaving the asset addition until later is useful for conditionals, see here: https://github.com/stactools-packages/modis/blob/524bfd26bb6d571336e50a226e853b97287529e3/src/stactools/modis/commands.py#L74
|
Closing as will-reimplement -- this needs to be simpler. |
Related Issue(s): None
Description: This is a DRAFT pull request to experiment with ideas for adding support for a class-based item builder.
PR checklist:
scripts/format).scripts/lint).scripts/test).