Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@PythonFZ
Copy link
Member

@PythonFZ PythonFZ commented Aug 6, 2025

Summary by CodeRabbit

  • Tests

    • Added new integration tests to verify correct loading of dependent nodes using various revision and remote parameters.
    • Updated nested repository tests to expect successful node loading and attribute access instead of errors.
  • Bug Fixes

    • Improved handling of empty revision and remote parameters, ensuring they are treated as None when appropriate.
    • Resolved path resolution inconsistencies for nodes in different repository states and structures.
  • Chores

    • Updated .gitignore to exclude .DS_Store files.

@PythonFZ PythonFZ linked an issue Aug 6, 2025 that may be closed by this pull request
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 6, 2025

Walkthrough

The changes introduce new integration tests for dependency handling, update the .gitignore to exclude .DS_Store files, and revise several internal mechanisms for node loading and path resolution. Updates in core modules adjust how optional parameters (remote, rev) are handled, refine path resolution logic, and modify test expectations to reflect successful node loading scenarios.

Changes

Cohort / File(s) Change Summary
Git Ignore Update
.gitignore
Added .DS_Store to ignored files; no other changes.
Integration Tests for Dependency Handling
tests/integration/test_from_rev.py
Added fixture and four new tests for zntrack.from_rev with various remote and rev parameters, testing dependency resolution and node attribute correctness.
Integration Test Logic Adjustments
tests/integration/test_nested_repo.py
Removed error-expecting tests; now asserts successful node loading and attribute access, reflecting new expected behaviors.
Node Converter Parameter Handling
zntrack/converter.py, zntrack/fields/deps.py
Updated to treat empty remote/rev as None and pass these as optional parameters; removed fallback to empty strings; updated function signature for create_node_converter.
Node Loading and Control Flow
zntrack/from_rev.py
Uses stage.path_in_repo for path resolution; modifies logic to conditionally include filesystem argument based on remote/rev presence; minor code cleanup.
Path Resolution Logic
zntrack/utils/filesystem.py
Simplified resolve_dvc_path: absolute paths are made relative to repo root if possible; relative paths are returned as-is; removed combination with state_path.

Sequence Diagram(s)

sequenceDiagram
    participant Test as Test Function
    participant ZnTrack as zntrack.from_rev
    participant Converter as NodeConverter
    participant FS as Filesystem

    Test->>ZnTrack: Call from_rev(node_name, remote, rev)
    ZnTrack->>FS: Resolve stage.path_in_repo
    ZnTrack->>Converter: Decode node (remote, rev as None if empty)
    Converter-->>ZnTrack: Node instance with dependencies
    ZnTrack-->>Test: Return loaded node with correct attributes
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15-20 minutes

Poem

A rabbit hops through code anew,
Ignoring .DS_Store as all devs do.
Paths resolve with gentle care,
Dependencies tested everywhere!
From remote and rev, to nested repo,
Each node now loads without a woe.
🐇✨ Hooray for tidy code review!

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 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 4023f68 and 25e8784.

📒 Files selected for processing (7)
  • .gitignore (1 hunks)
  • tests/integration/test_from_rev.py (1 hunks)
  • tests/integration/test_nested_repo.py (2 hunks)
  • zntrack/converter.py (1 hunks)
  • zntrack/fields/deps.py (2 hunks)
  • zntrack/from_rev.py (2 hunks)
  • zntrack/utils/filesystem.py (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
zntrack/fields/deps.py (1)
zntrack/node.py (1)
  • state (297-302)
tests/integration/test_from_rev.py (4)
tests/conftest.py (1)
  • proj_path (27-45)
zntrack/examples/nodes.py (3)
  • AddNumbers (80-89)
  • AddNodeAttributes (128-137)
  • c (99-101)
zntrack/from_rev.py (1)
  • from_rev (11-113)
zntrack/node.py (1)
  • from_rev (203-294)
🔇 Additional comments (16)
.gitignore (1)

172-172: LGTM! Standard macOS system file exclusion.

Adding .DS_Store to .gitignore is a common and recommended practice to prevent macOS Finder system files from being committed to version control.

zntrack/fields/deps.py (2)

29-30: LGTM! Improved parameter handling alignment.

The change to pass self.state.remote and self.state.rev directly without defaulting to empty strings aligns with the broader improvements in parameter handling across the codebase, particularly the updates in converter.py that now treat empty strings as None.


55-55: LGTM! Minor formatting cleanup.

Removing the extraneous blank line improves code consistency.

zntrack/from_rev.py (2)

75-78: LGTM! Addresses DVC path resolution issue.

The change from stage.path to stage.path_in_repo correctly addresses the DVC issue where stage.path uses different relative roots depending on whether a revision or only a remote is specified. This ensures consistent path resolution behavior.


109-113: LGTM! Improved filesystem parameter handling.

The conditional logic correctly passes the fs parameter only when remote or rev are specified, allowing the method to fall back to the local filesystem when neither is provided. This aligns with the broader parameter handling improvements across the codebase.

zntrack/converter.py (2)

115-115: LGTM! Function signature reflects optional parameter nature.

Updating the signature to accept str | None for remote and rev parameters properly reflects their optional nature and aligns with the parameter handling improvements across the codebase.


108-109: LGTM! Consistent empty string to None conversion.

The logic to treat empty strings as None for remote and rev parameters when self.path is set ensures consistent parameter handling and aligns with the broader improvements to handle these optional parameters properly throughout the codebase.

zntrack/utils/filesystem.py (2)

15-15: LGTM! Ensures absolute repo root path.

Adding .resolve() ensures that repo_root is an absolute path, which is important for reliable relative path calculations.


18-28: LGTM! Simplified and improved path resolution logic.

The simplified logic correctly handles path resolution by:

  • Converting absolute paths to be relative to the repo root when possible
  • Treating relative paths as already correctly relative to the repo root
  • Removing the previous combination with state_path for relative paths

This aligns with the path handling improvements in from_rev.py and ensures consistent behavior across the codebase.

tests/integration/test_nested_repo.py (2)

57-62: LGTM! Test now verifies successful node loading with absolute path and remote.

The change from expecting a FileNotFoundError to successful loading aligns with the PR objective of fixing zntrack.from_rev with deps. The test properly validates that the loaded node maintains correct parameter and output values.


116-123: LGTM! Test now verifies successful external dependency loading.

The updated test expectation reflects improved handling of external dependencies. The ability to access node.value.parameter even after removing the external module from sys.modules demonstrates that zntrack.from_rev now properly manages external dependency reconstruction, which aligns with the PR's dependency handling improvements.

tests/integration/test_from_rev.py (5)

234-242: Well-structured test fixture for dependency scenarios.

The fixture creates a realistic dependency graph with AddNodeAttributes depending on outputs from two AddNumbers nodes, providing excellent test coverage for the zntrack.from_rev with deps functionality that this PR aims to fix.


245-254: Excellent test coverage for basic dependency resolution.

This test verifies that zntrack.from_rev correctly resolves dependencies, ensuring that dependent node attributes (a=3, b=7) are properly loaded and the computed output (c=10) is accurate. This directly addresses the core issue mentioned in the PR title.


257-272: Good test coverage for dependency resolution with remote parameter.

The test correctly creates a git commit (required for remote/rev functionality) and verifies that dependency resolution works properly when using remote=".". This ensures the PR's fixes work correctly across different loading scenarios.


275-290: Comprehensive test for dependency resolution with revision parameter.

The test properly establishes a git commit to create a valid HEAD reference and verifies that dependency resolution works correctly when loading from a specific revision. This ensures the PR's fixes handle revision-based scenarios properly.


293-309: Thorough test for combined remote and revision parameters.

This test covers the most comprehensive scenario by using both rev="HEAD" and remote="." parameters together. It ensures that dependency resolution works correctly in complex loading scenarios, providing excellent coverage for the PR's fixes.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 930-zntrackfrom_rev-broken

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.
  • 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.

Support

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

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 generate unit tests to generate unit tests 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.

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.

@codecov
Copy link

codecov bot commented Aug 6, 2025

Codecov Report

❌ Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 88.60%. Comparing base (4023f68) to head (25e8784).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
zntrack/utils/filesystem.py 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #931      +/-   ##
==========================================
+ Coverage   88.49%   88.60%   +0.11%     
==========================================
  Files          40       40              
  Lines        2294     2290       -4     
==========================================
- Hits         2030     2029       -1     
+ Misses        264      261       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions
Copy link

github-actions bot commented Aug 6, 2025

Benchmark

Write: Varying number of nodes

Write: Varying number of edges

@PythonFZ PythonFZ marked this pull request as ready for review August 7, 2025 13:40
@PythonFZ PythonFZ merged commit 9bf19ed into main Aug 7, 2025
11 checks passed
@PythonFZ PythonFZ deleted the 930-zntrackfrom_rev-broken branch August 7, 2025 13:54
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.

zntrack.from_rev broken

2 participants