Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow fingerprint duration more than ~9 hours #158

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lalinsky
Copy link
Member

@lalinsky lalinsky commented Mar 8, 2025

Summary by CodeRabbit

  • New Features

    • Expanded the allowed duration range, enabling users to submit content with significantly longer durations. This enhancement improves flexibility and ensures better handling of diverse input values.
  • Chores

    • Updated the system’s data storage configuration to support the extended numeric range for duration records. This change boosts overall reliability and performance during data processing.

Copy link
Contributor

coderabbitai bot commented Mar 8, 2025

Walkthrough

This pull request updates two main areas. First, it adjusts the validation logic for the duration parameter in the SubmitHandlerParams class by increasing the acceptable upper value from 32767 to 2147483647. Second, it changes the data type for the length column in both the submission and fingerprint tables from SmallInteger/SMALLINT to Integer/int4, and introduces Alembic migration scripts with corresponding upgrade and downgrade functions to effect these type changes while preserving the check constraint enforcing positive values.

Changes

Files Change Summary
acoustid/api/v2/__init__.py In SubmitHandlerParams._parse_duration_and_format, extended the duration check from >0x7FFF (32767) to >0x7FFFFFFF (2147483647).
acoustid/tables.py, alembic/versions/...fingerprint...py, alembic/versions/...submission...py Changed the length column type from SmallInteger/SMALLINT to Integer/int4 in both submission and fingerprint tables; added migration scripts with upgrade/downgrade functions to apply the data type changes while maintaining the length>0 constraint.

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b615781 and 195c71b.

📒 Files selected for processing (4)
  • acoustid/api/v2/__init__.py (1 hunks)
  • acoustid/tables.py (2 hunks)
  • alembic/versions/468b44482655_change_fingerprint_length_to_int4.py (1 hunks)
  • alembic/versions/d7e8b1c80561_change_submission_length_to_int4.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
alembic/versions/468b44482655_change_fingerprint_length_to_int4.py

10-10: sqlalchemy.dialects.postgresql imported but unused

Remove unused import: sqlalchemy.dialects.postgresql

(F401)


19-19: Missing return type annotation for public function upgrade

Add return type annotation: None

(ANN201)


19-19: Missing type annotation for function argument engine_name

(ANN001)


20-20: Use format specifiers instead of percent format

Replace with format specifiers

(UP031)


23-23: Missing return type annotation for public function downgrade

Add return type annotation: None

(ANN201)


23-23: Missing type annotation for function argument engine_name

(ANN001)


24-24: Use format specifiers instead of percent format

Replace with format specifiers

(UP031)


27-27: Missing return type annotation for public function upgrade_app

Add return type annotation: None

(ANN201)


33-33: Missing return type annotation for public function downgrade_app

Add return type annotation: None

(ANN201)


39-39: Missing return type annotation for public function upgrade_ingest

Add return type annotation: None

(ANN201)


45-45: Missing return type annotation for public function downgrade_ingest

Add return type annotation: None

(ANN201)


51-51: Missing return type annotation for public function upgrade_fingerprint

Add return type annotation: None

(ANN201)


60-60: Missing return type annotation for public function downgrade_fingerprint

Add return type annotation: None

(ANN201)

alembic/versions/d7e8b1c80561_change_submission_length_to_int4.py

10-10: sqlalchemy.dialects.postgresql imported but unused

Remove unused import: sqlalchemy.dialects.postgresql

(F401)


19-19: Missing return type annotation for public function upgrade

Add return type annotation: None

(ANN201)


19-19: Missing type annotation for function argument engine_name

(ANN001)


20-20: Use format specifiers instead of percent format

Replace with format specifiers

(UP031)


23-23: Missing return type annotation for public function downgrade

Add return type annotation: None

(ANN201)


23-23: Missing type annotation for function argument engine_name

(ANN001)


24-24: Use format specifiers instead of percent format

Replace with format specifiers

(UP031)


27-27: Missing return type annotation for public function upgrade_app

Add return type annotation: None

(ANN201)


33-33: Missing return type annotation for public function downgrade_app

Add return type annotation: None

(ANN201)


39-39: Missing return type annotation for public function upgrade_ingest

Add return type annotation: None

(ANN201)


48-48: Missing return type annotation for public function downgrade_ingest

Add return type annotation: None

(ANN201)


57-57: Missing return type annotation for public function upgrade_fingerprint

Add return type annotation: None

(ANN201)


63-63: Missing return type annotation for public function downgrade_fingerprint

Add return type annotation: None

(ANN201)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (3)
acoustid/api/v2/__init__.py (1)

910-910: Change to duration limit looks good

The upper bound for duration validation has been increased from a 16-bit signed integer max (0x7FFF = 32767 seconds, roughly 9 hours) to a 32-bit signed integer max (0x7FFFFFFF = 2147483647 seconds). This change aligns with the database column type modifications in the other files.

acoustid/tables.py (2)

162-162: Appropriate data type change for submission length

Changing from SmallInteger to Integer increases the maximum possible duration value from 32,767 seconds to 2,147,483,647 seconds. The CheckConstraint ensuring positive values is properly preserved.


313-313: Appropriate data type change for fingerprint length

Consistent with the submission table change, this updates the fingerprint table's length column to use Integer instead of SmallInteger, while maintaining the positive value constraint.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@lalinsky
Copy link
Member Author

lalinsky commented Mar 8, 2025

Can't merge this yet, as there is no good way to change the type in PostgreSQL, these are huge tables, can't have them locked for days while they are being rewritten.

@lalinsky
Copy link
Member Author

lalinsky commented Mar 8, 2025

I'll most likely time this with upgrading all databases to PostgreSQL 17, as that will require dump/restore.

@lalinsky lalinsky requested a review from Copilot March 10, 2025 11:46

Choose a reason for hiding this comment

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

PR Overview

This PR extends the allowed duration range and updates related database migration scripts and table definitions to support longer durations.

  • Updates migration scripts to alter the "length" column from SMALLINT to Integer for fingerprints and submissions.
  • Adjusts table definitions in acoustid/tables.py to reflect the new integer type.
  • Modifies the duration validation in the API to use an extended upper bound.

Reviewed Changes

File Description
alembic/versions/468b44482655_change_fingerprint_length_to_int4.py Alters the fingerprint length column type to Integer and includes engine-specific no-op migration functions.
alembic/versions/d7e8b1c80561_change_submission_length_to_int4.py Alters the submission length column type to Integer with similar no-op migration functions for unused engines.
acoustid/tables.py Updates table definitions to use Integer for the "length" column.
acoustid/api/v2/init.py Extends the allowed duration range by updating the upper limit in the duration validation check.

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

alembic/versions/468b44482655_change_fingerprint_length_to_int4.py:29

  • [nitpick] The auto-generated upgrade_app function is currently a no-op; please add a clarifying comment to indicate that no migration steps are necessary for this engine to avoid future confusion.
pass

acoustid/api/v2/init.py:910

  • [nitpick] Consider enhancing the error message for InvalidDurationError by including the expected allowed range to assist in debugging and user feedback.
if p["duration"] <= 0 or p["duration"] > 0x7FFFFFFF:
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.

1 participant