Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tango
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LOFAR2.0
tango
Commits
fa162a94
Commit
fa162a94
authored
3 years ago
by
Corné Lukken
Browse files
Options
Downloads
Plain Diff
Merge branch '
L2SS-548
-log-which-attribute-errors' into 'master'
L2SS-548
: Annotate which attribute is giving errors Closes
L2SS-548
See merge request
!201
parents
984678a8
de418833
No related branches found
No related tags found
1 merge request
!201
L2SS-548: Annotate which attribute is giving errors
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tangostationcontrol/tangostationcontrol/clients/attribute_wrapper.py
+30
-2
30 additions, 2 deletions
...ncontrol/tangostationcontrol/clients/attribute_wrapper.py
with
30 additions
and
2 deletions
tangostationcontrol/tangostationcontrol/clients/attribute_wrapper.py
+
30
−
2
View file @
fa162a94
...
@@ -145,13 +145,38 @@ class attribute_wrapper(attribute):
...
@@ -145,13 +145,38 @@ class attribute_wrapper(attribute):
return
value
return
value
def
_decorate_read_function
(
self
,
read_attr_func
):
"""
Wrap an attribute read function to annotate its exceptions with our
comms_annotation to be able to identify which attribute triggered the error.
"""
def
wrapper
():
try
:
return
read_attr_func
()
except
Exception
as
e
:
raise
Exception
(
f
"
Failed to read attribute
{
self
.
comms_annotation
}
"
)
from
e
return
wrapper
def
_decorate_write_function
(
self
,
write_attr_func
):
"""
Wrap an attribute write function to annotate its exceptions with our
comms_annotation to be able to identify which attribute triggered the error.
"""
def
wrapper
(
value
):
try
:
write_attr_func
(
value
)
except
Exception
as
e
:
raise
Exception
(
f
"
Failed to write attribute
{
self
.
comms_annotation
}
"
)
from
e
return
wrapper
def
set_comm_client
(
self
,
client
):
def
set_comm_client
(
self
,
client
):
"""
"""
takes a communications client as input arguments This client should be of a class containing a
"
get_mapping
"
function
takes a communications client as input arguments This client should be of a class containing a
"
get_mapping
"
function
and return a read and write function that the wrapper will use to get/set data.
and return a read and write function that the wrapper will use to get/set data.
"""
"""
try
:
try
:
self
.
read_function
,
self
.
write_function
=
client
.
setup_attribute
(
self
.
comms_annotation
,
self
)
read_attr_func
,
write_attr_func
=
client
.
setup_attribute
(
self
.
comms_annotation
,
self
)
self
.
read_function
=
self
.
_decorate_read_function
(
read_attr_func
)
self
.
write_function
=
self
.
_decorate_write_function
(
write_attr_func
)
except
Exception
as
e
:
except
Exception
as
e
:
raise
Exception
(
f
"
Exception while setting
{
client
.
__class__
.
__name__
}
attribute with annotation:
'
{
self
.
comms_annotation
}
'"
)
from
e
raise
Exception
(
f
"
Exception while setting
{
client
.
__class__
.
__name__
}
attribute with annotation:
'
{
self
.
comms_annotation
}
'"
)
from
e
...
@@ -160,7 +185,10 @@ class attribute_wrapper(attribute):
...
@@ -160,7 +185,10 @@ class attribute_wrapper(attribute):
Asynchronous version of set_comm_client.
Asynchronous version of set_comm_client.
"""
"""
try
:
try
:
self
.
read_function
,
self
.
write_function
=
await
client
.
setup_attribute
(
self
.
comms_annotation
,
self
)
read_attr_func
,
write_attr_func
=
await
client
.
setup_attribute
(
self
.
comms_annotation
,
self
)
self
.
read_function
=
self
.
_decorate_read_function
(
read_attr_func
)
self
.
write_function
=
self
.
_decorate_write_function
(
write_attr_func
)
except
Exception
as
e
:
except
Exception
as
e
:
raise
Exception
(
f
"
Exception while setting
{
client
.
__class__
.
__name__
}
attribute with annotation:
'
{
self
.
comms_annotation
}
'"
)
from
e
raise
Exception
(
f
"
Exception while setting
{
client
.
__class__
.
__name__
}
attribute with annotation:
'
{
self
.
comms_annotation
}
'"
)
from
e
...
...
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