Skip to content

ci#83

Merged
MH0386 merged 29 commits into
mainfrom
ci
Jun 16, 2025
Merged

ci#83
MH0386 merged 29 commits into
mainfrom
ci

Conversation

@MH0386
Copy link
Copy Markdown
Contributor

@MH0386 MH0386 commented Jun 14, 2025

Summary by Sourcery

Clean up code comments and formatting across model modules, update CI configuration bootstrap steps, and remove obsolete configuration files

Enhancements:

  • Reformatted assertion statements for readability in AttentionBlock and UNet forward methods
  • Repositioned and clarified inline comments in seq2seq feature combination for better context

CI:

  • Move cleanup of uv.lock and .idea directory to the start of qodana.yaml bootstrap sequence

Documentation:

  • Simplified and tightened docstrings in AttentionBlock, BeatGANsUNetConfig, and GaussianDiffusionBeatGans classes

Chores:

  • Remove deprecated .trunk/.yamllint.yaml and .trunk/pyrightconfig.json configuration files

Summary by CodeRabbit

  • Chores

    • Removed several configuration files for code formatting and linting tools, including Pyright, isort, Taplo, and Prettier.
    • Updated and simplified remaining configuration files for linting and formatting, including Ruff and Trunk.
    • Updated workflow to use a full git clone for code quality checks.
    • Added SonarLint configuration and updated project dictionary for IDE integration.
    • Updated dependency on Gradio to version 5.34.0.
  • Style / Documentation

    • Improved and clarified code comments and docstrings across multiple modules for better readability.
  • Refactor

    • Minor refactoring for code clarity and maintainability, such as variable scope adjustments and streamlined logic in select functions.
  • Bug Fixes

    • Improved argument validation in face enhancement functionality to prevent invalid method usage.

@gitnotebooks
Copy link
Copy Markdown

gitnotebooks Bot commented Jun 14, 2025

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Jun 14, 2025

Reviewer's Guide

This PR focuses on code style and configuration cleanup across the project, standardizing docstrings, reflowing comments and asserts, reorganizing imports, tweaking the CI bootstrap sequence, and pruning obsolete config files.

Flow Diagram for Updated CI Bootstrap Sequence in qodana.yaml

graph TD
    A[Start] --> B["rm uv.lock"];
    B --> C["rm -rf .idea"];
    C --> D["export UV_CACHE_DIR=/data/cache"];
    D --> E["export CONDA_PREFIX=/opt/miniconda3"];
    E --> F["conda config --add channels defaults"];
    F --> G["conda install -y python=3.10"];
    G --> H["pip install uv"];
    H --> I["uv pip sync pyproject.toml --python 3.10"];
    I --> J[End];
Loading

File-Level Changes

Change Details Files
Reorganized imports and cleaned up whitespace in dataset loader
  • Grouped stdlib and third-party imports
  • Removed extra blank lines
  • Ensured consistent import ordering
src/visualizr/dataset.py
Standardized and condensed docstrings in attention and UNet blocks
  • Collapsed multi-line docstrings into single lines
  • Removed external URL references
  • Reflowed explanatory comments
src/visualizr/model/blocks.py
src/visualizr/model/unet.py
Refactored assert statements for readability
  • Wrapped complex conditions and messages in parentheses
  • Moved multi-line messages into inline form
src/visualizr/model/blocks.py
src/visualizr/model/unet.py
Moved inline comments to standalone lines in seq2seq forward
  • Extracted end-of-line comment above its code
  • Clarified purpose of initial_code and direction_code
src/visualizr/model/seq2seq.py
Tweaked CI bootstrap sequence in Qodana config
  • Moved cleanup commands (rm uv.lock, rm -rf .idea) to start of bootstrap
  • Ensured cache and environment setup follow cleanup
qodana.yaml
Pruned obsolete CI and lint config files
  • Removed .yamllint.yaml under .trunk/configs
  • Removed pyrightconfig.json under .trunk/configs
.trunk/configs/.yamllint.yaml
.trunk/configs/pyrightconfig.json

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. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the 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 exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard 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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 14, 2025

Walkthrough

This update primarily involves configuration and documentation changes, including the deletion and simplification of several linter and formatter config files, updates to project dependency and linter versions, and minor code comment and type hint improvements. Several Python methods now explicitly declare global variables. No major functional or control flow changes are introduced to the codebase.

Changes

File(s) Change Summary
.trunk/configs/pyrightconfig.json,
.trunk/configs/.isort.cfg,
.trunk/configs/taplo.toml,
.trunk/configs/.prettierrc.yaml
Deleted configuration files for Pyright, isort, Taplo, and Prettier, removing related settings.
.trunk/configs/ruff.toml Simplified Ruff config: reduced excludes, shorter line length, enabled docstring code formatting.
.trunk/trunk.yaml Removed several linters, downgraded some tool versions, added new pre-push/commit actions.
qodana.yaml Updated bootstrap to use .log dir, changed cleanup, excluded uv.lock, removed one inspection.
pyproject.toml Reformatted TOML, bumped gradio[mcp] version, no other dependency changes.
.github/workflows/code_analysis.yaml Changed git checkout to fetch full history (fetch-depth: 0).
.idea/sonarlint.xml Added SonarLint config for IDE integration.
.idea/dictionaries/project.xml Added "mergify" to recognized dictionary words.
src/visualizr/dataset.py Added type hint, refactored a method, clarified comments.
src/visualizr/diffusion/base.py Removed docstring source reference, added global declarations in a method.
src/visualizr/model/blocks.py Simplified AttentionBlock docstring.
src/visualizr/model/seq2seq.py Added global declaration and explanatory comments in a method.
src/visualizr/model/unet.py Clarified comments in a dataclass.
src/visualizr/face_sr/face_enhancer.py Added explicit validation for the method argument.
src/visualizr/model/diffusion.py Added global s declaration in a method.
src/visualizr/model/unet_autoenc.py Removed commented-out code in a method.
src/visualizr/networks/styledecoder.py Added global declarations in a method.
src/visualizr/utils.py Added global declarations in the main function.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant FaceEnhancer

    User->>FaceEnhancer: Call enhancer_generator_no_len(method)
    alt method is valid ("gfpgan", "RestoreFormer", "codeformer")
        FaceEnhancer->>FaceEnhancer: Proceed with enhancement
    else method is invalid
        FaceEnhancer->>User: Raise ValueError
    end
Loading

Poem

A rabbit hops through configs anew,
Sweeping up files, making settings few.
With global declarations and comments refined,
And "mergify" now in the dictionary aligned.
Linters and formatters, some bid adieu—
The codebase is lighter, and ready for you!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f81b948 and 0c47711.

📒 Files selected for processing (2)
  • .idea/dictionaries/project.xml (1 hunks)
  • .trunk/configs/.prettierrc.yaml (0 hunks)
💤 Files with no reviewable changes (1)
  • .trunk/configs/.prettierrc.yaml
✅ Files skipped from review due to trivial changes (1)
  • .idea/dictionaries/project.xml
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Trunk Check
  • GitHub Check: Qodana
  • GitHub Check: Trunk Code Quality
  • GitHub Check: Mergify Merge Protections
  • GitHub Check: Qodana
  • GitHub Check: Summary

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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in 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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @MH0386, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Based on the title 'ci' and the changes included, this pull request appears to focus on general maintenance. It includes a minor adjustment to the CI configuration and several small code cleanups, such as removing outdated comments and improving code formatting, along with adding a clarifying comment in one of the model files. Without a detailed description, the primary goal seems to be maintaining the codebase and potentially improving the CI process.

Highlights

  • CI Configuration Update: Adjusted the order of cleanup commands (rm uv.lock, rm -rf .idea) within the bootstrap section of the qodana.yaml configuration file.
  • Codebase Cleanup: Removed comments referencing external source code links in diffusion/base.py and model/blocks.py. Also, reformatted some comments and assert statements across model/blocks.py and model/unet.py for improved readability.
  • Model Code Clarity: Added explanatory comments to the forward method in model/seq2seq.py to clarify the purpose of the initial_code and direction_code variables.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configureGemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@deepsource-io
Copy link
Copy Markdown
Contributor

deepsource-io Bot commented Jun 14, 2025

Here's the code health analysis summary for commits 12dc22a..b40cff1. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource Python LogoPython❌ Failure
❗ 280 occurences introduced
View Check ↗
DeepSource Docker LogoDocker✅ SuccessView Check ↗
DeepSource Secrets LogoSecrets✅ SuccessView Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request primarily focuses on cleaning up code comments and documentation, updating CI configuration for Qodana, and removing obsolete configuration files. The changes generally improve code hygiene and CI pipeline reliability. Key areas for consideration include the removal of attribution links in src/visualizr/diffusion/base.py and src/visualizr/model/blocks.py; it's worth ensuring these removals are appropriate if the code still significantly draws from the original sources.

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey @MH0386 - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments

### Comment 1
<location> `src/visualizr/dataset.py:48` </location>
<code_context>
-        )
-
-        self.data = []
-        for db_name in ["VoxCeleb2", "HDTF"]:
-            db_png_path = os.path.join(frame_jpgs, db_name)
-            for clip_name in tqdm(os.listdir(db_png_path)):
</code_context>

<issue_to_address>
Avoid shadowing the `db_name` parameter.

Rename the loop variable to avoid confusion and potential errors.
</issue_to_address>

### Comment 2
<location> `src/visualizr/dataset.py:152` </location>
<code_context>
-                if min_len < self.window_size * self.video_fps + 5:
-                    continue
-
-        print("Db count:", len(self.data))
-
-    def get_single_image(self, image_path):
</code_context>

<issue_to_address>
No items are ever appended to `self.data`.

Consider adding `self.data.append(item_dict)` after constructing and validating `item_dict` to ensure items are stored as intended.
</issue_to_address>

### Comment 3
<location> `qodana.yaml:5` </location>
<code_context>
 linter: jetbrains/qodana-python:2025.1
 bootstrap: |
+  rm uv.lock
+  rm -rf .idea
   export UV_CACHE_DIR=/data/cache
   export CONDA_PREFIX=/opt/miniconda3
</code_context>

<issue_to_address>
Removing `.idea` before redirecting logs will break log files.

Removing the `.idea` directory before redirecting logs to `.idea/output.log` will cause the redirection to fail. Remove `.idea` after logging, or recreate the directory before redirecting logs.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/visualizr/dataset.py
)

self.data = []
for db_name in ["VoxCeleb2", "HDTF"]:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue: Avoid shadowing the db_name parameter.

Rename the loop variable to avoid confusion and potential errors.

Comment thread src/visualizr/dataset.py
continue

print("Db count:", len(self.data))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue (bug_risk): No items are ever appended to self.data.

Consider adding self.data.append(item_dict) after constructing and validating item_dict to ensure items are stored as intended.

Comment thread qodana.yaml Outdated
Comment thread src/visualizr/dataset.py
Comment thread src/visualizr/dataset.py

class LatentDataLoader(object):
def __init__(
self,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue (code-quality): We've found these issues:


Explanation

The quality score for this function is below the quality threshold of 25%.
This score is a combination of the method length, cognitive complexity and working memory.

How can you solve this?

It might be worth refactoring this function to make it shorter and more readable.

  • Reduce the function length by extracting pieces of functionality out into
    their own functions. This is the most important thing you can do - ideally a
    function should be less than 10 lines.
  • Reduce nesting, perhaps by introducing guard clauses to return early.
  • Ensure that variables are tightly scoped, so that code using related concepts
    sits together within the function rather than being scattered.

Comment thread src/visualizr/dataset.py Outdated
Comment thread src/visualizr/dataset.py

total_lmd_obj = []
for i, line in enumerate(lmd_lines):
# Split the coordinates and filter out any empty strings
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion (code-quality): Remove unnecessary calls to enumerate when the index is not used (remove-unused-enumerate)

Suggested change
for i, line in enumerate(lmd_lines):
for line in lmd_lines:

Comment thread src/visualizr/dataset.py
Comment on lines +198 to +199
return distances

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion (code-quality): Inline variable that is immediately returned (inline-immediately-returned-variable)

Suggested change
distances = np.linalg.norm(forehead_center - chin_bottom, axis=1, keepdims=True)
return distances
return np.linalg.norm(forehead_center - chin_bottom, axis=1, keepdims=True)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 15, 2025

Qodana for Python

604 new problems were found

Inspection name Severity Problems
Attempt to call a non-callable object 🔶 Warning 56
Unbound local variables 🔶 Warning 19
Invalid type hints definitions and usages 🔶 Warning 4
Incorrect call arguments 🔶 Warning 3
Problematic whitespace 🔶 Warning 2
Incorrect type 🔶 Warning 2
Check third party software list 🔶 Warning 1
Inconsistent line separators 🔶 Warning 1
Missing or empty docstring ◽️ Notice 320
Incorrect docstring ◽️ Notice 41
PEP 8 naming convention violation ◽️ Notice 29
Incorrect formatting ◽️ Notice 26
Unused local symbols ◽️ Notice 25
An instance attribute is defined outside init`` ◽️ Notice 20
Shadowing names from outer scopes ◽️ Notice 18
The function argument is equal to the default parameter value ◽️ Notice 9
Global variable is not defined at the module level ◽️ Notice 8
Method is not declared static ◽️ Notice 8
Duplicated code fragment ◽️ Notice 5
Inconsistent return statements ◽️ Notice 2
Accessing a protected member of a class or a module ◽️ Notice 2
Class has no init method ◽️ Notice 1
Dictionary creation can be rewritten by dictionary literal ◽️ Notice 1
Redundant parentheses ◽️ Notice 1

☁️ View the detailed Qodana report

Contact Qodana team

Contact us at qodana-support@jetbrains.com

MH0386 added 2 commits June 15, 2025 03:08
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (2)
src/visualizr/dataset.py (2)

23-36: db_name parameter shadowed by loop variable
Same issue pointed out previously persists; rename the loop variable to avoid confusion.


47-152: ⚠️ Potential issue

Critical: items never added to self.data

self.data remains an empty list because the inner loop builds item_dict but never appends it.
Down-stream __len__ and __getitem__ will malfunction.

@@
                 if min_len < self.window_size * self.video_fps + 5:
                     continue
+
+                # finally store the validated clip
+                self.data.append(item_dict)
🧰 Tools
🪛 Pylint (3.3.7)

[refactor] 48-48: Redefining argument with the local name 'db_name'

(R1704)


[refactor] 51-51: Consider using '{}' instead of a call to 'dict'.

(R1735)

🧹 Nitpick comments (2)
src/visualizr/dataset.py (1)

174-177: Unused loop index i

i is not referenced inside the loop; rename to _ or drop enumerate.

-        for i, line in enumerate(lmd_lines):
+        for line in lmd_lines:
🧰 Tools
🪛 Ruff (0.11.9)

175-175: Loop control variable i not used within loop body

Rename unused i to _i

(B007)

qodana.yaml (1)

8-9: Prevent log overwrites by using append or separate files.

Both conda config --add… > output.log and conda install… > output.log currently overwrite the same file, losing earlier logs. Consider one of the following:

  • Use >> output.log to append each command’s output.
  • Redirect each command to its own log file (e.g., config.log and install.log).
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f4da25b and 5e64be7.

📒 Files selected for processing (9)
  • .github/workflows/code_analysis.yaml (1 hunks)
  • .trunk/configs/.yamllint.yaml (0 hunks)
  • .trunk/configs/pyrightconfig.json (0 hunks)
  • qodana.yaml (1 hunks)
  • src/visualizr/dataset.py (1 hunks)
  • src/visualizr/diffusion/base.py (0 hunks)
  • src/visualizr/model/blocks.py (1 hunks)
  • src/visualizr/model/seq2seq.py (1 hunks)
  • src/visualizr/model/unet.py (1 hunks)
💤 Files with no reviewable changes (3)
  • src/visualizr/diffusion/base.py
  • .trunk/configs/pyrightconfig.json
  • .trunk/configs/.yamllint.yaml
🧰 Additional context used
🪛 Ruff (0.11.9)
src/visualizr/dataset.py

175-175: Loop control variable i not used within loop body

Rename unused i to _i

(B007)

🪛 Pylint (3.3.7)
src/visualizr/dataset.py

[refactor] 13-13: Class 'LatentDataLoader' inherits from object, can be safely removed from bases in python3

(R0205)


[refactor] 13-13: Too many instance attributes (11/7)

(R0902)


[refactor] 14-14: Too many arguments (13/5)

(R0913)


[refactor] 14-14: Too many positional arguments (13/5)

(R0917)


[refactor] 14-14: Too many local variables (24/15)

(R0914)


[refactor] 48-48: Redefining argument with the local name 'db_name'

(R1704)


[refactor] 51-51: Consider using '{}' instead of a call to 'dict'.

(R1735)


[refactor] 14-14: Too many statements (62/50)

(R0915)


[refactor] 201-201: Too many local variables (18/15)

(R0914)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Qodana
  • GitHub Check: Mergify Merge Protections
  • GitHub Check: Qodana
🔇 Additional comments (4)
src/visualizr/model/unet.py (1)

29-35: Comment-only tweak acknowledged

Pure comment re-flow, no behavioural impact.

.github/workflows/code_analysis.yaml (1)

66-68: Confirm intention to disable Qodana auto-fixes

--apply-fixes and push-fixes are now commented out.
If this was accidental, CI will still surface problems but never amend them, so technical debt could silently accumulate.

src/visualizr/model/blocks.py (1)

412-412: Docstring shrinkage looks fine

Concise wording, behaviour unchanged.

src/visualizr/model/seq2seq.py (1)

148-154: Comment addition improves intent clarity

No functional diff; LGTM.

Comment thread qodana.yaml Outdated
Comment on lines +4 to +5
rm uv.lock
rm -rd .idea
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Make cleanup commands idempotent and error-tolerant.

Without force flags, rm uv.lock will error if the file is missing, and rm -rd .idea may fail or behave unexpectedly (the -d flag only removes empty directories). This can break the CI bootstrap.
Apply this diff:

- rm uv.lock
- rm -rd .idea
+ rm -f uv.lock
+ rm -rf .idea
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
rm uv.lock
rm -rd .idea
rm -f uv.lock
rm -rf .idea
🤖 Prompt for AI Agents
In qodana.yaml around lines 4 to 5, the cleanup commands use `rm uv.lock` and
`rm -rd .idea`, which can fail if the file or directory does not exist or if the
directory is not empty. To fix this, add the `-f` flag to `rm uv.lock` to avoid
errors if the file is missing, and replace `rm -rd .idea` with `rm -rf .idea` to
forcefully and recursively remove the directory regardless of its contents,
making the cleanup commands idempotent and error-tolerant.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🔭 Outside diff range comments (2)
src/visualizr/networks/styledecoder.py (1)

588-594: 🛠️ Refactor suggestion

Remove global usage; keep skip & skip_flow local to forward.

Exposing intermediate tensors via the global namespace:

  1. Breaks re-entrancy & thread-safety – multiple model instances running in dataloader workers will trample each other.
  2. Makes debugging harder because the lifecycle of these tensors is no longer explicit.
  3. Creates silent memory leaks on long-running processes.

A self-contained approach keeps the two variables local and initialises them before the loop:

-        global skip_flow, skip
+        skip_flow: torch.Tensor | None = None
+        skip:      torch.Tensor | None = None

All subsequent references already occur inside this scope, so no further change is needed.

🧰 Tools
🪛 Pylint (3.3.7)

[refactor] 589-589: Too many local variables (16/15)

(R0914)

src/visualizr/utils.py (1)

150-160: 🛠️ Refactor suggestion

global frame_end, audio_driven is unnecessary and harmful

Both names are only consumed inside main; declaring them global:

  • Pollutes the module namespace.
  • Prevents concurrent calls to main (e.g., from gradio threads) from running safely.
  • Adds hidden coupling with external code – but no other function actually imports them.

Simply drop the declaration – nothing else in this file relies on these globals.

-    global frame_end, audio_driven
🧹 Nitpick comments (1)
src/visualizr/face_sr/face_enhancer.py (1)

47-48: Early validation is welcome, but make it case-insensitive & DRY

Nice to see the guard added before heavy init.
Two small tweaks would make it more robust and avoid future duplication with the match block:

  1. Normalize the input once (method = method.lower()), then keep valid_methods in one tuple that is reused for both the upfront check and the match.
  2. Update the case labels to the same lower-case strings, eliminating the mixed-case "RestoreFormer".

Example sketch:

-    if method not in ["gfpgan", "RestoreFormer", "codeformer"]:
-        raise ValueError(f"Wrong model version {method}.")
+    method = method.lower()
+    valid_methods = ("gfpgan", "restoreformer", "codeformer")
+    if method not in valid_methods:
+        raise ValueError(f"Unknown face-enhancement method: {method}")

This prevents surprises such as callers passing "RestoreFormer" vs "restoreformer" and centralises the allowed set.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5e64be7 and 2a9f34b.

📒 Files selected for processing (9)
  • qodana.yaml (1 hunks)
  • src/visualizr/diffusion/base.py (1 hunks)
  • src/visualizr/face_sr/face_enhancer.py (1 hunks)
  • src/visualizr/model/diffusion.py (1 hunks)
  • src/visualizr/model/seq2seq.py (2 hunks)
  • src/visualizr/model/unet_autoenc.py (1 hunks)
  • src/visualizr/networks/encoder.py (1 hunks)
  • src/visualizr/networks/styledecoder.py (1 hunks)
  • src/visualizr/utils.py (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/visualizr/model/diffusion.py
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/visualizr/diffusion/base.py
  • src/visualizr/model/seq2seq.py
  • qodana.yaml
🧰 Additional context used
🪛 Ruff (0.11.9)
src/visualizr/model/unet_autoenc.py

221-221: Loop control variable j not used within loop body

Rename unused j to _j

(B007)


240-240: Loop control variable j not used within loop body

Rename unused j to _j

(B007)


285-289: Use ternary operator time_emb = None if time_emb is None else self.time_embed(time_emb) instead of if-else-block

(SIM108)

🪛 GitHub Check: Qodana for Python
src/visualizr/model/unet_autoenc.py

[warning] 1-1: Inconsistent line separators
Line separators in the current file (\r\n) differ from the project defaults (\n)

🪛 Pylint (3.3.7)
src/visualizr/model/unet_autoenc.py

[refactor] 124-128: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it

(R1705)


[refactor] 130-130: Too many arguments (9/5)

(R0913)


[refactor] 130-130: Too many positional arguments (9/5)

(R0917)


[refactor] 130-130: Too many local variables (29/15)

(R0914)


[refactor] 130-130: Too many branches (18/12)

(R0912)


[refactor] 130-130: Too many statements (56/50)

(R0915)


[refactor] 273-273: Too few public methods (1/2)

(R0903)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Mergify Merge Protections

Comment on lines +83 to +87
def noise_to_cond(self, noise: Tensor):
raise NotImplementedError()
# assert self.conf.noise_net_conf is not None
# return self.noise_net.forward(noise)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

noise_to_cond() now always raises – forward pass will crash

forward() calls self.noise_to_cond(noise) when noise is not None (l.154-157).
With the current stub, any training code that supplies noise will hit NotImplementedError.

Either implement the mapping or delete the call path (and the argument) to avoid a runtime failure.

-    def noise_to_cond(self, noise: Tensor):
-        raise NotImplementedError()
+    def noise_to_cond(self, noise: Tensor):
+        # Example: simple MLP, replace with real logic
+        return self.noise_net(noise)

If the feature is truly obsolete, remove the parameter check in forward instead.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def noise_to_cond(self, noise: Tensor):
raise NotImplementedError()
# assert self.conf.noise_net_conf is not None
# return self.noise_net.forward(noise)
def noise_to_cond(self, noise: Tensor):
# Example: simple MLP, replace with real logic
return self.noise_net(noise)
🤖 Prompt for AI Agents
In src/visualizr/model/unet_autoenc.py around lines 83 to 87, the
noise_to_cond() method currently raises NotImplementedError, causing a crash
when forward() calls it if noise is provided. To fix this, either implement the
noise_to_cond() method to properly map noise to conditioning or remove the noise
argument and the call to noise_to_cond() in forward() to prevent runtime errors.
If the noise feature is obsolete, also remove the noise parameter check in
forward() to avoid calling the unimplemented method.

Comment thread src/visualizr/networks/encoder.py Outdated
… refine dependency markers for CUDA compatibility.
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
.trunk/trunk.yaml (1)

16-19: Confirm disabling formatters and linters.

The removal of black and isort (alongside existing pyright and yamllint) from the enabled list could impact code formatting and type checking in your workflow. Please verify that no downstream processes or pre-commit hooks depend on these tools and update any documentation or scripts accordingly.

Consider adding an inline comment explaining the rationale for disabling these formatters to aid future maintainers.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2a9f34b and 65a2299.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • .idea/codeStyles/codeStyleConfig.xml (1 hunks)
  • .trunk/configs/.isort.cfg (0 hunks)
  • .trunk/configs/.markdownlint.yaml (0 hunks)
  • .trunk/configs/ruff.toml (1 hunks)
  • .trunk/configs/taplo.toml (0 hunks)
  • .trunk/trunk.yaml (1 hunks)
  • pyproject.toml (1 hunks)
💤 Files with no reviewable changes (3)
  • .trunk/configs/.markdownlint.yaml
  • .trunk/configs/.isort.cfg
  • .trunk/configs/taplo.toml
✅ Files skipped from review due to trivial changes (3)
  • .idea/codeStyles/codeStyleConfig.xml
  • .trunk/configs/ruff.toml
  • pyproject.toml
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Trunk Check
  • GitHub Check: Qodana
  • GitHub Check: Trunk Code Quality
  • GitHub Check: Mergify Merge Protections
  • GitHub Check: Qodana
  • GitHub Check: Trunk Code Quality
🔇 Additional comments (1)
.trunk/trunk.yaml (1)

37-38: Approve new pre-commit and pre-push actions.

Adding trunk-check-pre-push-always and trunk-check-pre-commit strengthens your CI by enforcing checks at earlier stages. This aligns well with best practices for preventing regressions.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (2)
src/visualizr/dataset.py (2)

49-50: Loop variable shadows constructor parameter db_name

Using the same identifier for two different concepts is confusing and risks bugs if the parameter were ever used. Rename the loop variable (e.g. dataset_name) and, if useful, store it in item_dict for later tracing.

-for db_name in ["VoxCeleb2", "HDTF"]:
-    db_png_path = os.path.join(frame_jpgs, db_name)
+for dataset_name in ["VoxCeleb2", "HDTF"]:
+    db_png_path = os.path.join(frame_jpgs, dataset_name)

145-153: self.data never populated – Dataset length is always zero

__len__ and __getitem__ rely on self.data, but no item is appended after all validations pass, so every call will either return 0 or raise an IndexError.
Add the append once the sample clears the min_len gate:

             if min_len < self.window_size * self.video_fps + 5:
                 continue

-            # (nothing is stored – bug)
+            # All checks passed – persist the sample
+            self.data.append(item_dict)
🧹 Nitpick comments (2)
src/visualizr/dataset.py (2)

176-176: Unused loop index variable

i is never referenced inside the loop; replace it with _ to signal intentional discard and silence linters.

-for i, line in enumerate(lmd_lines):
+for _, line in enumerate(lmd_lines):

14-14: Redundant ‘object’ base class

In Python 3, explicitly inheriting from object is unnecessary. Removing it cuts noise and appeases style tools.

-class LatentDataLoader(object):
+class LatentDataLoader:
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e864d3d and 1586e9b.

📒 Files selected for processing (3)
  • .idea/sonarlint.xml (1 hunks)
  • qodana.yaml (1 hunks)
  • src/visualizr/dataset.py (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .idea/sonarlint.xml
🚧 Files skipped from review as they are similar to previous changes (1)
  • qodana.yaml
🧰 Additional context used
🪛 Ruff (0.11.9)
src/visualizr/dataset.py

176-176: Loop control variable i not used within loop body

Rename unused i to _i

(B007)

🪛 Pylint (3.3.7)
src/visualizr/dataset.py

[refactor] 14-14: Class 'LatentDataLoader' inherits from object, can be safely removed from bases in python3

(R0205)


[refactor] 14-14: Too many instance attributes (11/7)

(R0902)


[refactor] 15-15: Too many arguments (13/5)

(R0913)


[refactor] 15-15: Too many positional arguments (13/5)

(R0917)


[refactor] 15-15: Too many local variables (24/15)

(R0914)


[refactor] 49-49: Redefining argument with the local name 'db_name'

(R1704)


[refactor] 15-15: Too many statements (62/50)

(R0915)


[refactor] 202-202: Too many local variables (18/15)

(R0914)

⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Trunk Check
  • GitHub Check: Trunk Code Quality
  • GitHub Check: Check Dependency Compatibility
  • GitHub Check: Qodana
  • GitHub Check: Mergify Merge Protections
  • GitHub Check: Qodana

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Jun 16, 2025

Hi @MH0386, Your PR is in conflict and cannot be merged.

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (2)
src/visualizr/dataset.py (2)

49-49: Avoid shadowing the constructor parameter db_name.

The loop variable db_name hides the constructor argument with the same name, which makes the original value inaccessible inside the loop and is error-prone.
Rename the loop variable, e.g. to dataset_name.


48-153: self.data is never populated – the dataset will always be empty.

After constructing and validating item_dict, it is never appended to self.data.
As a result, __len__ will return 0 and __getitem__ will fail.

@@
                 item_dict["frame_count"] = min_len
                 item_dict["hubert_obj"] = item_dict["hubert_obj"][
                     :, : min_len * 2, :
                 ]
 
                 if min_len < self.window_size * self.video_fps + 5:
                     continue
+
+                # ✅ Store the sample
+                self.data.append(item_dict)
@@
         print("Db count:", len(self.data))
🧹 Nitpick comments (3)
src/visualizr/dataset.py (3)

52-53: Use a precise type hint (Dict[str, Any]) instead of the unparameterised Dict.

-from typing import Dict
+from typing import Dict, Any
 ...
-item_dict: Dict = {}
+item_dict: Dict[str, Any] = {}

Using Dict without type parameters defeats the purpose of the hint and triggers typing warnings.


160-168: Minor API & naming improvements for get_multiple_ranges.

  1. The parameter name lists shadows the built-in list type.
  2. Guard clauses validate tuple shape, but not range ordering or bounds.
  3. You can eliminate the intermediate extracted_elements variable for clarity.
-def get_multiple_ranges(self, lists, multi_ranges):
+def get_multiple_ranges(self, sequence, multi_ranges):
@@
-        extracted_elements = [lists[start:end] for start, end in multi_ranges]
-        return [item for sublist in extracted_elements for item in sublist]
+        if not all(0 <= start < end <= len(sequence) for start, end in multi_ranges):
+            raise ValueError("Range indices must satisfy 0 ≤ start < end ≤ len(sequence)")
+
+        return [item for start, end in multi_ranges for item in sequence[start:end]]

233-243: Replace magic indices with named constants for maintainability.

Hard-coded offsets (1:, 30, 0) obscure intent and are brittle if the landmark format changes.

DRIVEN_FRAME_IDX = 1
NOISE_LANDMARK_IDX = 30
X_COORD_IDX = 0

"face_location": lmd_obj_full[DRIVEN_FRAME_IDX:, NOISE_LANDMARK_IDX, X_COORD_IDX],
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1586e9b and 0381184.

📒 Files selected for processing (1)
  • src/visualizr/dataset.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.11.9)
src/visualizr/dataset.py

175-175: Loop control variable i not used within loop body

Rename unused i to _i

(B007)

🪛 Pylint (3.3.7)
src/visualizr/dataset.py

[refactor] 14-14: Class 'LatentDataLoader' inherits from object, can be safely removed from bases in python3

(R0205)


[refactor] 14-14: Too many instance attributes (11/7)

(R0902)


[refactor] 15-15: Too many arguments (13/5)

(R0913)


[refactor] 15-15: Too many positional arguments (13/5)

(R0917)


[refactor] 15-15: Too many local variables (24/15)

(R0914)


[refactor] 49-49: Redefining argument with the local name 'db_name'

(R1704)


[refactor] 15-15: Too many statements (62/50)

(R0915)


[refactor] 201-201: Too many local variables (18/15)

(R0914)

⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Trunk Code Quality
  • GitHub Check: Qodana
  • GitHub Check: Mergify Merge Protections
  • GitHub Check: Summary

MH0386 and others added 3 commits June 16, 2025 18:21
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Jun 16, 2025

Hi @MH0386! Your pull request is ready for merging

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Jun 16, 2025

Hi @MH0386, Your PR is in conflict and cannot be merged.

@sonarqubecloud
Copy link
Copy Markdown

@MH0386 MH0386 merged commit f4afcb2 into main Jun 16, 2025
17 of 20 checks passed
@MH0386 MH0386 deleted the ci branch June 16, 2025 20:52
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Jun 16, 2025

Thank you for your contribution @MH0386! Your pull request has been merged.

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