Skip to content

Commit

Permalink
Merge branch 'fix-message-leave-out-hostname-in-uri' into smhi-msb-en…
Browse files Browse the repository at this point in the history
…hancements2023 and add somde debug messages

# Conflicts:
#	activefires_pp/post_processing.py
#	activefires_pp/tests/test_messaging.py
  • Loading branch information
Adam.Dybbroe committed Jul 20, 2023
2 parents d66534e + ce024b3 commit 7f97fc8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
4 changes: 3 additions & 1 deletion activefires_pp/post_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ def _national_save_and_publish(self, feature_collection, ndata, af_shapeff, msg,

def do_postprocessing_on_message(self, msg, filename):
"""Do the fires post processing on a message."""
logger.debug("Current detection id: ", str(self._fire_detection_id))
platform_name = msg.data.get('platform_name')
af_shapeff = ActiveFiresShapefileFiltering(filename, platform_name=platform_name,
timezone=self.timezone)
Expand All @@ -449,6 +450,7 @@ def do_postprocessing_on_message(self, msg, filename):

afdata = self.add_unique_day_id(afdata)
self.save_id_to_file()
logger.debug("Current detection id: ", str(self._fire_detection_id))

afdata = self.add_tb_celcius(afdata)

Expand Down Expand Up @@ -573,7 +575,6 @@ def _generate_output_message(self, filepath, input_msg, region=None):
"""Create the output message to publish."""
output_topic = generate_posttroll_topic(self.output_topic, region)
to_send = prepare_posttroll_message(input_msg, region)
# to_send['uri'] = ('ssh://%s/%s' % (self.host, filepath))
to_send['uri'] = str(filepath)
to_send['uid'] = os.path.basename(filepath)
to_send['type'] = 'GEOJSON-filtered'
Expand Down Expand Up @@ -649,6 +650,7 @@ def add_unique_day_id(self, afdata):
# Add id's to the detections:
id_list = []
for _i in range(len(afdata)):
logger.debug("Updating the fire detection id...")
self.update_fire_detection_id()
id_ = self._create_id_string()
id_list.append(id_)
Expand Down
16 changes: 8 additions & 8 deletions activefires_pp/tests/test_messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,14 @@ def test_prepare_posttroll_message(setup_comm, get_config,
test_filepath = "/my/geojson/file/path"

input_msg = Message.decode(rawstr=TEST_MSG)
result_messages = afpp.get_output_messages(test_filepath, input_msg, 1)

assert result_messages[0].data['platform_name'] == 'NOAA-20'
assert result_messages[0].data['type'] == 'GEOJSON-filtered'
assert result_messages[0].data['format'] == 'geojson'
assert result_messages[0].data['product'] == 'afimg'
assert result_messages[0].subject == '/VIIRS/L2/Fires/PP/National'
assert result_messages[0].data['uri'] == 'ssh://my.host.name//my/geojson/file/path'
res_msg = afpp.get_output_messages(test_filepath, input_msg, 1)

assert res_msg[0].data['platform_name'] == 'NOAA-20'
assert res_msg[0].data['type'] == 'GEOJSON-filtered'
assert res_msg[0].data['format'] == 'geojson'
assert res_msg[0].data['product'] == 'afimg'
assert res_msg[0].subject == '/VIIRS/L2/Fires/PP/National'
assert res_msg[0].data['uri'] == '/my/geojson/file/path'

input_msg = Message.decode(rawstr=TEST_MSG)

Expand Down

0 comments on commit 7f97fc8

Please sign in to comment.