Skip to content

Implement missing System Telemetry and System Commands methods in python#2569

Merged
mcosgriff merged 5 commits intomainfrom
2532-implement-missing-systemtelemetry-and-systemcommands-methods-in-python
Dec 1, 2025
Merged

Implement missing System Telemetry and System Commands methods in python#2569
mcosgriff merged 5 commits intomainfrom
2532-implement-missing-systemtelemetry-and-systemcommands-methods-in-python

Conversation

@mcosgriff
Copy link
Copy Markdown
Contributor

@mcosgriff mcosgriff commented Nov 25, 2025

Python Methods Added

This branch implements missing Python methods that were already present in the Ruby codebase.

System class (openc3/python/openc3/system/system.py)

Added class-level properties (via metaclass) to access singleton instance attributes:

  • System.targets (property getter/setter at lines 42-58)

    • Ruby counterpart: instance_attr_reader :targets at openc3/lib/openc3/system/system.rb:39
  • System.packet_config (property getter/setter at lines 61-77)

    • Ruby counterpart: instance_attr_reader :packet_config at openc3/lib/openc3/system/system.rb:42
  • System.commands (property getter/setter at lines 80-96)

    • Ruby counterpart: instance_attr_reader :commands at openc3/lib/openc3/system/system.rb:45
  • System.telemetry (property getter/setter at lines 99-115)

    • Ruby counterpart: instance_attr_reader :telemetry at openc3/lib/openc3/system/system.rb:48
  • System.limits (property getter/setter at lines 118-134)

    • Ruby counterpart: instance_attr_reader :limits at openc3/lib/openc3/system/system.rb:51

Telemetry class (openc3/python/openc3/packets/telemetry.py)

  • newest_packet(target_name, item_name) at line 92

    • Ruby counterpart: def newest_packet at openc3/lib/openc3/packets/telemetry.rb:227
  • packet_and_item(target_name, packet_name, item_name) at line 115

    • Ruby counterpart: def packet_and_item at openc3/lib/openc3/packets/telemetry.rb:94
  • value(target_name, packet_name, item_name, value_type) at line 134

    • Ruby counterpart: def value at openc3/lib/openc3/packets/telemetry.rb:115
  • values_and_limits_states(item_array, value_types) at line 149

    • Ruby counterpart: def values_and_limits_states at openc3/lib/openc3/packets/telemetry.rb:133

PacketConfig class (openc3/python/openc3/packets/packet_config.py)

  • to_config(output_dir) at line 293

    • Ruby counterpart: def to_config at openc3/lib/openc3/packets/packet_config.rb:276
  • to_xtce(output_dir) at line 375

    • Ruby counterpart: def to_xtce at openc3/lib/openc3/packets/packet_config.rb:331

Typing

Added type hints to the methods.

None checking

Added a bunch of checks for None to remove the PyLance errors.

Ruff Checks

https://docs.astral.sh/ruff/rules/if-else-block-instead-of-if-exp/

Closes #2532

… classes

Implement comprehensive type hints and defensive programming patterns across
config parser, packet config, telemetry, and system modules to improve type
safety and error handling.

BREAKING CHANGE: SystemMeta properties now raise RuntimeError instead of
returning None when System instance is not initialized. Code accessing
System.telemetry, System.commands, etc. before System.instance() is called
will now receive explicit errors.

Changes:
- Add comprehensive type hints to Telemetry class with TYPE_CHECKING pattern
  to avoid circular imports
- Add explanatory comments for TYPE_CHECKING blocks
- Implement SystemMeta property setters for all singleton attributes
  (targets, packet_config, commands, telemetry, limits)
- Change SystemMeta property getters to raise RuntimeError with clear message
  when instance_obj is None instead of silently returning None/empty dict
- Add defensive None checks in ConfigParser methods (verify_num_parameters,
  verify_parameter_naming, parse_errors)
- Add defensive None checks in PacketConfig for current_packet and current_item
  access across multiple keyword handlers
- Implement XTCE file detection with NotImplementedError and clear error message
- Fix type narrowing in parse_errors() using isinstance() instead of issubclass()
- Add local typed variable pattern (line_buffer: str) to resolve Optional string
  concatenation issues
- Add type: ignore[has-type] comments to suppress ambiguous generic instance
  variable access warnings
- Fix test_commands.py setUp to properly initialize System instance

Impact:
- 246 tests passing (up from 199 originally failing)
- 48 originally failing tests now fixed
- 47 test_commands.py tests now passing
- Only 3 remaining failures are pre-existing jsonpath_ng dependency issues
- Improved error messages provide clearer debugging information
- Type checkers (Pylance/mypy) now have complete type information

Files modified:
- openc3/python/openc3/config/config_parser.py
- openc3/python/openc3/packets/packet_config.py
- openc3/python/openc3/packets/telemetry.py
- openc3/python/openc3/packets/parsers/xtce_converter.py
- openc3/python/openc3/system/system.py
- openc3/python/test/packets/test_packet_config.py
- openc3/python/test/packets/test_commands.py
…g-systemtelemetry-and-systemcommands-methods-in-python
@codecov
Copy link
Copy Markdown

codecov bot commented Nov 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.12%. Comparing base (3246784) to head (e418959).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2569      +/-   ##
==========================================
- Coverage   79.18%   79.12%   -0.06%     
==========================================
  Files         662      663       +1     
  Lines       51305    51800     +495     
  Branches      735      735              
==========================================
+ Hits        40626    40988     +362     
- Misses      10599    10732     +133     
  Partials       80       80              
Flag Coverage Δ
python 81.10% <ø> (-0.21%) ⬇️
ruby-api 84.41% <ø> (-0.08%) ⬇️
ruby-backend 82.14% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mcosgriff mcosgriff marked this pull request as ready for review November 25, 2025 20:12
mcosgriff and others added 3 commits November 25, 2025 13:15
Co-authored-by: aikido-pr-checks[bot] <169896070+aikido-pr-checks[bot]@users.noreply.github.com>
Co-authored-by: aikido-pr-checks[bot] <169896070+aikido-pr-checks[bot]@users.noreply.github.com>
@jmthomas jmthomas changed the title 2532 implement missing systemtelemetry and systemcommands methods in python Implement missing systemtelemetry and systemcommands methods in python Nov 25, 2025
@jmthomas jmthomas changed the title Implement missing systemtelemetry and systemcommands methods in python Implement missing System Telemetry and System Commands methods in python Nov 26, 2025
Copy link
Copy Markdown
Member

@jmthomas jmthomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was there a specific use-case for this code? Why did you add this?

@mcosgriff
Copy link
Copy Markdown
Contributor Author

mcosgriff commented Nov 26, 2025

Was there a specific use-case for this code? Why did you add this?

Ticket looked like and opportunity to explore the codebase more.

@ryanmelt
Copy link
Copy Markdown
Member

Use case was python based conversions for a customer.

@mcosgriff mcosgriff merged commit 2039b05 into main Dec 1, 2025
29 of 31 checks passed
@mcosgriff mcosgriff deleted the 2532-implement-missing-systemtelemetry-and-systemcommands-methods-in-python branch December 1, 2025 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement missing System.telemetry and System.commands methods in Python

3 participants