Add Pydantic model CLI conversion and improve error handling#258
Open
Add Pydantic model CLI conversion and improve error handling#258
Conversation
This commit includes two major improvements: 1. Add to_cli_args() method to Pydantic models - Implement base to_cli_args() in SeqeraResource - Add model-specific overrides for Credential, ComputeEnv, Action, Pipeline, and Launch - Simplify CommandBuilder classes to use model's to_cli_args() - Add Command.execute() method for self-executing commands - Simplify handler functions to use command.execute(sp) 2. Add --traceback flag to reduce verbose error output - Hide tracebacks by default for cleaner error messages - Add --traceback flag to show full tracebacks when debugging - Improve Pydantic ValidationError formatting - Add catch-all exception handler Tests: - Add test_to_cli_args.py with 28 tests for model CLI conversion - Add test_command_execute.py with 15 tests for command execution - Add tests for --traceback flag behavior - All 184 tests passing 🤖 Generated with Claude Code Co-Authored-By: Claude <[email protected]>
- Remove duplicate 'labels' key in ComputeEnv.from_api_response() - Fix type hint in Pipeline.from_api_response() (Pipelines -> Pipeline) - Apply ruff formatting and trailing whitespace fixes 🤖 Generated with Claude Code Co-Authored-By: Claude <[email protected]>
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.
Add Pydantic model CLI conversion and improve error handling
Summary
This PR refactors the architecture to simplify the transformation pipeline from Pydantic models to CLI commands and adds a
--tracebackflag to reduce verbose error output for better user experience.Changes
1. Model-to-CLI Conversion (
to_cli_args()method)to_cli_args()method inSeqeraResource(seqerakit/models/base.py) that converts Pydantic models directly to CLI argument listsCredential: type as positional argumentComputeEnv: type and config-mode as positional argumentsAction: type as positional, params excludedPipeline: URL as positional, params excludedLaunch: pipeline as positional, params excluded2. Simplified Command Architecture
Command.execute()method (seqerakit/helper.py) for self-executing commandsCommandBuilderclasses to usemodel.to_cli_args()instead of manual argument buildingcommand.execute(sp)patternBefore:
After:
3. Error Handling Improvements
--tracebackflag to control traceback visibility (seqerakit/cli.py)ValidationErrorformatting with field-level error messagesMigration Notes
No migration required - this is a refactoring with full backward compatibility.