Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto
#144 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
20/100
Tipo de issue
Nueva funcionalidad
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
python
Área
backend

Línea de trabajo

Lea la implementación de calibrate en dripline/core y compárela con SimpleSCPIEntity.on_get. Reproduzca el comando GET power_monitor_voltage usando power_detector.py, power_detector_calibration.py y la definición del endpoint. La tarea está terminada cuando el on_get heredado pueda usar la calibración personalizada sin el NameError reportado ni decoradores en conflicto.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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)

Lenguaje dominante
Python
Estrellas
3
Forks
6
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

  • Incluye un Dockerfile o un archivo de Docker Compose
  • Tiene una plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de driplineorg/dripline-python

Todos los issues de driplineorg/dripline-python

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.