Skip to content

Commit

Permalink
Add support for publisher config
Browse files Browse the repository at this point in the history
Add an option to use publisher configuration from a file.
Needs merger of posttroll #35
pytroll/posttroll#35
  • Loading branch information
gerritholl committed Dec 22, 2021
1 parent ade47d8 commit 82afee5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion bin/viirs_dr_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ def parse_args():
type=str,
default=None,
help="The file to log to (stdout per default).")
parser.add_argument("-p", "--publisher", type=str,
help="File with publisher config (YAML).")

return parser.parse_args()

Expand Down Expand Up @@ -134,7 +136,8 @@ def main():
viirs_sdr_call,
viirs_sdr_options,
int(OPTIONS.get("granule_time_tolerance", 10)),
int(OPTIONS.get("ncpus", 1))
int(OPTIONS.get("ncpus", 1)),
publisher_config=args.publisher,
)


Expand Down
8 changes: 7 additions & 1 deletion cspp_runner/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ def npp_rolling_runner(
viirs_sdr_options,
granule_time_tolerance=10,
ncpus=1,
publisher_config=None
):
"""The NPP/VIIRS runner. Listens and triggers processing on RDR granules."""

Expand Down Expand Up @@ -609,10 +610,15 @@ def npp_rolling_runner(
LOG.info("Will use %d CPUs when running CSPP instances" % ncpus)
viirs_proc = ViirsSdrProcessor(ncpus, level1_home)

if publisher_config is None:
pubconf = {"name": "viirs_dr_runner", "port": 0}
else:
pubconf = yaml.safe_load(publisher_config)

LOG.debug("Subscribe topics = %s", str(subscribe_topics))
with posttroll.subscriber.Subscribe('',
subscribe_topics, True) as subscr:
with Publish('viirs_dr_runner', 0) as publisher:
with Publish(**pubconf) as publisher:
while True:
viirs_proc.initialise()
for msg in subscr.recv(timeout=300):
Expand Down

0 comments on commit 82afee5

Please sign in to comment.