DTSW-7453-dts-commands-update-fails-at-first-run #122
Merged
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.
This pull request introduces several improvements to how command set configurations are imported and refreshed within the shell, focusing on better module loading, improved error handling, and robustness against failed command set loads. The most important changes include switching to direct file-based module loading to avoid caching issues, ensuring proper refresh of command sets after download, and handling cases where command sets fail to load commands.
Improvements to command set configuration loading:
import_commandset_configurationto load configuration modules directly from their file path usingimportlib.util.spec_from_file_location, assigning each a unique module name to prevent caching issues between different command sets.pathattribute on the default configuration when a custom configuration is not found, ensuring consistency.Robustness and error handling:
CommandSet.refresh, configuration is now reloaded using the improved importer, and command loading is more robust by defaulting to an empty dictionary if no commands are found.CommandSet.download, the refresh step is moved outside the try/except block to ensure the command set is always refreshed after a successful clone, regardless of exceptions during cloning.Shell.load_commands, command sets with no commands (e.g., those that failed to load) are now skipped, preventing errors during command loading.