refactor: extract CLI orchestration logic into focused modules#255
Open
edmundmiller wants to merge 5 commits intospr/edmundmiller/refactor-extract-resource-parsers-into-individual-modulesfrom
Conversation
Create foundational architecture to support one-file-per-command pattern by organizing code into logical modules. This is the first step in a stacked PR series to improve code maintainability and AI-assisted development. Changes: - Create new directory structure: commands/, resources/, core/, utils/ - Move core modules to core/ package: - seqeraplatform.py → core/seqeraplatform.py - overwrite.py → core/overwrite.py - on_exists.py → core/on_exists.py - Extract YAML utilities to utils/yaml_utils.py: - load_and_merge_yaml_files() - filter_blocks_by_targets() - get_resource_order() - Move general utilities to utils/helpers.py - Add backward compatibility imports in original locations This refactoring maintains 100% backward compatibility while laying the groundwork for subsequent PRs that will extract resource-specific parsers and handlers into individual modules. Test Plan: - All 111 unit tests pass - No breaking changes to public API - Backward compatibility maintained through import shims 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Pull Request: #250
Extract all YAML parsing logic from helper.py into dedicated resource
modules, implementing the one-file-per-command pattern. Each resource
type now has its own self-contained parser module.
Changes:
- Create shared parsing utilities in resources/_parsers.py:
- parse_generic() for simple key-value resources
- parse_type_based() for type/file-path resources
- process_params_dict() for parameter handling
- resolve_dataset_reference() for dataset resolution
- Create 15 resource parser modules:
- Generic parsers (8): organizations, workspaces, labels, members,
participants, secrets, studios, data_links
- Type-based parsers (3): credentials, compute_envs, actions
- Special parsers (4): teams, datasets, pipelines, launch
- Update helper.py to use new resource parsers:
- Import PARSERS dict from resources package
- Simplify parse_block() to use parser_module.parse()
- Maintain backward compatibility with existing code
- Update resources/__init__.py:
- Export all resource modules
- Provide PARSERS mapping dict
Benefits:
- Improved modularity: Each resource type is self-contained (~30-80 lines)
- Better testability: Parsers can be tested independently
- AI-friendly: Smaller, focused files vs 542-line monolith
- Easier extensibility: Add resources by creating single file
Test Plan:
- All 111 unit tests pass
- No breaking changes to existing functionality
- Verified parsing logic identical to previous implementation
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Pull Request: #251
refactor: extract resource handlers into individual modules
Extract handler functions from helper.py into resource modules, completing
the modularization pattern started in PR1 and PR2. Each resource module now
owns both parsing (parse()) and execution (handle()) logic.
Changes:
- Created seqerakit/resources/_handlers.py with handle_generic() utility
- Added handle() functions to 6 special resource modules:
* teams: Two-phase team creation + member addition
* members: Two-phase member add/update for role assignment
* participants: Two-phase participant add/update for role assignment
* compute_envs: JSON import detection + primary flag handling
* pipelines: URL/JSON detection for add vs import
* launch: Direct method call without 'add' subcommand
- Updated resources/__init__.py with HANDLERS registry
- Updated cli.py BlockParser to use dynamic HANDLERS lookup
- Added deprecation warnings to helper.py handler functions
- All 111 tests passing
Benefits:
- Complete separation of concerns by resource type
- Easier to understand and maintain resource-specific logic
- Consistent pattern: parse() + handle() in each module
- Backward compatibility maintained via deprecation warnings
Extract large orchestration functions from cli.py and helper.py into dedicated modules, making the codebase more maintainable and easier to work with for both AI and humans. Changes: - Created seqerakit/core/block_parser.py: Extracted BlockParser class (88 lines) * Manages routing of YAML blocks to appropriate handlers * Handles on_exists behavior and resource deletion - Created seqerakit/utils/file_discovery.py: Extracted find_yaml_files() function * Separates filesystem concerns from CLI * Supports files, directories, and stdin input - Created seqerakit/core/yaml_processor.py: Extracted YAML processing orchestration * parse_all_yaml(): Loads and merges multiple YAML files * parse_yaml_block(): Parses individual resource blocks * parse_block(): Routes to resource-specific parsers * find_name(): Detects duplicate resources * RESOURCE_ORDER: Defines resource creation order - Created seqerakit/resources/_deprecated.py: Moved deprecated handler wrappers * Makes legacy code obvious and contained * All functions emit DeprecationWarnings - Updated seqerakit/cli.py: Simplified from 366 to ~200 lines * Imports from new modular locations * Focuses on CLI argument handling only - Updated seqerakit/helper.py: Added explicit re-exports with __all__ * Maintains backward compatibility for external code * Re-exports functions from new locations - Updated tests to use correct module paths * All 111 tests passing Benefits: - Smaller, focused files with clear responsibilities - Easier to understand and maintain individual modules - Better separation of concerns (CLI, orchestration, file I/O) - Consistent with modular pattern from PR1-PR3 - No breaking changes for end users
7e284d3 to
e4d4514
Compare
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.
Extract large orchestration functions from cli.py and helper.py into dedicated modules, making the codebase more maintainable and easier to work with for both AI and humans.
Changes:
Created seqerakit/core/block_parser.py: Extracted BlockParser class (88 lines)
Created seqerakit/utils/file_discovery.py: Extracted find_yaml_files() function
Created seqerakit/core/yaml_processor.py: Extracted YAML processing orchestration
Created seqerakit/resources/_deprecated.py: Moved deprecated handler wrappers
Updated seqerakit/cli.py: Simplified from 366 to ~200 lines
Updated seqerakit/helper.py: Added explicit re-exports with all
Updated tests to use correct module paths
Benefits: