Skip to content
Snippets Groups Projects
Commit 76a523ce authored by Matthias Stefan Bodenbenner's avatar Matthias Stefan Bodenbenner
Browse files

9.0.1- bug fixes & small refactoring

parent 99c01cf9
No related branches found
No related tags found
No related merge requests found
[![Build](https://git-ce.rwth-aachen.de/wzl-mq-ms/forschung-lehre/lava/unified-device-interface/python/badges/master/pipeline.svg)](https://git-ce.rwth-aachen.de/wzl-mq-ms/forschung-lehre/lava/unified-device-interface/python/commits/master) [![Build](https://git-ce.rwth-aachen.de/wzl-mq-ms/forschung-lehre/lava/unified-device-interface/python/badges/master/pipeline.svg)](https://git-ce.rwth-aachen.de/wzl-mq-ms/forschung-lehre/lava/unified-device-interface/python/commits/master)
# Python Unified Device Interface # Python Unified Device Interface
Current stable version: 9.0.0 Current stable version: 9.0.1
## Installation ## Installation
1. Install the WZL-UDI package via pip 1. Install the WZL-UDI package via pip
...@@ -53,10 +53,14 @@ https://doi.org/10.1117/12.2527461 ...@@ -53,10 +53,14 @@ https://doi.org/10.1117/12.2527461
The authors acknowledge funding from the LaVA project (Large Volume Applications, contract 17IND03 of the European Metrology Programme for Innovation and Research EMPIR). The EMPIR initiative is co-funded by the European Union’s Horizon 2020 research and innovation programme and the EMPIR Participating States. The authors acknowledge funding from the LaVA project (Large Volume Applications, contract 17IND03 of the European Metrology Programme for Innovation and Research EMPIR). The EMPIR initiative is co-funded by the European Union’s Horizon 2020 research and innovation programme and the EMPIR Participating States.
Funded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) under Germany's Excellence Strategy – EXC-2023 Internet of Production – 390621612. Funded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) under Germany's Excellence Strategy – EXC-2023 Internet of Production – 390621612.
Funded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) under Project-ID 432233186 -- AIMS. Funded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) under Project-ID 432233186 -- AIMS.
## Recent changes ## Recent changes
**9.0.1** - 2024-01-11
- bug fix of semantic name resolution
**9.0.0** - 2024-01-10 **9.0.0** - 2024-01-10
- added semantic features - added semantic features
- the device can return profiles, metadata and data defined and structured according to semantic web standards using RDF and SHACL - the device can return profiles, metadata and data defined and structured according to semantic web standards using RDF and SHACL
... ...
......
...@@ -7,4 +7,4 @@ rdflib==7.0.0 ...@@ -7,4 +7,4 @@ rdflib==7.0.0
sphinx==3.5.2 sphinx==3.5.2
sphinx-rtd-theme==1.0.0 sphinx-rtd-theme==1.0.0
strict-rfc3339==0.7 strict-rfc3339==0.7
wzl-mqtt~=2.6.0 wzl-mqtt~=2.6.1
\ No newline at end of file \ No newline at end of file
...@@ -4,7 +4,7 @@ with open("README.md", "r", encoding="utf-8") as fh: ...@@ -4,7 +4,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read() long_description = fh.read()
setup(name='wzl-udi', setup(name='wzl-udi',
version='9.0.0', version='9.0.1',
url='https://git-ce.rwth-aachen.de/wzl-mq-public/soil/python', url='https://git-ce.rwth-aachen.de/wzl-mq-public/soil/python',
project_urls={ project_urls={
"Bug Tracker": "https://git-ce.rwth-aachen.de/wzl-mq-public/soil/python/-/issues", "Bug Tracker": "https://git-ce.rwth-aachen.de/wzl-mq-public/soil/python/-/issues",
...@@ -25,7 +25,7 @@ setup(name='wzl-udi', ...@@ -25,7 +25,7 @@ setup(name='wzl-udi',
'Deprecated~=1.2.13', 'Deprecated~=1.2.13',
'nest-asyncio~=1.5.6', 'nest-asyncio~=1.5.6',
'strict-rfc3339==0.7', 'strict-rfc3339==0.7',
'wzl-mqtt~=2.5.3', 'wzl-mqtt~=2.6.1',
'rdflib~=7.0.0' 'rdflib~=7.0.0'
], ],
zip_safe=False) zip_safe=False)
...@@ -180,7 +180,7 @@ class HTTPServer(object): ...@@ -180,7 +180,7 @@ class HTTPServer(object):
semantic = request.query['semantic'] semantic = request.query['semantic']
if len(splitted_request) > 0 and splitted_request[0] == Semantics.prefix: if len(splitted_request) > 0 and splitted_request[0] == Semantics.prefix:
item, semantic = self.root.resolve_semantic_path(splitted_request[1:]) item, semantic = self.root.resolve_semantic_path(splitted_request[1])
else: else:
try: try:
item = self.root[splitted_request] item = self.root[splitted_request]
... ...
......
...@@ -395,20 +395,13 @@ class Component(Element): ...@@ -395,20 +395,13 @@ class Component(Element):
raise DeviceException('The provided kind of semantic information cannot be returned.') raise DeviceException('The provided kind of semantic information cannot be returned.')
return result return result
def resolve_semantic_path(self, path: List[str]): def resolve_semantic_path(self, suffix: str) -> (Element, str):
try: try:
super().resolve_semantic_path(path) return super().resolve_semantic_path(suffix)
except ChildNotFoundException: except ChildNotFoundException:
triples = list(self._metadata.triples((None, Namespaces.rdf.type, None)))
triples = list(filter(lambda x: x[2] == Namespaces.ssn.System, triples))
assert len(triples) > 0
if path[0] == triples[0][0].split('/')[-1] and len(path) == 1:
return self, 'metadata'
for child in self.children: for child in self.children:
try: try:
return child.resolve_semantic_path(path) return child.resolve_semantic_path(suffix)
except ChildNotFoundException: except ChildNotFoundException:
continue continue
... ...
......
...@@ -112,12 +112,11 @@ class Element(ABC): ...@@ -112,12 +112,11 @@ class Element(ABC):
def serialize_semantics(self, kind: str) -> rdflib.Graph: def serialize_semantics(self, kind: str) -> rdflib.Graph:
... ...
def resolve_semantic_path(self, path: List[str]) -> ('Element', str): def resolve_semantic_path(self, suffix: str) -> ('Element', str):
if len(path) == 0: if suffix == f'{self._profilename}Shape':
raise ChildNotFoundException('Could not resolve the semantic path.')
if path[0] == f'{self._profilename}Shape' and len(path) == 1:
return self, 'profile' return self, 'profile'
elif suffix == self.semantic_name.split('/')[-1]:
return self, 'metadata'
raise ChildNotFoundException('Could not resolve the semantic path.') raise ChildNotFoundException('Could not resolve the semantic path.')
... ...
......
...@@ -195,7 +195,7 @@ class Function(Element): ...@@ -195,7 +195,7 @@ class Function(Element):
# This method does nothing intentionally, as we do not have any semantic definition for function # This method does nothing intentionally, as we do not have any semantic definition for function
return None return None
def resolve_semantic_path(self, path: List[str]) -> ('Element', str): def resolve_semantic_path(self, suffix: str) -> (Element, str):
# This method does nothing intentionally, as we do not have any semantic definition for function # This method does nothing intentionally, as we do not have any semantic definition for function
raise ChildNotFoundException('Could not resolve the semantic path.') raise ChildNotFoundException('Could not resolve the semantic path.')
... ...
......
...@@ -6,8 +6,6 @@ import rdflib ...@@ -6,8 +6,6 @@ import rdflib
from deprecated import deprecated from deprecated import deprecated
from .datatype import Datatype from .datatype import Datatype
from .element import Element
from .error import ChildNotFoundException
from .figure import Figure from .figure import Figure
from .semantics import Semantics, Namespaces from .semantics import Semantics, Namespaces
from ..utils import root_logger from ..utils import root_logger
...@@ -223,22 +221,10 @@ class Measurement(Figure): ...@@ -223,22 +221,10 @@ class Measurement(Figure):
raise DeviceException('The provided kind of semantic information cannot be returned.') raise DeviceException('The provided kind of semantic information cannot be returned.')
return result return result
def resolve_semantic_path(self, path: List[str]) -> (Element, str):
try:
super().resolve_semantic_path(path)
except ChildNotFoundException:
triples = list(self._metadata.triples((None, Namespaces.rdf.type, None)))
triples = list(filter(lambda x: x[2] == Namespaces.sosa.ObservableProperty, triples))
assert len(triples) > 0
if path[0] == triples[0][0].split('/')[-1] and len(path) == 1:
return self, 'metadata'
raise ChildNotFoundException('Could not resolve the semantic path.')
@property @property
def semantic_name(self) -> str: def semantic_name(self) -> str:
if self._metadata is None: if self._metadata is None:
return "" return ""
subject = next(self._metadata.subjects(predicate=Namespaces.rdf.type, object=Namespaces.sosa.ObservableProperty)) subject = next(
self._metadata.subjects(predicate=Namespaces.rdf.type, object=Namespaces.sosa.ObservableProperty))
return subject.toPython() return subject.toPython()
...@@ -6,7 +6,7 @@ from typing import Dict, Callable, Any, List ...@@ -6,7 +6,7 @@ from typing import Dict, Callable, Any, List
import rdflib import rdflib
from .datatype import Datatype from .datatype import Datatype
from .error import ReadOnlyException, ChildNotFoundException from .error import ReadOnlyException
from .figure import Figure from .figure import Figure
from .semantics import Semantics, Namespaces from .semantics import Semantics, Namespaces
from ..utils import root_logger from ..utils import root_logger
...@@ -154,19 +154,6 @@ class Parameter(Figure): ...@@ -154,19 +154,6 @@ class Parameter(Figure):
raise DeviceException('The provided kind of semantic information cannot be returned.') raise DeviceException('The provided kind of semantic information cannot be returned.')
return result return result
def resolve_semantic_path(self, path: List[str]) -> ('Element', str):
try:
super().resolve_semantic_path(path)
except ChildNotFoundException:
triples = list(self._metadata.triples((None, Namespaces.rdf.type, None)))
triples = list(filter(lambda x: x[2] == Namespaces.ssn.Property, triples))
assert len(triples) > 0
if path[0] == triples[0][0].split('/')[-1] and len(path) == 1:
return self, 'metadata'
raise ChildNotFoundException('Could not resolve the semantic path.')
@property @property
def semantic_name(self) -> str: def semantic_name(self) -> str:
if self._metadata is None: if self._metadata is None:
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment