Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Python Unified Device Interface
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WZL-IQS-Public
Sensor Interfacing Language (SOIL)
Python Unified Device Interface
Commits
595930b8
Commit
595930b8
authored
1 year ago
by
Matthias Stefan Bodenbenner
Browse files
Options
Downloads
Patches
Plain Diff
- increased logging verbosity of streaming class
- fixed streaming of semantic measurements
parent
61655cca
No related branches found
No related tags found
No related merge requests found
Pipeline
#377225
passed
1 year ago
Stage: build
Stage: push
Changes
5
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
README.md
+5
-1
5 additions, 1 deletion
README.md
requirements-dev.txt
+2
-1
2 additions, 1 deletion
requirements-dev.txt
setup.py
+1
-1
1 addition, 1 deletion
setup.py
src/soil/measurement.py
+0
-1
0 additions, 1 deletion
src/soil/measurement.py
src/soil/stream.py
+26
-13
26 additions, 13 deletions
src/soil/stream.py
with
34 additions
and
17 deletions
README.md
+
5
−
1
View file @
595930b8
[

](https://git-ce.rwth-aachen.de/wzl-mq-ms/forschung-lehre/lava/unified-device-interface/python/commits/master)
[

](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: 10.0.
3
Current stable version: 10.0.
4
## Installation
## Installation
1.
Install the WZL-UDI package via pip
1.
Install the WZL-UDI package via pip
...
@@ -69,6 +69,10 @@ Funded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation)
...
@@ -69,6 +69,10 @@ Funded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation)
## Recent changes
## Recent changes
**10.0.4**
- 2024-03-21
-
increased logging verbosity of streaming class
-
fixed streaming of semantic measurements
**10.0.3**
- 2024-03-21
**10.0.3**
- 2024-03-21
-
added license field to semantic provision of measurement range
-
added license field to semantic provision of measurement range
...
...
This diff is collapsed.
Click to expand it.
requirements-dev.txt
+
2
−
1
View file @
595930b8
aiohttp==3.
8.4
aiohttp==3.
9.1
Deprecated==1.2.13
Deprecated==1.2.13
nest-asyncio==1.5.6
nest-asyncio==1.5.6
pytest==7.1.1
pytest==7.1.1
rdflib==7.0.0
rdflib==7.0.0
pytz==2024.1
sphinx==3.5.2
sphinx==3.5.2
sphinx-rtd-theme==1.0.0
sphinx-rtd-theme==1.0.0
wzl-mqtt~=2.6.1
wzl-mqtt~=2.6.1
\ No newline at end of file
This diff is collapsed.
Click to expand it.
setup.py
+
1
−
1
View file @
595930b8
...
@@ -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
=
'
10.0.
3
'
,
version
=
'
10.0.
4
'
,
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
"
,
...
...
This diff is collapsed.
Click to expand it.
src/soil/measurement.py
+
0
−
1
View file @
595930b8
...
@@ -259,7 +259,6 @@ class Measurement(Variable):
...
@@ -259,7 +259,6 @@ class Measurement(Variable):
data_graph
.
bind
(
Semantics
.
prefix
,
Semantics
.
namespace
)
data_graph
.
bind
(
Semantics
.
prefix
,
Semantics
.
namespace
)
uncertainty_subject
=
Semantics
.
namespace
[
f
'
{
self
.
_semantic_name
}
MeasurementUncertainty
'
]
uncertainty_subject
=
Semantics
.
namespace
[
f
'
{
self
.
_semantic_name
}
MeasurementUncertainty
'
]
covariance
=
self
.
__getitem__
(
'
covariance
'
,
0
)
covariance
=
self
.
__getitem__
(
'
covariance
'
,
0
)
print
(
covariance
)
if
covariance
is
not
None
:
if
covariance
is
not
None
:
rdf_covariance
=
self
.
serialize_value
(
data_graph
,
covariance
)
rdf_covariance
=
self
.
serialize_value
(
data_graph
,
covariance
)
data_graph
.
add
((
uncertainty_subject
,
Namespaces
.
rdf
.
type
,
Namespaces
.
si
.
CoverageInterval
))
data_graph
.
add
((
uncertainty_subject
,
Namespaces
.
rdf
.
type
,
Namespaces
.
si
.
CoverageInterval
))
...
...
This diff is collapsed.
Click to expand it.
src/soil/stream.py
+
26
−
13
View file @
595930b8
import
datetime
import
datetime
import
json
import
json
import
traceback
from
abc
import
ABC
,
abstractmethod
from
abc
import
ABC
,
abstractmethod
from
typing
import
List
,
Callable
,
Any
,
Union
,
Dict
,
Tuple
from
typing
import
List
,
Callable
,
Any
,
Union
,
Dict
,
Tuple
...
@@ -20,8 +21,15 @@ logger = root_logger.get(__name__)
...
@@ -20,8 +21,15 @@ logger = root_logger.get(__name__)
class
JobError
(
Exception
):
class
JobError
(
Exception
):
def
__init__
(
self
):
def
__init__
(
self
,
message
:
str
,
predeccessor
:
Exception
=
None
):
pass
self
.
_predecessor
:
predeccessor
self
.
_message
=
message
@property
def
message
(
self
)
->
str
:
return
self
.
_message
class
Job
(
ABC
):
class
Job
(
ABC
):
...
@@ -73,7 +81,7 @@ class Job(ABC):
...
@@ -73,7 +81,7 @@ class Job(ABC):
time
=
time
if
time
is
not
None
else
datetime
.
datetime
.
now
()
time
=
time
if
time
is
not
None
else
datetime
.
datetime
.
now
()
return
self
.
_next
is
not
None
and
self
.
_next
<=
time
and
self
.
_is_triggered
()
return
self
.
_next
is
not
None
and
self
.
_next
<=
time
and
self
.
_is_triggered
()
except
Exception
as
e
:
except
Exception
as
e
:
raise
JobError
()
raise
JobError
(
'
is_triggered failed
'
,
predeccessor
=
e
)
@abstractmethod
@abstractmethod
def
_is_triggered
(
self
)
->
bool
:
def
_is_triggered
(
self
)
->
bool
:
...
@@ -97,7 +105,7 @@ class Job(ABC):
...
@@ -97,7 +105,7 @@ class Job(ABC):
def
data
(
self
,
model
:
Component
=
None
)
->
Dict
:
def
data
(
self
,
model
:
Component
=
None
)
->
Dict
:
if
model
is
None
:
if
model
is
None
:
raise
JobError
()
raise
JobError
(
'
Can not retrieve data. Model is missing
'
)
try
:
try
:
uuids
=
self
.
topic
.
split
(
'
/
'
)
uuids
=
self
.
topic
.
split
(
'
/
'
)
data
=
model
.
__getitem__
(
uuids
).
serialize
([],
False
)
data
=
model
.
__getitem__
(
uuids
).
serialize
([],
False
)
...
@@ -109,11 +117,11 @@ class Job(ABC):
...
@@ -109,11 +117,11 @@ class Job(ABC):
data
[
'
timestamp
'
]
=
variable
.
serialize_time
(
datetime
.
datetime
.
now
())
data
[
'
timestamp
'
]
=
variable
.
serialize_time
(
datetime
.
datetime
.
now
())
return
data
return
data
except
Exception
as
e
:
except
Exception
as
e
:
raise
JobError
()
raise
JobError
(
'
Can not retrieve data. Due to another error.
'
,
predeccessor
=
e
)
def
semantic_data
(
self
,
model
:
Component
=
None
)
->
(
str
,
rdflib
.
Graph
):
def
semantic_data
(
self
,
model
:
Component
=
None
)
->
(
str
,
rdflib
.
Graph
):
if
model
is
None
:
if
model
is
None
:
raise
JobError
()
raise
JobError
(
'
Can not retrieve semantic data. Model is missing
'
)
try
:
try
:
uuids
=
self
.
topic
.
split
(
'
/
'
)
uuids
=
self
.
topic
.
split
(
'
/
'
)
element
=
model
.
__getitem__
(
uuids
)
element
=
model
.
__getitem__
(
uuids
)
...
@@ -122,7 +130,7 @@ class Job(ABC):
...
@@ -122,7 +130,7 @@ class Job(ABC):
data
+=
element
.
serialize_semantics
(
ResourceType
.
observation
)
data
+=
element
.
serialize_semantics
(
ResourceType
.
observation
)
measurement_subject
=
\
measurement_subject
=
\
list
((
data
.
subjects
(
predicate
=
Namespaces
.
rdf
.
type
,
object
=
Namespaces
.
so
il
.
Measurement
)))[
0
]
list
((
data
.
subjects
(
predicate
=
Namespaces
.
rdf
.
type
,
object
=
Namespaces
.
so
sa
.
Observation
)))[
0
]
# replace value
# replace value
data
.
remove
((
None
,
Namespaces
.
qudt
.
value
,
None
))
data
.
remove
((
None
,
Namespaces
.
qudt
.
value
,
None
))
...
@@ -135,7 +143,7 @@ class Job(ABC):
...
@@ -135,7 +143,7 @@ class Job(ABC):
return
element
.
semantic_name
,
data
return
element
.
semantic_name
,
data
except
Exception
as
e
:
except
Exception
as
e
:
raise
JobError
()
raise
JobError
(
'
Can not semantic retrieve data. Due to another error.
'
,
predeccessor
=
e
)
class
FixedJob
(
Job
):
class
FixedJob
(
Job
):
...
@@ -291,6 +299,8 @@ class StreamScheduler(object):
...
@@ -291,6 +299,8 @@ class StreamScheduler(object):
try
:
try
:
self
.
_publisher
.
get
(
'
tier1
'
).
publish
(
job
.
topic
,
message
,
1
)
self
.
_publisher
.
get
(
'
tier1
'
).
publish
(
job
.
topic
,
message
,
1
)
except
ClientNotFoundError
:
except
ClientNotFoundError
:
logger
.
warn
(
'
Client not found error occured.
'
)
logger
.
warn
(
traceback
.
format_exc
())
self
.
_publisher
.
publish
(
job
.
topic
,
message
,
1
)
self
.
_publisher
.
publish
(
job
.
topic
,
message
,
1
)
# try to send semantic data package
# try to send semantic data package
...
@@ -305,16 +315,19 @@ class StreamScheduler(object):
...
@@ -305,16 +315,19 @@ class StreamScheduler(object):
try
:
try
:
self
.
_publisher
.
get
(
'
tier2
'
).
publish
(
url
,
message
,
1
)
self
.
_publisher
.
get
(
'
tier2
'
).
publish
(
url
,
message
,
1
)
except
ClientNotFoundError
:
except
ClientNotFoundError
:
logger
.
warn
(
'
Client not found error occured.
'
)
logger
.
warn
(
traceback
.
format_exc
())
self
.
_publisher
.
publish
(
url
,
message
,
1
)
self
.
_publisher
.
publish
(
url
,
message
,
1
)
except
JobError
:
except
JobError
as
e
:
pass
logger
.
error
(
e
.
message
)
logger
.
error
(
traceback
.
format_exc
())
job
.
schedule
()
job
.
schedule
()
next
=
job
.
determine_next
(
next
)
next
=
job
.
determine_next
(
next
)
except
JobError
:
except
JobError
as
e
:
#
logger.error(
traceback.format_exc()
)
logger
.
error
(
e
.
message
)
# job.stop
()
logger
.
error
(
traceback
.
format_exc
()
)
pass
pass
if
next
is
None
:
if
next
is
None
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment