Skip to content

TUI API Compatibility Issue - DeviceTemplateManager.query_dtdl_model() Not Found #1

@YumTaha

Description

@YumTaha

Describe the set-up

  • Board: (STWIN.box) Not applicable (TUI fails to launch before device detection)
  • IDE/Compiler: Python 3.13.5 with Virtual Environment (.venv)
  • STDatalog SDK Version: 1.2.0
  • Platform: Windows 11
  • Installation Method: Official STDATALOG-PYSDK_install.bat

Describe the bug

The STDatalog TUI (Text User Interface) fails to launch due to an AttributeError where DeviceTemplateManager.query_dtdl_model() method is not found. The TUI is importing the wrong class and calling a non-existent method, making the entire TUI functionality unavailable.

How To Reproduce the bug

  1. Global behavior: Attempting to launch the STDatalog TUI for device data logging management
  2. Suspected modules: stdatalog_pnpl.DTDL.device_template_manager - API mismatch between classes
  3. Use case: User tries to run TUI in interactive mode to detect and configure STMicroelectronics devices
  4. Reproduction steps:
    • Install STDatalog SDK v1.2.0 using official installer
    • Navigate to TUI directory: stdatalog_examples/gui_applications/stdatalog/TUI/
    • Run: python stdatalog_TUI.py -i
    • Observe AttributeError on startup

Error Details

(.venv) PS C:\Users\momayizt\OneDrive\Desktop\stdatalog\stdatalog-pysdk\stdatalog_examples\gui_applications\stdatalog\TUI> python stdatalog_TUI.py -i
2025-07-18 08:33:11,136 - HSDatalogApp - INFO - Checking additional required packages... (stdatalog_TUI.py:51)
2025-07-18 08:33:11,137 - HSDatalogApp - INFO - All required packages are installed. (stdatalog_TUI.py:74)
2025-07-18 08:33:11,586 - HSDatalogApp.stdatalog_pnpl.DTDL.device_template_manager - INFO - Online catalog data matches local catalog data.
2025-07-18 08:33:11,586 - HSDatalogApp.stdatalog_pnpl.DTDL.device_template_manager - INFO - Date: 2025-07-17 13:15:11.255594, Version: 0.8.0, Checksum: d7deff580b9683a217d724d8eae300d8
2025-07-18 08:33:11,586 - HSDatalogApp.stdatalog_core.HSD_link.communication.PnPL_HSD.hsd_dll - INFO - Platform Architecture: 64bit  
2025-07-18 08:33:11,907 - HSDatalogApp.stdatalog_core.HSD_link.communication.PnPL_HSD.PnPLHSD_com_manager - INFO - Communication Engine UP (libhs_datalog_v2 DLL/so) (PnPLHSD_com_manager.py:45)
2025-07-18 08:33:11,908 - HSDatalogApp.stdatalog_core.HSD_link.HSDLink_v2 - INFO - Vespucci PnPL Commands (HSDLink_v2.py:98)
2025-07-18 08:33:11,908 - HSDatalogApp.stdatalog_core.HSD_link.HSDLink - INFO - Commmunication Opened correctly
Traceback (most recent call last):
  File "C:\Users\momayizt\OneDrive\Desktop\stdatalog\stdatalog-pysdk\stdatalog_examples\gui_applications\stdatalog\TUI\stdatalog_TUI.py", line 334, in <module>
    hsd_TUI()
    ~~~~~~~^^
  File "C:\Users\momayizt\OneDrive\Desktop\stdatalog\stdatalog-pysdk\.venv\Lib\site-packages\click\core.py", line 1161, in __call__
    return self.main(*args, **kwargs)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "C:\Users\momayizt\OneDrive\Desktop\stdatalog\stdatalog-pysdk\.venv\Lib\site-packages\click\core.py", line 1082, in main
    rv = self.invoke(ctx)
  File "C:\Users\momayizt\OneDrive\Desktop\stdatalog\stdatalog-pysdk\.venv\Lib\site-packages\click\core.py", line 1443, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\momayizt\OneDrive\Desktop\stdatalog\stdatalog-pysdk\.venv\Lib\site-packages\click\core.py", line 788, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\momayizt\OneDrive\Desktop\stdatalog\stdatalog-pysdk\stdatalog_examples\gui_applications\stdatalog\TUI\stdatalog_TUI.py", line 309, in hsd_TUI
    hsd_info = HSDInfo(tui_flags)
  File "C:\Users\momayizt\OneDrive\Desktop\stdatalog\stdatalog-pysdk\stdatalog_examples\gui_applications\stdatalog\TUI\stdatalog_TUI.py", line 144, in __init__
    self.load_device_template(board_id,fw_id)
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "C:\Users\momayizt\OneDrive\Desktop\stdatalog\stdatalog-pysdk\stdatalog_examples\gui_applications\stdatalog\TUI\stdatalog_TUI.py", line 152, in load_device_template
    dev_template_json = DeviceTemplateManager.query_dtdl_model(board_id, fw_id)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'DeviceTemplateManager' has no attribute 'query_dtdl_model'

Additional context

Root Cause Analysis

The issue occurs because:

  1. Wrong Class Import: The TUI imports DeviceTemplateManager but calls a method that doesn't exist on this class
  2. API Mismatch: The query_dtdl_model() method exists on DeviceCatalogManager, not DeviceTemplateManager

Affected File and Line

File: stdatalog_examples/gui_applications/stdatalog/TUI/stdatalog_TUI.py
Line: 152

Current problematic code:

from stdatalog_pnpl.DTDL.device_template_manager import DeviceTemplateManager

# ...

def load_device_template(self, board_id, fw_id):
    dev_template_json = DeviceTemplateManager.query_dtdl_model(board_id, fw_id)  # ❌ FAILS

API Analysis

DeviceTemplateManager (Currently Imported) - Available Methods:

['get_component', 'get_components', 'get_components_name_list', 'get_root_component']

DeviceCatalogManager (Contains Required Method) - Available Methods:

['add_dtdl_model', 'compare_catalogs', 'download_dtdl_model_from_url', 'get_board_names_list', 
 'get_boards_list', 'get_device_model', 'get_firmwares_list', 'get_instance', 'get_path_from_dtmi', 
 'get_url_from_dtmi', 'query_dtdl_model', 'remove_custom_dtdl_model', 'remove_dtdl_model_from_local_catalog', 
 'update_catalog']

Proposed Fix

Option 1: Use DeviceCatalogManager.query_dtdl_model()

from stdatalog_pnpl.DTDL.device_template_manager import DeviceTemplateManager, DeviceCatalogManager

def load_device_template(self, board_id, fw_id):
    dev_template_json = DeviceCatalogManager.query_dtdl_model(board_id, fw_id)  # ✅ WORKS

Option 2: Use DeviceCatalogManager.get_device_model()

from stdatalog_pnpl.DTDL.device_template_manager import DeviceTemplateManager, DeviceCatalogManager

def load_device_template(self, board_id, fw_id):
    # Note: get_device_model expects integer values, not hex strings
    dev_template_json = DeviceCatalogManager.get_device_model(int(board_id, 16), int(fw_id, 16))  # ✅ WORKS

Impact Assessment

  • Severity: High - TUI completely non-functional
  • Scope: All TUI functionality is blocked
  • Workaround: Use GUI applications instead of TUI

System Context

  • All dependencies are properly installed (asciimatics, pywin32, etc.)
  • Device catalog is successfully loaded (log shows: "Online catalog data matches local catalog data")
  • Communication engine initializes correctly
  • Error occurs during device template loading phase

System Information:

Platform Architecture: 64bit
Communication Engine: libhs_datalog_v2 DLL/so
Catalog Version: 0.8.0
Catalog Date: 2025-07-17 13:15:11.255594
Catalog Checksum: d7deff580b9683a217d724d8eae300d8

Note: This appears to be an API breaking change or oversight in the TUI implementation that wasn't caught during SDK release testing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions