I can't seem to overwrite calibration decoration when I inherit on_get from SimpleSCPIEntity
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 20/100
Hướng nghiên cứu
Đọc phần triển khai calibrate trong dripline/core và so sánh với SimpleSCPIEntity.on_get. Tái hiện lệnh GET power_monitor_voltage bằng power_detector.py, power_detector_calibration.py và định nghĩa endpoint. Công việc được xem là hoàn tất khi on_get được kế thừa có thể sử dụng hiệu chuẩn tùy chỉnh mà không gặp NameError đã báo cáo hoặc các decoration xung đột.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Sorry, I don't have time to write something thoughtful. I'm going to paste the slack conversation related to this issue because it's better than nothing.
Raphael Cervantes 10:59 AM
@Ben LaRoque I'm trying to extend SimpleSCPIEntity such that on_get has a custom calibration
from dripline.core import Entity, calibrate, ThrowReply
from dripline.implementations import SimpleSCPIEntity
import logging
from .power_detector_calibration import zx47_50_cal
logger = logging.getLogger(__name__)
__all__ = []
__all__.append("PowerDetectorEntity")
class PowerDetectorEntity(SimpleSCPIEntity):
'''
Entity with power detector calibration
'''
@calibrate([zx47_50_cal])
def on_get(self):
What should go in the body of on_get if it's the same as SimpleSCPIEntity
Ben LaRoque 11:03 AM
ummm:
def on_get(self):
return super().on_get()
(edited)
11:04
should be the same as:
def on_get(self):
return SimpleSCPIEntity.on_get(self)
Raphael Cervantes 11:05 AM
ok. dope
11:05
I was about to just copy what was in SimpleSCPIEntity, which would have been bad OOP
Ben LaRoque 11:07 AM
the first one uses the class method resolution order to find the next on_get implementation, the latter specifically uses the one that is first in the MRO of SimpleSCPIEntity; here those should be the same, but there could be a time when there’s a subtle difference and you care
11:07
(like if you have multiple inheritance)
Raphael Cervantes 11:08 AM
ohhh
11:08
got it
Raphael Cervantes 11:42 AM
@Ben LaRoque I'm getting a name error when I run this get command with the custom calibration and I don't understand why
2021-08-16T18:38:10[INFO ] dripline.implementations.ethernet_scpi_service(172) -> sync: 'MEASure:VOLTage:DC?\r\n' -> '-7.55700000E-06'
2021-08-16T18:38:10[DEBUG ] dripline.implementations.ethernet_scpi_service(143) -> should return:
-7.55700000E-06
2021-08-16T18:38:10[DEBUG ] dripline.implementations.entity_endpoints(50) -> raw result is: -7.55700000E-06
2021-08-16T18:38:10[DEBUG ] dripline.core.calibrate(30) -> attempting to calibrate
2021-08-16T18:38:10[DEBUG ] dripline.core.calibrate(43) -> formatted cal is:
zx47_50_cal(-7.55700000E-06)
NameError
zx47_50_cal(-7.55700000E-06)
name 'zx47_50_cal' is not defined
this is where the calibration function is defined: https://github.com/axiondarkmatterexperiment/dripline-orpheus/blob/ad12b0d05cfff7b[…]/extensions/power_detector_entity/power_detector_calibration.py
this is where it decorates the on_get function: https://github.com/axiondarkmatterexperiment/dripline-orpheus/blob/ad12b0d05cfff7b[…]e5e/dripline/extensions/power_detector_entity/power_detector.py
did I implement this incorrectly?
power_detector_calibration.py
https://github.com/axiondarkmatterexperiment/dripline-orpheus|axiondarkmatterexperiment/dripline-orpheusaxiondarkmatterexperiment/dripline-orpheus | Added by GitHub
power_detector.py
https://github.com/axiondarkmatterexperiment/dripline-orpheus|axiondarkmatterexperiment/dripline-orpheusaxiondarkmatterexperiment/dripline-orpheus | Added by GitHub
Raphael Cervantes 11:59 AM
here is my endpoint definiton:
endpoints:
- name: power_monitor_voltage
module: PowerDetectorEntity
base_str: MEASure:VOLTage:DC
calibration: "zx47_50_cal({})"
log_routing_key_prefix: sensor_double_precision
Raphael Cervantes 12:13 PM
I explicitly defined on_get and have gotten further https://github.com/axiondarkmatterexperiment/dripline-orpheus/blob/95f88fd0ae03363[…]8cd/dripline/extensions/power_detector_entity/power_detector.py
I'm guessing the inheritence caused conflicting calibration decorations?
power_detector.py
@calibrate([zx47_50_cal])
https://github.com/axiondarkmatterexperiment/dripline-orpheus|axiondarkmatterexperiment/dripline-orpheusaxiondarkmatterexperiment/dripline-orpheus | Added by GitHub
Raphael Cervantes 12:31 PM
ok I have it working now
12:31
but I couldn't use inheritence
12:32
maybe there's a way to override the calibration decoration from the base class?
Ben LaRoque 12:33 PM
oh… um
12:33
that may be a design problem, would need to think about it (edited)
12:33
(dripline side, not your side)
- Ngôn ngữ chính
- Python
- Star
- 3
- Fork
- 6
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của driplineorg/dripline-python
-
Log on set delayĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
driplineorg/dripline-python#222 · 1 bình luận ·
-
Create Logging WrapperĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
driplineorg/dripline-python#221 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 50/100
driplineorg/dripline-python#214 · 2 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
driplineorg/dripline-python#207 ·
-
Inconsistent response behavior with a 'values' arrayCó thể làm lại được @pkolbeck đã nhận 484 ngày trước và không có pull request nào đang mở. Đang mở
driplineorg/dripline-python#204 · 1 bình luận · 2 người được giao ·
Tất cả issue của driplineorg/dripline-python
Issue tương tự
-
area:core-platform effort:S priority:P3 status:in-review type:test
Độ khó 2/5 Dưới một giờ Mức phù hợp với người mới 80/100
randomparity/kdive#3246 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Requantification library converts m/z to mass with the hydrogen-atom mass instead of the proton massĐang mởbug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
nf-core/metaboigniter#130 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
common-workflow-language/cwl-utils#477 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add dependabotĐang mởfeat
Độ khó 2/5 Dưới một giờ Mức phù hợp với người mới 72/100
open-nudge/opentemplate#204 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
github-stale-ci-pr-closer: KV state is double-wrapped, never persists, and hits the depth-32 limitCó thể đã có người làm @VascoSch92 đã nhận hôm nay. Đang mởpriority:medium ready-for-dev
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
OpenHands/extensions#781 ·
Maintainer thường phản hồi trong vòng 1 ngày