LemurPwned / video-sampler

Effective frame sampling for ML applications.
https://lemurpwned.github.io/video-sampler/
MIT License
16 stars 5 forks source link

Feat/output fmt #36

Closed LemurPwned closed 1 day ago

LemurPwned commented 1 day ago

Summary by Sourcery

Add a new SaveFormatConfig class to handle save format configurations, including options for encoding time, avoiding dots, and including filenames. Refactor SamplerConfig to utilize Pydantic's Field for better default value management and validation. Update the format_output_path method to align with the new save format options.

New Features:

Enhancements:

sourcery-ai[bot] commented 1 day ago

Reviewer's Guide by Sourcery

This pull request implements changes to the video sampler configuration and output formatting. The main changes include updating the SaveFormatConfig class, modifying the SamplerConfig class, and adjusting the output path formatting in the sampler.

Class diagram for updated SaveFormatConfig and SamplerConfig

classDiagram
    class SaveFormatConfig {
        bool encode_time_b64
        bool avoid_dot
        bool include_filename
        model_validator validate_save_format()
    }
    class SamplerConfig {
        float min_frame_interval_sec
        bool keyframes_only
        float queue_wait
        int start_time_s
        int end_time_s
        bool precise_seek
        bool debug
        bool print_stats
        dict buffer_config
        dict gate_config
        dict extractor_config
        dict summary_config
        int n_workers
        SaveFormatConfig save_format
        str __str__()
        SamplerConfig from_yaml(str file_path)
        model_validator validate_start_end_times()
    }

File-Level Changes

Change Details Files
Refactored and expanded SaveFormatConfig class
  • Moved SaveFormatConfig out of SamplerConfig and made it a standalone class
  • Added new option 'avoiddot' to replace '.' with '' in filenames
  • Renamed 'encode_time' to 'encode_time_b64' for clarity
  • Added a model validator to warn when both 'encode_time_b64' and 'avoid_dot' are True
video_sampler/config.py
Updated SamplerConfig class
  • Replaced dataclasses with pydantic models
  • Changed field definitions to use pydantic's Field
  • Updated the str method to use model_dump() instead of asdict()
  • Modified the validate_start_end_times validator to work with pydantic v2
video_sampler/config.py
Modified output path formatting in the sampler
  • Updated format_output_path method to handle new SaveFormatConfig options
  • Implemented logic for 'avoid_dot' option
  • Changed the way encoded time is formatted in the filename
video_sampler/sampler.py
Updated configuration file
  • Changed 'encode_time' to 'encode_time_b64' and set it to false
  • Added 'avoid_dot' option and set it to true
  • Kept 'include_filename' as true
configs/hash_base.yaml

Tips and commands #### Interacting with Sourcery - **Trigger a new review:** Comment `@sourcery-ai review` on the pull request. - **Continue discussions:** Reply directly to Sourcery's review comments. - **Generate a GitHub issue from a review comment:** Ask Sourcery to create an issue from a review comment by replying to it. - **Generate a pull request title:** Write `@sourcery-ai` anywhere in the pull request title to generate a title at any time. - **Generate a pull request summary:** Write `@sourcery-ai summary` anywhere in the pull request body to generate a PR summary at any time. You can also use this command to specify where the summary should be inserted. #### Customizing Your Experience Access your [dashboard](https://app.sourcery.ai) to: - Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others. - Change the review language. - Add, remove or edit custom review instructions. - Adjust other review settings. #### Getting Help - [Contact our support team](mailto:support@sourcery.ai) for questions or feedback. - Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information. - Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).