Skip to content

Commit

Permalink
skip main handler on metadata publication (#481)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkralidis authored Jul 6, 2023
1 parent 1a45e7f commit 7c709b8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 8 additions & 0 deletions wis2box-management/wis2box/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ def __init__(self, filepath: str, topic_hierarchy: str = None):
th = self.filepath
fuzzy = True

if '/metadata/' in th:
msg = 'Passing on handling metadata in workflow'
raise NotHandledError(msg)

try:
self.topic_hierarchy, self.plugins = validate_and_load(
th, self.filetype, fuzzy=fuzzy)
Expand Down Expand Up @@ -130,3 +134,7 @@ def publish(self) -> bool:
upsert_collection_item(index_name, geojson)

return True


class NotHandledError(Exception):
pass
5 changes: 4 additions & 1 deletion wis2box-management/wis2box/pubsub/subscribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from wis2box.api import setup_collection
from wis2box.env import (BROKER_HOST, BROKER_PORT, BROKER_USERNAME,
BROKER_PASSWORD, STORAGE_SOURCE, STORAGE_ARCHIVE)
from wis2box.handler import Handler
from wis2box.handler import Handler, NotHandledError
from wis2box.plugin import load_plugin, PLUGINS
from wis2box.pubsub.message import gcm

Expand All @@ -47,6 +47,9 @@ def handle(filepath):
for plugin in handler.plugins:
for filepath in plugin.files():
LOGGER.info(f'Public filepath: {filepath}')
except NotHandledError as err:
msg = f'not handled error: {err}'
LOGGER.debug(msg)
except ValueError as err:
msg = f'handle() error: {err}'
LOGGER.error(msg)
Expand Down

0 comments on commit 7c709b8

Please sign in to comment.