-
Notifications
You must be signed in to change notification settings - Fork 7
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
HARMONY-1862: Update pystac library dependency #47
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
70587ef
HARMONY-1862: Update STAC IO library
vinnyinverso ce110a7
HARMONY-1862: Update test matrix
vinnyinverso 40974ae
HARMONY-1852: Try >= for pystac version
vinnyinverso 4d3bb46
HARMONY-1862: Ignore CVE for now
vinnyinverso 2bc5a29
HARMONY-1862: Lint issues
vinnyinverso cec9162
HARMONY-1862: Bump pystac to oldest known version that is compatible …
vinnyinverso d1b10da
Merge branch 'main' into HARMONY-1862
vinnyinverso 62d2125
HARMONY-1862: Ignore whole vscode dir
vinnyinverso 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 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 |
---|---|---|
|
@@ -132,3 +132,6 @@ config.json | |
|
||
# Snyk / Deepcode AI | ||
.dccache | ||
|
||
# VS Code | ||
.vscode/ |
This file contains 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,16 +1,16 @@ | ||
autopep8 ~= 1.5 | ||
debugpy ~= 1.2 | ||
Faker ~= 8.1.3 | ||
flake8 ~= 5.0.4 | ||
flake8 >= 6.1.0 | ||
ipython ~= 8.10.0 | ||
jedi ~= 0.17.2 | ||
packaging ~= 24.1 | ||
parameterized ~= 0.7 | ||
pycodestyle ~= 2.9.1 | ||
pytest ~= 7.2.0 | ||
pytest-cov ~=2.11 | ||
pytest-mock ~=3.5 | ||
python-language-server ~= 0.35 | ||
responses ~=0.22.0 | ||
pycodestyle >= 2.9.1 | ||
safety ~= 3.2.7 | ||
setuptools == 70.0.0 | ||
setuptools == 70.0.0 |
This file contains 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 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 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 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 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 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 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 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 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,54 +1,57 @@ | ||
from urllib.parse import urlparse | ||
import boto3 | ||
from pystac import STAC_IO | ||
from pystac.stac_io import StacIO, DefaultStacIO | ||
from harmony import util | ||
from harmony import aws | ||
from os import environ | ||
|
||
""" | ||
Read and write to s3 when STAC links start with s3://. | ||
https://pystac.readthedocs.io/en/0.5/concepts.html#using-stac-io | ||
https://pystac.readthedocs.io/en/latest/concepts.html#using-stac-io | ||
""" | ||
|
||
|
||
def read(uri): | ||
""" | ||
Reads STAC files from s3 | ||
(or via the default method if the protocol is not s3). | ||
|
||
Parameters | ||
---------- | ||
uri: The STAC file uri. | ||
|
||
Returns | ||
------- | ||
The file contents | ||
""" | ||
config = util.config(validate=environ.get('ENV') != 'test') | ||
service_params = aws.aws_parameters( | ||
config.use_localstack, config.localstack_host, config.aws_default_region) | ||
parsed = urlparse(uri) | ||
if parsed.scheme == 's3': | ||
bucket = parsed.netloc | ||
key = parsed.path[1:] | ||
s3 = boto3.resource('s3', **service_params) | ||
obj = s3.Object(bucket, key) | ||
return obj.get()['Body'].read().decode('utf-8') | ||
else: | ||
return STAC_IO.default_read_text_method(uri) | ||
|
||
|
||
def write(uri, txt): | ||
""" | ||
Writes a STAC file to the given uri. | ||
|
||
Parameters | ||
---------- | ||
uri: The STAC file uri. | ||
txt: The STAC contents. | ||
""" | ||
parsed = urlparse(uri) | ||
if parsed.scheme == 's3': | ||
aws.write_s3(uri, txt) | ||
else: | ||
STAC_IO.default_write_text_method(uri, txt) | ||
defaultStacIO = DefaultStacIO() | ||
|
||
|
||
class S3StacIO(StacIO): | ||
|
||
def read_text(self, uri): | ||
""" | ||
Reads STAC files from s3 | ||
(or via the default method if the protocol is not s3). | ||
|
||
Parameters | ||
---------- | ||
uri: The STAC file uri. | ||
|
||
Returns | ||
------- | ||
The file contents | ||
""" | ||
config = util.config(validate=environ.get('ENV') != 'test') | ||
service_params = aws.aws_parameters( | ||
config.use_localstack, config.localstack_host, config.aws_default_region) | ||
parsed = urlparse(uri) | ||
if parsed.scheme == 's3': | ||
bucket = parsed.netloc | ||
key = parsed.path[1:] | ||
s3 = boto3.resource('s3', **service_params) | ||
obj = s3.Object(bucket, key) | ||
return obj.get()['Body'].read().decode('utf-8') | ||
else: | ||
return defaultStacIO.read_text(uri) | ||
|
||
def write_text(self, uri, txt): | ||
""" | ||
Writes a STAC file to the given uri. | ||
|
||
Parameters | ||
---------- | ||
uri: The STAC file uri. | ||
txt: The STAC contents. | ||
""" | ||
parsed = urlparse(uri) | ||
if parsed.scheme == 's3': | ||
aws.write_s3(uri, txt) | ||
else: | ||
defaultStacIO.write_text(uri, txt) |
This file contains 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,7 +1,7 @@ | ||
boto3 ~= 1.14 | ||
deprecation ~= 2.1.0 | ||
pynacl ~= 1.4 | ||
pystac ~= 0.5.3 | ||
pystac >= 1.0.0 | ||
python-json-logger ~= 2.0.1 | ||
requests ~= 2.24 | ||
urllib3 ~= 1.26.9 |
This file contains 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.
Updated this because flake8 was mistaking the colon in
http://
for a JSON-like colon.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.
Maybe should have an upper bound here? I want it to be flexible though because of all of the python versions we support.
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.
Maybe should avoid the upper bound according to this:
https://iscinumpy.dev/post/bound-version-constraints/#tldr
related: nasa/harmony-py#79