Skip to content

Commit

Permalink
Merge pull request #29 from mraspaud/fix-s3-path
Browse files Browse the repository at this point in the history
Fix to many slashes in s3 path
  • Loading branch information
mraspaud authored Sep 11, 2024
2 parents d94145a + e6b2128 commit f9f6dee
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ local = ["watchdog"]
publishing = ["posttroll"]
ssh = ["paramiko"]
dataspace = ["oauthlib", "requests_oauthlib", "s3fs"]
datastore = ["oauthlib", "requests_oauthlib"]
dhus = ["defusedxml"]
datastore = ["oauthlib", "requests_oauthlib", "aiohttp"]
dhus = ["defusedxml", "requests", "aiohttp"]
selector = ["redis"]
tests = ["redis-server", "freezegun", "responses", "pytroll-watchers[minio,local,publishing,ssh,dataspace,datastore,dhus,selector]"]

[build-system]
requires = ["hatchling", "hatch-vcs"]
Expand Down
2 changes: 1 addition & 1 deletion src/pytroll_watchers/dataspace_watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def generate_download_links(filter_string, dataspace_auth, storage_options):
resp = oauth.get(filter_string)
metadatas = resp.get("value", [])
for metadata in metadatas:
s3path = UPath("s3://" + metadata["S3Path"], **storage_options)
s3path = UPath("s3:/" + metadata["S3Path"], **storage_options)
mda = dict()
attributes = _construct_attributes_dict(metadata)
mda["platform_name"] = attributes["platformShortName"].capitalize() + attributes["platformSerialIdentifier"]
Expand Down
4 changes: 2 additions & 2 deletions tests/test_copernicus_dataspace_watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ def test_publish_paths(caplog):
assert "uri" not in message_settings["data"]
assert len(messages) == 3
message = Message(rawstr=messages[0])
assert message.data["uri"] == "s3:///eodata/Sentinel-3/OLCI/OL_1_EFR___/2024/04/15/S3B_OL_1_EFR____20240415T074029_20240415T074329_20240415T094236_0179_092_035_1620_PS2_O_NR_003.SEN3"
assert message.data["uri"] == "s3://eodata/Sentinel-3/OLCI/OL_1_EFR___/2024/04/15/S3B_OL_1_EFR____20240415T074029_20240415T074329_20240415T094236_0179_092_035_1620_PS2_O_NR_003.SEN3"
assert message.data["uid"] == "S3B_OL_1_EFR____20240415T074029_20240415T074329_20240415T094236_0179_092_035_1620_PS2_O_NR_003.SEN3" # noqa
assert message.data["sensor"] == "olci"
assert message.data["filesystem"] == {"cls": "s3fs.core:S3FileSystem", "protocol": "s3", "args": [],
"profile": "someprofile"}
assert message.data["path"] == "/eodata/Sentinel-3/OLCI/OL_1_EFR___/2024/04/15/S3B_OL_1_EFR____20240415T074029_20240415T074329_20240415T094236_0179_092_035_1620_PS2_O_NR_003.SEN3" # noqa
assert message.data["path"] == "eodata/Sentinel-3/OLCI/OL_1_EFR___/2024/04/15/S3B_OL_1_EFR____20240415T074029_20240415T074329_20240415T094236_0179_092_035_1620_PS2_O_NR_003.SEN3" # noqa
assert f"Starting watch on dataspace for '{filter_string}'" in caplog.text

0 comments on commit f9f6dee

Please sign in to comment.