fix(digital-twin): resolve offsets file from package
Load x01da_offsets.yaml relative to digital_twin.py instead of the process working directory so the widget starts correctly from any launch location.
This commit is contained in:
@@ -58,7 +58,7 @@ from debye_bec.bec_widgets.widgets.digital_twin.types import ConfigDict
|
||||
|
||||
logger = bec_logger.logger
|
||||
|
||||
OFFSET_FILE = "debye_bec/debye_bec/bec_widgets/widgets/digital_twin/x01da_offsets.yaml"
|
||||
OFFSET_FILE = Path(__file__).with_name("x01da_offsets.yaml")
|
||||
|
||||
|
||||
class DigitalTwin(BECWidget, QWidget):
|
||||
@@ -555,11 +555,10 @@ class DigitalTwin(BECWidget, QWidget):
|
||||
|
||||
if self.offsets == {}:
|
||||
# Load offsets
|
||||
file = Path(OFFSET_FILE)
|
||||
if not file.exists():
|
||||
if not OFFSET_FILE.exists():
|
||||
raise FileNotFoundError(f"Offset file not found: {OFFSET_FILE}")
|
||||
|
||||
with file.open("r", encoding="utf-8") as f:
|
||||
with OFFSET_FILE.open("r", encoding="utf-8") as f:
|
||||
data = yaml.safe_load(f)
|
||||
|
||||
if not isinstance(data, dict):
|
||||
@@ -600,7 +599,7 @@ class DigitalTwin(BECWidget, QWidget):
|
||||
intro_label.setWordWrap(True)
|
||||
layout.addWidget(intro_label)
|
||||
|
||||
file = QLabel(OFFSET_FILE)
|
||||
file = QLabel(str(OFFSET_FILE))
|
||||
file.setWordWrap(True)
|
||||
font = QFont()
|
||||
font.setItalic(True)
|
||||
|
||||
Reference in New Issue
Block a user