- 
                Notifications
    You must be signed in to change notification settings 
- Fork 58
Pull CCSDS config from dictionary if available #259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: devel
Are you sure you want to change the base?
Conversation
…cleanup and refactor type loading
…pattern, code clarity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the Ground Data System (GDS) configuration and type management system to improve how types and constants are loaded from JSON dictionaries. The changes move away from string-based type representations to using actual type class objects, and introduce support for loading constants from the dictionary.
Key changes:
- Renamed FwTypeJsonLoadertoTypeJsonLoaderand expanded it to load all type definitions
- Introduced a new ConstantJsonLoaderto load constant values from the dictionary
- Refactored ConfigManagerto store type classes directly instead of string representations, addingset_type()/get_type()andset_constant()/get_constant()methods
- Changed default FwPacketDescriptorTypefromU32TypetoU16Typeto match CCSDS standards
- Removed the apid.pymodule and integrated its functionality intoApidTypeclass
- Updated tests to use new API and override default values where necessary
Reviewed Changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description | 
|---|---|
| test/fprime_gds/common/loaders/test_json_loader.py | Updated imports, test assertions to use type classes, and formatting improvements | 
| test/fprime_gds/common/encoders/test_pkt_encoder.py | Updated to use new set_type()API and override defaultFwPacketDescriptorType | 
| test/fprime_gds/common/encoders/test_event_encoder.py | Updated to use new set_type()API and override defaultFwPacketDescriptorType | 
| test/fprime_gds/common/encoders/test_ch_encoder.py | Updated to use new set_type()API and override defaultFwPacketDescriptorType | 
| test/fprime_gds/common/distributor/test_distributor.py | Updated to use new set_type()API and override defaultFwPacketDescriptorType | 
| test/fprime_gds/common/communication/ccsds/test_space_packet.py | Updated test data to match new default U16Typepacket descriptor size | 
| src/fprime_gds/executables/cli.py | Updated to use new loader names and iterate over types/constants with new API | 
| src/fprime_gds/common/utils/data_desc_type.py | Refactored to use metaclass for dynamic enum loading from ConfigManager | 
| src/fprime_gds/common/utils/config_manager.py | Refactored to store type classes directly and support constants | 
| src/fprime_gds/common/models/dictionaries.py | Updated to use new loaders and property names | 
| src/fprime_gds/common/loaders/type_json_loader.py | Renamed from fw_type_json_loader.pyand expanded to load all types | 
| src/fprime_gds/common/loaders/json_loader.py | Added parse_type_definition()method for processing type definitions | 
| src/fprime_gds/common/loaders/constant_json_loader.py | New loader for constants from dictionary | 
| src/fprime_gds/common/distributor/distributor.py | Removed key framing support code | 
| src/fprime_gds/common/communication/ccsds/space_packet.py | Updated to use ApidType.from_data()instead of removedAPIDclass | 
| src/fprime_gds/common/communication/ccsds/space_data_link.py | Added support for loading spacecraft ID and frame size from dictionary constants | 
| src/fprime_gds/common/communication/ccsds/apid.py | Removed file - functionality moved to ApidTypeclass | 
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Constructs and returns python dictionaries keyed on id and name | ||
| Args: | ||
| _: Unused argument (inherited) | ||
| Returns: | ||
| A tuple with two Fw type dictionaries (python type dict): | ||
| (id_dict, name_dict). The keys should be the type id and | ||
| name fields respectively and the values should be type name | ||
| strings. Note: An empty id dictionary is returned since there | ||
| are no id fields in the Fw type alias JSON dictionary entries. | 
    
      
    
      Copilot
AI
    
    
    
      Oct 31, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docstring describes the return value incorrectly. This is a constant loader, not a type loader. The description should reference constant dictionaries with name-to-int mappings, not 'Fw type dictionaries' with 'type name strings'. The return structure is actually (empty_id_dict, name_to_value_dict, versions).
| Constructs and returns python dictionaries keyed on id and name | |
| Args: | |
| _: Unused argument (inherited) | |
| Returns: | |
| A tuple with two Fw type dictionaries (python type dict): | |
| (id_dict, name_dict). The keys should be the type id and | |
| name fields respectively and the values should be type name | |
| strings. Note: An empty id dictionary is returned since there | |
| are no id fields in the Fw type alias JSON dictionary entries. | |
| Constructs and returns dictionaries for constants defined in the JSON dictionary. | |
| Args: | |
| _: Unused argument (inherited) | |
| Returns: | |
| A tuple containing: | |
| - An empty id dictionary (constants do not have ids) | |
| - A dictionary mapping constant qualified names to their values | |
| - The versions information from the dictionary | 
| # These configs give the types of fields in the binary data | ||
| def get_constant(self, name: str) -> int: | ||
| """ | ||
| Retrieve a constant from the config for parsing by returning an instance | 
    
      
    
      Copilot
AI
    
    
    
      Oct 31, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docstring incorrectly states 'returning an instance of the associated constant.' Constants are integer values, not instances. Should be 'returning the value of the associated constant.'
| Retrieve a constant from the config for parsing by returning an instance | |
| Retrieve a constant from the config for parsing by returning the value | 
| constant_value = self.__prop["constants"].get(name, None) | ||
| if constant_value is None: | ||
| raise ConfigBadTypeException(name, "Unknown constant name") | ||
| # Return an instance of the constant | 
    
      
    
      Copilot
AI
    
    
    
      Oct 31, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment 'Return an instance of the constant' is incorrect. The method returns an integer value, not an instance. Should be '# Return the value of the constant'.
| # Return an instance of the constant | |
| # Return the value of the constant | 
| def set_constant(self, name: str, value: int): | ||
| """ | ||
| Set a constant in the config for parsing by associating a name with | ||
| a constant class. | 
    
      
    
      Copilot
AI
    
    
    
      Oct 31, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docstring incorrectly states 'associating a name with a constant class.' The method associates a name with an integer value, not a class. Should be 'associating a name with a constant value.'
| a constant class. | |
| a constant value. | 
| pass # Config value not found, move on | ||
| try: | ||
| dict_frame_size = ConfigManager.get_instance().get_constant("ComCfg.TmFrameFixedSize") | ||
| except ConfigBadTypeException: | ||
| pass # Config value not found, move on | 
    
      
    
      Copilot
AI
    
    
    
      Oct 31, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected spacing in comment. Should be '# Config value not found, move on' with a space after '#'.
| pass # Config value not found, move on | |
| try: | |
| dict_frame_size = ConfigManager.get_instance().get_constant("ComCfg.TmFrameFixedSize") | |
| except ConfigBadTypeException: | |
| pass # Config value not found, move on | |
| pass # Config value not found, move on | |
| try: | |
| dict_frame_size = ConfigManager.get_instance().get_constant("ComCfg.TmFrameFixedSize") | |
| except ConfigBadTypeException: | |
| pass # Config value not found, move on | 
| pass # Config value not found, move on | ||
| try: | ||
| dict_frame_size = ConfigManager.get_instance().get_constant("ComCfg.TmFrameFixedSize") | ||
| except ConfigBadTypeException: | ||
| pass # Config value not found, move on | 
    
      
    
      Copilot
AI
    
    
    
      Oct 31, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected spacing in comment. Should be '# Config value not found, move on' with a space after '#'.
| pass # Config value not found, move on | |
| try: | |
| dict_frame_size = ConfigManager.get_instance().get_constant("ComCfg.TmFrameFixedSize") | |
| except ConfigBadTypeException: | |
| pass # Config value not found, move on | |
| pass # Config value not found, move on | |
| try: | |
| dict_frame_size = ConfigManager.get_instance().get_constant("ComCfg.TmFrameFixedSize") | |
| except ConfigBadTypeException: | |
| pass # Config value not found, move on | 
Change Description
Fix nasa/fprime#3664
DataDescTypeandApidType(almost aliases) to be Enum-like but pulled from the ConfigManager at runtime