Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

I can't seem to overwrite calibration decoration when I inherit on_get from SimpleSCPIEntity

Đang mở
#144 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
Loại issue
Tính năng
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
backend

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

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của driplineorg/dripline-python

Tất cả issue của driplineorg/dripline-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.