refactor(cli): unify ado get handling for all resources#854
Merged
Conversation
Signed-off-by: Alessandro Pomponio <alessandro.pomponio1@ibm.com>
Signed-off-by: Alessandro Pomponio <alessandro.pomponio1@ibm.com>
Signed-off-by: Alessandro Pomponio <alessandro.pomponio1@ibm.com>
Signed-off-by: Alessandro Pomponio <alessandro.pomponio1@ibm.com>
Signed-off-by: Alessandro Pomponio <alessandro.pomponio1@ibm.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This pull request refactors the
ado getcommand handlers across all resource types to use a unifiedhandle_ado_get()function. The changes consolidate duplicated output formatting logic, improve code maintainability, and provide a consistent interface for handling different output formats (TABLE, NAME, YAML, JSON, CONFIG, RAW).Resolves #848
Files Changed
📄
orchestrator/cli/resources/actuator/get.pyRefactored to use the unified
handle_ado_get()handler instead of custom table rendering logic. Removed manual NAME format handling and imports forrich.box,dataframe_to_rich_table, andADO_INFO_EMPTY_DATAFRAME.📄
orchestrator/cli/resources/actuator_configuration/get.pySimplified to use a single
handle_ado_get()call instead of branching betweenhandle_ado_get_default_format()andhandle_ado_get_special_formats(). Removed conditional logic for different output formats.📄
orchestrator/cli/resources/context/get.pyRefactored to use
handle_ado_get()for both NAME and TABLE formats (using DataFrame), and for structured formats (YAML, JSON, CONFIG) using resources. Removed manual table rendering and custom formatting logic.📄
orchestrator/cli/resources/data_container/get.pySimplified to a single
handle_ado_get()call, removing the conditional logic that branched between TABLE and other output formats. Cleaned up imports.📄
orchestrator/cli/resources/discovery_space/get.pyRefactored all three code paths (matching_point, matching_space, and standard) to use
handle_ado_get(). Removed manual table rendering withdataframe_to_rich_table()and custom format handling. Removed unused imports.📄
orchestrator/cli/resources/experiment/get.pyReplaced manual table rendering logic with
handle_ado_get()call. Moved empty DataFrame check inside the sort operation to handle it more gracefully. Removed imports forrich.box,dataframe_to_rich_table, andADO_INFO_EMPTY_DATAFRAME.📄
orchestrator/cli/resources/measurement_request/get.pySimplified to use
handle_ado_get()for rendering measurement request resources. Removed manual formatting withformat_resource_for_ado_get_custom_format()and the "getting output ready" spinner.📄
orchestrator/cli/resources/operation/get.pySimplified to a single
handle_ado_get()call, removing conditional branching between TABLE and other formats. Cleaned up imports.📄
orchestrator/cli/resources/operator/get.pyRefactored to use
handle_ado_get()with DataFrame, removing manual NAME format handling and table rendering logic. Removed imports forrich.boxanddataframe_to_rich_table.📄
orchestrator/cli/resources/sample_store/get.pySimplified to a single
handle_ado_get()call, removing conditional logic for different output formats. Cleaned up imports.📄
orchestrator/cli/utils/resources/handlers.pyMajor refactoring that introduces the unified
handle_ado_get()function and format-specific handlers (_handle_name_format(),_handle_table_format(),_handle_raw_format(),_handle_structured_formats()). This consolidates logic from the removedhandle_ado_get_default_format()andhandle_ado_get_special_formats()functions, providing a single entry point that delegates to efficient, format-specific implementations. Added helper function_write_or_print_output()for consistent output handling.