diff --git a/README.md b/README.md index 5387ececb9862f5e8c75a2e5bee6d71521e41b8b..f7e051fb3a4ade11569bf259f3dc3e0ebd42055b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ [](https://git-ce.rwth-aachen.de/wzl-mq-ms/forschung-lehre/lava/unified-device-interface/python/commits/master) # Python Unified Device Interface -Current stable version: 10.1.0 +Current stable version: 10.1.1 ## Installation 1. Install the WZL-UDI package via pip @@ -69,6 +69,9 @@ Funded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) ## Recent changes +**10.1.1** - 2024-08-16 + - added additional flog to Scheduler to configure semantic publishing correctly and supress unnecessary errors and warnings + **10.1.0** - 2024-04-17 - added "advertisement", i.e. publishing of metadata via MQTT every x seconds - light refactoring of source code for streaming via MQTT diff --git a/setup.py b/setup.py index bd948ffecf89fddafce1dee95765d77d098049dc..c4730876f539dc9a86e45c5ba12dd825b4aee9ae 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ with open("README.md", "r", encoding="utf-8") as fh: long_description = fh.read() setup(name='wzl-udi', - version='10.1.0', + version='10.1.1', url='https://git-ce.rwth-aachen.de/wzl-mq-public/soil/python', project_urls={ "Bug Tracker": "https://git-ce.rwth-aachen.de/wzl-mq-public/soil/python/-/issues", diff --git a/src/soil/component.py b/src/soil/component.py index 7bafd96d1c3f9596c4c68012efa01a9bd54733fb..91e60c9d9f990f4cc0630863cae45c6d216230d0 100644 --- a/src/soil/component.py +++ b/src/soil/component.py @@ -334,7 +334,7 @@ class Component(Element): __import__(module_name) implementation = getattr(sys.modules[module_name], class_name)(self._implementation._device, *args, **kwargs) - except AttributeError: + except (AttributeError, ModuleNotFoundError) as e: module_name = f'hwc.{module_name}' __import__(module_name) implementation = getattr(sys.modules[module_name], class_name)(self._implementation._device, diff --git a/src/stream/scheduler.py b/src/stream/scheduler.py index eccf00e880287f657168d4abe6f35b2c02fb79c4..1bc1a15c93051c8bc908965eb33d239e4c9715c8 100644 --- a/src/stream/scheduler.py +++ b/src/stream/scheduler.py @@ -22,7 +22,7 @@ class StreamScheduler(object): """ def __init__(self, loop, schedule: List[Job], publisher: MQTTPublisher = None, - start_immediately: bool = False, dataformat: str = 'json', model: 'Component' = None, advertise: int = 10): + start_immediately: bool = False, dataformat: str = 'json', model: 'Component' = None, advertise: int = 10, semantic: bool = False): """Constructor. Args: @@ -41,6 +41,7 @@ class StreamScheduler(object): self._dataformat: str = dataformat self._model: Component = model self._advertise = advertise + self._semantic = semantic for job in schedule: if isinstance(job, AdvertisementJob): @@ -113,24 +114,25 @@ class StreamScheduler(object): self._publisher.publish(job.topic, message, 1) # try to send semantic data package - try: - url, semantic_data = job.semantic_data(self._model) - url = url.replace('https://', '').replace('http://', '') - if self._dataformat == 'json': - message = semantic_data.serialize(format='json-ld') - elif self._dataformat == 'xml': - message = semantic_data.serialize(format='xml') - + if self._semantic: try: - self._publisher.get('tier2').publish(url, message, 1) - except ClientNotFoundError: - logger.warn('Client not found error occured.') - logger.warn(traceback.format_exc()) - self._publisher.publish(url, message, 1) - - except JobError as e: - logger.error(e.message) - logger.error(traceback.format_exc()) + url, semantic_data = job.semantic_data(self._model) + url = url.replace('https://', '').replace('http://', '') + if self._dataformat == 'json': + message = semantic_data.serialize(format='json-ld') + elif self._dataformat == 'xml': + message = semantic_data.serialize(format='xml') + + try: + self._publisher.get('tier2').publish(url, message, 1) + except ClientNotFoundError: + logger.warn('Client not found error occured.') + logger.warn(traceback.format_exc()) + self._publisher.publish(url, message, 1) + + except JobError as e: + logger.error(e.message) + logger.error(traceback.format_exc()) job.schedule() next = job.determine_next(next)