Skip to content

Commit b767988

Browse files
Read and set publisher config from file if not already set from REST request (#231)
Co-authored-by: Ashish Jagadish <ashish.jagadish@intel.com>
1 parent f527e8a commit b767988

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

  • microservices/dlstreamer-pipeline-server/src/publisher

microservices/dlstreamer-pipeline-server/src/publisher/publisher.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,6 @@ def _get_meta_publisher_config(self,meta_destination):
145145
if len(self.request["destination"]["metadata"]) == 0: # Remove the metadata from destination if list is empty
146146
self.request["destination"].pop("metadata")
147147

148-
# if no mqtt config in REST request, check if mqtt config is in app_cfg
149-
if not self.mqtt_config and self.app_cfg.get("mqtt_publisher"):
150-
self.mqtt_config = self.app_cfg.get("mqtt_publisher")
151-
if not self.opcua_config and self.app_cfg.get("opcua_publisher"):
152-
self.opcua_config = self.app_cfg.get("opcua_publisher")
153-
if not self.influx_config and self.app_cfg.get("influx_write"):
154-
self.influx_config = self.app_cfg.get("influx_write")
155-
156148
def _get_frame_publisher_config(self,frame_destination):
157149
"""Get config for frame publishers
158150
:param frame_destination: Frame destination
@@ -169,11 +161,20 @@ def _get_frame_publisher_config(self,frame_destination):
169161
self.request["destination"]["frame"].remove(dest)
170162
if len(self.request["destination"]["frame"]) == 0: # Remove the frame from destination if list is empty
171163
self.request["destination"].pop("frame")
172-
173-
# if no s3 config in REST request, check if s3 config is in app_cfg
164+
165+
def _get_publisher_config_from_config_file(self):
166+
"""Get publisher config from config file
167+
"""
168+
# Get the config only if it is not already set in the REST request
169+
if not self.mqtt_config and self.app_cfg.get("mqtt_publisher"):
170+
self.mqtt_config = self.app_cfg.get("mqtt_publisher")
171+
if not self.opcua_config and self.app_cfg.get("opcua_publisher"):
172+
self.opcua_config = self.app_cfg.get("opcua_publisher")
174173
if not self.s3_config and self.app_cfg.get("S3_write"):
175174
self.s3_config = self.app_cfg["S3_write"]
176-
175+
if not self.influx_config and self.app_cfg.get("influx_write"):
176+
self.influx_config = self.app_cfg["influx_write"]
177+
177178
def _get_publishers(self):
178179
"""Get publishers based on config.
179180
@@ -202,6 +203,7 @@ def _get_publishers(self):
202203
self._get_meta_publisher_config(meta_destination)
203204
if not self.request["destination"]:
204205
self.request.pop("destination")
206+
self._get_publisher_config_from_config_file()
205207

206208
# NOTE: always add S3_write first in the list of publishers, essential for blocking case
207209
if self.s3_config:

0 commit comments

Comments
 (0)