Skip to content

Commit

Permalink
Fix fs publishing to be a dict, not a string
Browse files Browse the repository at this point in the history
  • Loading branch information
mraspaud committed Apr 19, 2024
1 parent 6000004 commit ed8bd3a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/pytroll_watchers/publisher.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Common functions for publishing messages."""

import datetime
import json
import logging
from contextlib import closing, suppress
from copy import deepcopy
Expand Down Expand Up @@ -29,7 +30,7 @@ def file_publisher_from_generator(generator, publisher_config, message_config):
amended_message_config = deepcopy(message_config)
amended_message_config["data"]["uri"] = file_item.as_uri()
with suppress(AttributeError):
amended_message_config["data"]["fs"] = file_item.fs.to_json()
amended_message_config["data"]["fs"] = json.loads(file_item.fs.to_json())
aliases = amended_message_config.pop("aliases", {})
apply_aliases(aliases, file_metadata)
amended_message_config["data"].update(file_metadata)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_bucket_notification_watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ def test_publish_paths(patched_bucket_listener, caplog): # noqa
message = Message(rawstr=messages[0])
assert message.data["uri"] == "s3://viirs-data/sdr/SVM13_npp_d20240408_t1006227_e1007469_b64498_c20240408102334392250_cspp_dev.h5"
assert message.data["sensor"] == "viirs"
assert message.data["fs"] == ('{"cls": "s3fs.core.S3FileSystem", "protocol": "s3", "args": [], '
'"profile": "someprofile"}')
assert message.data["fs"] == {"cls": "s3fs.core.S3FileSystem", "protocol": "s3", "args": [],
"profile": "someprofile"}
assert "Starting watch on 'viirs-data'" in caplog.text


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 @@ -113,6 +113,6 @@ def test_publish_paths(caplog):
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["sensor"] == "olci"
assert message.data["fs"] == ('{"cls": "s3fs.core.S3FileSystem", "protocol": "s3", "args": [], '
'"profile": "someprofile"}')
assert message.data["fs"] == {"cls": "s3fs.core.S3FileSystem", "protocol": "s3", "args": [],
"profile": "someprofile"}
assert f"Starting watch on dataspace for '{filter_string}'" in caplog.text

0 comments on commit ed8bd3a

Please sign in to comment.