refactor(cli): update --use-latest to use db instead of local information#837
Merged
Conversation
Signed-off-by: Alessandro Pomponio <alessandro.pomponio1@ibm.com>
Signed-off-by: Alessandro Pomponio <alessandro.pomponio1@ibm.com>
…nfiguration 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>
Signed-off-by: Alessandro Pomponio <alessandro.pomponio1@ibm.com>
Signed-off-by: Alessandro Pomponio <alessandro.pomponio1@ibm.com>
michael-johnston
requested changes
Apr 14, 2026
Signed-off-by: Alessandro Pomponio <alessandro.pomponio1@ibm.com>
michael-johnston
approved these changes
Apr 14, 2026
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 CLI configuration system to remove the in-memory caching of latest resource identifiers and instead query them directly from the database when needed. This change improves data consistency, eliminates the need to persist resource IDs in configuration files, and ensures commands always work with the most current data.
Resolves #812
Files Changed
📄
orchestrator/cli/commands/create.pyRemoved the
ado_configuration.store()call after resource creation, as the configuration no longer needs to be persisted after tracking resource IDs.📄
orchestrator/cli/commands/describe.pyUpdated to pass
project_contextinstead of the fullado_configurationobject toget_effective_resource_id(), simplifying the function's dependencies.📄
orchestrator/cli/commands/show_details.pyUpdated to pass
project_contextinstead of the fullado_configurationobject toget_effective_resource_id().📄
orchestrator/cli/commands/show_entities.pyUpdated to pass
project_contextinstead of the fullado_configurationobject toget_effective_resource_id().📄
orchestrator/cli/commands/show_related.pyUpdated to pass
project_contextinstead of the fullado_configurationobject toget_effective_resource_id().📄
orchestrator/cli/commands/show_requests.pyUpdated to pass
project_contextinstead of the fullado_configurationobject toget_effective_resource_id().📄
orchestrator/cli/commands/show_results.pyUpdated to pass
project_contextinstead of the fullado_configurationobject toget_effective_resource_id().📄
orchestrator/cli/commands/show_summary.pyRefactored to query the database directly for the latest resource ID instead of reading from configuration. Added database query with spinner feedback for better UX.
📄
orchestrator/cli/core/config.pyRemoved the
latest_resource_idsfield fromAdoConfigurationand added a Pydantic validator to strip this deprecated field from old config files for backward compatibility. Moved thestore()call to theload()method to ensure configuration is persisted after context loading.📄
orchestrator/cli/resources/actuator_configuration/create.pyRemoved code that saved the created actuator configuration identifier to the in-memory configuration cache.
📄
orchestrator/cli/resources/discovery_space/create.pyRefactored to query the database for the latest sample store identifier instead of reading from configuration. Removed code that cached created resource identifiers.
📄
orchestrator/cli/resources/operation/create.pyRemoved the
_save_operation_identifier()helper function and all calls to save operation identifiers to configuration. Refactoredreuse_requested_latest_identifiers()to use a single batch database query instead of reading from configuration.📄
orchestrator/cli/resources/sample_store/create.pyRemoved code that saved the created sample store identifier to the in-memory configuration cache.
📄
orchestrator/cli/utils/generic/common.pyRefactored
get_effective_resource_id()to acceptproject_contextinstead ofado_configurationand query the database for latest resource IDs. Improved error messages and added database query with spinner feedback.📄
orchestrator/cli/utils/generic/wrappers.pyUpdated return type annotation for
get_sql_store()fromSQLStoretoSQLResourceStoreto match actual runtime behavior.📄
orchestrator/metastore/sql/statements.pyAdded new
resource_select_latest_by_kinds()function that generates SQL to fetch the most recently created resource for each specified kind using window functions (ROW_NUMBER). Supports batch queries for multiple resource kinds.📄
orchestrator/metastore/sqlstore.pyAdded new
get_latest_resource_identifiers_of_kinds()method toSQLResourceStorethat retrieves the identifiers of the most recently created resources for multiple kinds in a single database query, minimizing round-trips.📄
tests/fixtures/core/space.pyUpdated the
random_space_resource_from_filefixture to set thecreatedtimestamp on generated space resources, ensuring proper ordering in latest resource queries.📄
tests/metastore/test_resourcestore.pyAdded comprehensive test coverage for the new
get_latest_resource_identifiers_of_kinds()method, including tests for empty databases, single/multiple kinds, multiple resources of the same kind, missing kinds, and invalid input validation. Refactored SQLite version checks into a reusablerequires_sqlite_3_38marker.