Skip to content

Fix CLI one-sided range and resolution options#90

Merged
Ahmed-Hindy merged 1 commit into
mainfrom
dev/fix-cli-one-sided-options
Jun 12, 2026
Merged

Fix CLI one-sided range and resolution options#90
Ahmed-Hindy merged 1 commit into
mainfrom
dev/fix-cli-one-sided-options

Conversation

@Ahmed-Hindy

@Ahmed-Hindy Ahmed-Hindy commented Jun 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • reject lone CLI --width / --height options before conversion side effects
  • preserve one-sided --start-frame / --end-frame ranges as open-ended bounds
  • align the public Python API with the same paired-resolution and open-ended range behavior

Root cause

The CLI only applied resolution when both dimensions were provided, so a lone dimension was silently dropped. Frame range handling also coerced one-sided ranges into surprising closed ranges, such as --start-frame N becoming N-N.

Validation

  • uv --native-tls run --extra dev pytest tests/test_api.py tests/test_cli.py tests/test_batch.py tests/test_converter.py
  • uv --native-tls run --extra dev ruff check src\renderkit\api\processor.py src\renderkit\cli\conversion.py src\renderkit\cli\main.py src\renderkit\cli\batch.py src\renderkit\core\config.py tests\test_api.py tests\test_cli.py tests\test_batch.py tests\test_converter.py
  • uv --native-tls run --extra dev pytest
  • uv --native-tls run --extra dev mypy
  • uv --native-tls run --extra dev ruff format --check src\renderkit\api\processor.py src\renderkit\cli\conversion.py src\renderkit\cli\main.py src\renderkit\cli\batch.py src\renderkit\core\config.py tests\test_api.py tests\test_cli.py tests\test_batch.py tests\test_converter.py
  • git diff --check

Closes #86

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Resolution override parameters must now be provided as a complete pair; supplying only width or only height raises a validation error.
  • New Features

    • Frame range configuration now supports open-ended ranges, allowing you to specify start frame only, end frame only, or both.
  • Tests

    • Added comprehensive test coverage for resolution validation and frame range handling.

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR resolves issue #86 by enforcing paired resolution options and supporting open-ended frame ranges. Width and height must now be provided together; providing only one raises an error. Frame ranges can now be specified with only a start or end bound, which are passed through as open-ended configurations rather than being derived to closed ranges.

Changes

Validation for Paired Resolution and Open-Ended Frame Ranges

Layer / File(s) Summary
Config Builder Contract Update
src/renderkit/core/config.py
ConversionConfigBuilder.with_frame_range() now accepts Optional[int] for both start and end parameters instead of requiring both to be non-optional, enabling open-ended frame range configurations.
CLI Validation Helpers
src/renderkit/cli/conversion.py
New validate_paired_resolution() enforces width and height are used together, raising click.UsageError if only one is provided. New apply_frame_range() conditionally applies optional frame bounds to a builder. The validator is wired into base_conversion_config_builder().
Processor API Validation
src/renderkit/api/processor.py, tests/test_api.py
RenderKit.convert_exr_sequence_to_mp4() validates paired width/height and applies frame ranges by passing bounds directly to with_frame_range() instead of deriving defaults. Tests verify one-sided resolution is rejected and one-sided frame ranges are preserved as open-ended.
Batch Convert Command
src/renderkit/cli/batch.py, tests/test_batch.py
batch_convert imports and calls validate_paired_resolution() before directory setup. Test verifies the command exits with code 2 and correct error message when one-sided resolution is provided.
Main Convert Command Integration
src/renderkit/cli/main.py, tests/test_cli.py, tests/test_converter.py
convert_exr_sequence imports and calls validate_paired_resolution() and apply_frame_range() to replace inline conditional logic. Parameterized tests verify resolution validation, validation ordering against filesystem checks, and open-ended frame range handling. Config builder test covers open-ended ranges directly.

Sequence Diagram

sequenceDiagram
    participant CliUser as CLI User
    participant ConvertCmd as convert_exr_sequence<br/>Command
    participant ValidateRes as validate_paired_<br/>resolution
    participant ConfigBuilder as ConversionConfigBuilder
    participant ApplyRange as apply_frame_range
    participant RenderKit as RenderKit API
    
    CliUser->>ConvertCmd: --width 1920 (no --height)
    ConvertCmd->>ValidateRes: validate_paired_resolution(1920, None)
    ValidateRes-->>ConvertCmd: click.UsageError
    ConvertCmd-->>CliUser: exit code 2, error message
    
    CliUser->>ConvertCmd: --width 1920 --height 1080 --start-frame 100
    ConvertCmd->>ValidateRes: validate_paired_resolution(1920, 1080)
    ValidateRes-->>ConvertCmd: OK
    ConvertCmd->>ConfigBuilder: with_resolution(1920, 1080)
    ConfigBuilder-->>ConvertCmd: builder
    ConvertCmd->>ApplyRange: apply_frame_range(builder, 100, None)
    ApplyRange->>ConfigBuilder: with_frame_range(100, None)
    ConfigBuilder-->>ApplyRange: builder
    ConvertCmd->>RenderKit: convert_with_config(config)
    RenderKit-->>ConvertCmd: result (frames 100 to end)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Hop along, dear reviewer, through validation clear,
Paired widths and heights now dancing, with no fear,
Frame ranges open-ended, where one side is free,
The CLI speaks truly now—no silent misery!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 70.59% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title directly and concisely describes the main change: fixing CLI handling of one-sided range and resolution options, which is the primary focus of all modifications across multiple files.
Linked Issues check ✅ Passed All primary coding requirements from issue #86 are met: validation rejects lone width/height options [#86], preserves one-sided frame ranges as open-ended bounds [#86], and the public API is aligned with the same behavior.
Out of Scope Changes check ✅ Passed All changes align with issue #86 objectives: validation logic added to CLI and API, frame-range handling modified to support open-ended ranges, new helper functions introduced, and comprehensive tests added covering all specified scenarios.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev/fix-cli-one-sided-options

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud

Copy link
Copy Markdown

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Ahmed-Hindy Ahmed-Hindy self-assigned this Jun 11, 2026
@Ahmed-Hindy Ahmed-Hindy marked this pull request as ready for review June 11, 2026 17:58

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
tests/test_api.py (1)

29-30: 💤 Low value

Optional: Add a docstring or comment to satisfy the static analysis hint.

The empty convert method is intentional for this test stub, but SonarCloud flags it. Adding a brief docstring would silence the linter without changing behavior.

📝 Suggested docstring
         def convert(self, show_progress=None) -> None:
+            """Stub implementation for testing."""
             pass
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_api.py` around lines 29 - 30, Add a short docstring to the test
stub method convert(self, show_progress=None) -> None explaining that the method
is intentionally empty for testing (e.g., "Intentional no-op for test stub;
SonarCloud suppression"). This satisfies static analysis without changing
behavior; update the convert function's body to contain only the docstring and
keep the signature and no-op behavior.

Source: MCP tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/test_api.py`:
- Around line 29-30: Add a short docstring to the test stub method convert(self,
show_progress=None) -> None explaining that the method is intentionally empty
for testing (e.g., "Intentional no-op for test stub; SonarCloud suppression").
This satisfies static analysis without changing behavior; update the convert
function's body to contain only the docstring and keep the signature and no-op
behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c2491dbf-82d0-4603-b0a0-c62c1093b9b9

📥 Commits

Reviewing files that changed from the base of the PR and between 65e99cd and 2225288.

📒 Files selected for processing (9)
  • src/renderkit/api/processor.py
  • src/renderkit/cli/batch.py
  • src/renderkit/cli/conversion.py
  • src/renderkit/cli/main.py
  • src/renderkit/core/config.py
  • tests/test_api.py
  • tests/test_batch.py
  • tests/test_cli.py
  • tests/test_converter.py

@Ahmed-Hindy Ahmed-Hindy merged commit 86615f5 into main Jun 12, 2026
8 checks passed
@Ahmed-Hindy Ahmed-Hindy deleted the dev/fix-cli-one-sided-options branch June 12, 2026 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: CLI silently ignores or misinterprets one-sided range and resolution options

2 participants