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

9.1.2

  - added "all" query parameter for semantics, to request complete semantic data model
  - fixed bug when requesting enum or time measurements and parameters
parent e20c105c
Branches
Tags 9.1.2
No related merge requests found
Pipeline #348968 passed
[![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
Current stable version: 9.1.1
Current stable version: 9.1.2
## Installation
1. Install the WZL-UDI package via pip
......@@ -58,6 +58,10 @@ Funded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation)
## Recent changes
**9.1.2** - 2024-01-19
- added "all" query parameter for semantics, to request complete semantic data model
- fixed bug when requesting enum or time measurements and parameters
**9.1.1** - 2024-01-18
- bug fix of subjects of license paths in semantic data packages
......
......@@ -4,7 +4,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
setup(name='wzl-udi',
version='9.1.1',
version='9.1.2',
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",
......
......@@ -193,7 +193,8 @@ class HTTPServer(object):
# serializing the element
try:
if semantic:
response = item.serialize_semantics(semantic)
recursive = request.query is not None and 'all' in request.query
response = item.serialize_semantics(semantic, recursive)
else:
response = item.serialize(keys, self._legacy_mode, HTTP_GET)
status = 200
......
......@@ -383,7 +383,7 @@ class Component(Element):
for child in self.children:
child.load_semantics(profiles_path, metadata_path, f"{parent_name}{self.uuid[4:].capitalize()}")
def serialize_semantics(self, kind: str) -> rdflib.Graph:
def serialize_semantics(self, kind: str, recursive=False) -> rdflib.Graph:
if self._metadata_profile is None or self._metadata is None:
raise SerialisationException('No semantic information have been provided during initialization.')
......@@ -393,6 +393,11 @@ class Component(Element):
result = self._metadata
else:
raise DeviceException('The provided kind of semantic information cannot be returned.')
if recursive:
for child in self._components + self._measurements + self._parameters:
result += child.serialize_semantics(kind, recursive)
return result
def resolve_semantic_path(self, suffix: str) -> (Element, str):
......
......@@ -113,7 +113,7 @@ class Element(ABC):
self._metadata.add((rdflib.URIRef(self.semantic_name), Namespaces.schema.license, Semantics.metadata_license))
@abstractmethod
def serialize_semantics(self, kind: str) -> rdflib.Graph:
def serialize_semantics(self, kind: str, recursive: bool = False) -> rdflib.Graph:
...
def resolve_semantic_path(self, suffix: str) -> ('Element', str):
......
......@@ -88,9 +88,9 @@ class Figure(Element, ABC):
else:
value = self.get()
if self._datatype == 'time':
if self._datatype == Datatype.TIME:
value = serialize_time(value)
elif self._datatype == 'enum':
elif self._datatype == Datatype.ENUM:
value = str(value)
except Exception as e:
......
......@@ -191,7 +191,7 @@ class Function(Element):
# This method does nothing intentionally, as we do not have any semantic definition for function
pass
def serialize_semantics(self, kind: str) -> rdflib.Graph:
def serialize_semantics(self, kind: str, recursive=False) -> rdflib.Graph:
# This method does nothing intentionally, as we do not have any semantic definition for function
return None
......
......@@ -172,7 +172,7 @@ class Measurement(Figure):
except Exception as e:
raise SerialisationException('{}: The measurement can not be deserialized. {}'.format(uuid, e))
def serialize_semantics(self, kind: str) -> rdflib.Graph:
def serialize_semantics(self, kind: str, recursive=False) -> rdflib.Graph:
if kind == 'profile':
result = self._metadata_profile
elif kind == 'metadata':
......
......@@ -136,7 +136,7 @@ class Parameter(Figure):
else:
raise ReadOnlyException(self._uuid, self._name)
def serialize_semantics(self, kind: str) -> rdflib.Graph:
def serialize_semantics(self, kind: str, recursive=False) -> rdflib.Graph:
if kind == 'profile':
result = self._metadata_profile
elif kind == 'metadata':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment