Skip to content

Refresh python packages #415

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

Open
wants to merge 12 commits into
base: stable
Choose a base branch
from
Open

Refresh python packages #415

wants to merge 12 commits into from

Conversation

BeArchiTek
Copy link
Contributor

@BeArchiTek BeArchiTek commented May 20, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Improved validation to ensure IDs are present before saving credentials, nodes, and relationships, reducing the risk of invalid or incomplete data handling.
    • Standardized ID assignment and type consistency when processing mutation results.
    • Enhanced file reading and writing operations by explicitly using UTF-8 encoding, ensuring consistent behavior across systems.
  • Chores

    • Updated dependency requirements to support different numpy versions based on the Python interpreter version for improved compatibility.

Copy link

cloudflare-workers-and-pages bot commented May 20, 2025

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: f44c8e7
Status: ✅  Deploy successful!
Preview URL: https://213ba63c.infrahub-sdk-python.pages.dev
Branch Preview URL: https://bkr-fix-python.infrahub-sdk-python.pages.dev

View logs

Copy link

codecov bot commented May 20, 2025

Codecov Report

❌ Patch coverage is 33.33333% with 22 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
infrahub_sdk/node/node.py 33.33% 9 Missing and 5 partials ⚠️
infrahub_sdk/transfer/importer/json.py 0.00% 5 Missing ⚠️
infrahub_sdk/ctl/repository.py 0.00% 1 Missing and 1 partial ⚠️
...frahub_sdk/pytest_plugin/items/jinja2_transform.py 0.00% 1 Missing ⚠️
@@            Coverage Diff             @@
##           stable     #415      +/-   ##
==========================================
- Coverage   75.76%   75.61%   -0.15%     
==========================================
  Files         100      100              
  Lines        8838     8806      -32     
  Branches     1733     1324     -409     
==========================================
- Hits         6696     6659      -37     
- Misses       1666     1677      +11     
+ Partials      476      470       -6     
Flag Coverage Δ
integration-tests 34.82% <9.09%> (-0.08%) ⬇️
python-3.10 47.94% <30.30%> (-0.07%) ⬇️
python-3.11 47.96% <30.30%> (?)
python-3.12 47.94% <30.30%> (-0.25%) ⬇️
python-3.13 47.92% <30.30%> (-0.27%) ⬇️
python-3.9 46.62% <30.30%> (-0.04%) ⬇️
python-filler-3.12 25.18% <6.06%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
infrahub_sdk/node/related_node.py 90.25% <100.00%> (ø)
infrahub_sdk/pytest_plugin/utils.py 69.23% <100.00%> (ø)
infrahub_sdk/utils.py 84.75% <100.00%> (ø)
...frahub_sdk/pytest_plugin/items/jinja2_transform.py 60.29% <0.00%> (ø)
infrahub_sdk/ctl/repository.py 79.74% <0.00%> (-5.97%) ⬇️
infrahub_sdk/transfer/importer/json.py 15.27% <0.00%> (-0.11%) ⬇️
infrahub_sdk/node/node.py 73.84% <33.33%> (-1.35%) ⬇️

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@BeArchiTek BeArchiTek self-assigned this May 21, 2025
@BeArchiTek BeArchiTek marked this pull request as ready for review May 21, 2025 09:15
@BeArchiTek BeArchiTek requested a review from a team May 21, 2025 09:15
@dgarros dgarros requested a review from ogenstad June 13, 2025 06:42
Copy link
Contributor

@ogenstad ogenstad left a comment

Choose a reason for hiding this comment

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

I made a small comment regarding the change in pyproject.toml.

Also this PR has a merge conflict that needs to be resolved first. It looks like we're doing different things within this PR. Could we perhaps close this one and open two new ones, one for the package update and another one for the code changes and explain the changes with an issue or news fragment if needed?

Copy link

coderabbitai bot commented Jul 29, 2025

"""

Walkthrough

The changes introduce stricter checks for the presence and validity of IDs before proceeding with operations involving nodes, credentials, or relationships. File reading and writing operations are updated to explicitly use UTF-8 encoding. Dependency management for numpy in pyproject.toml is refined to align with Python version compatibility. Minor code simplifications include removing redundant None defaults in dictionary lookups and adding type annotations.

Changes

Cohort / File(s) Change Summary
Node ID Checks and Assignment
infrahub_sdk/node/node.py, infrahub_sdk/ctl/repository.py, infrahub_sdk/transfer/importer/json.py
Added explicit checks to ensure IDs are set before saving nodes, credentials, or processing relationships. Assignment of IDs now explicitly converts to string.
Attribute and Related Node Initialization
infrahub_sdk/node/attribute.py, infrahub_sdk/node/related_node.py
Simplified use of dict.get() by removing unnecessary None defaults in attribute and related node initialization; added explicit type annotation for _peer.
File Encoding Consistency
infrahub_sdk/pytest_plugin/items/jinja2_transform.py, infrahub_sdk/pytest_plugin/utils.py, infrahub_sdk/transfer/importer/json.py, infrahub_sdk/utils.py
Updated file reading and writing operations to explicitly specify UTF-8 encoding.
Dependency Versioning
pyproject.toml
Refined numpy dependency to differentiate between Python versions below and above 3.13.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Node
    participant Repository
    participant Importer

    User->>Node: save()
    alt Node.id is set
        Node->>Node: Add related groups/nodes
    else Node.id is not set
        Node->>User: Raise UninitializedError
    end

    User->>Repository: Save credential
    Repository->>Repository: Check credential.id
    alt credential.id is not set
        Repository->>User: Raise ValueError
    end

    Importer->>Importer: import_data()
    alt node.id is set
        Importer->>Importer: Add node to all_nodes
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes
"""

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 9e01a40 and f521e35.

📒 Files selected for processing (1)
  • infrahub_sdk/node/node.py (7 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • infrahub_sdk/node/node.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: unit-tests (3.13)
  • GitHub Check: unit-tests (3.12)
  • GitHub Check: unit-tests (3.10)
  • GitHub Check: unit-tests (3.9)
  • GitHub Check: unit-tests (3.11)
  • GitHub Check: integration-tests-latest-infrahub
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bkr-fix-python

🪧 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 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 or 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.

@BeArchiTek BeArchiTek requested review from ogenstad and a team July 29, 2025 08:56
Copy link

@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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6fe7675 and 9e01a40.

📒 Files selected for processing (2)
  • infrahub_sdk/node/node.py (7 hunks)
  • infrahub_sdk/node/related_node.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • infrahub_sdk/node/related_node.py
🧰 Additional context used
🧬 Code Graph Analysis (1)
infrahub_sdk/node/node.py (4)
infrahub_sdk/exceptions.py (1)
  • UninitializedError (156-157)
infrahub_sdk/node/related_node.py (5)
  • id (83-86)
  • fetch (204-210)
  • fetch (251-257)
  • peer (213-214)
  • peer (260-261)
infrahub_sdk/node/relationship.py (2)
  • fetch (148-182)
  • fetch (271-306)
infrahub_sdk/query_groups.py (4)
  • add_related_groups (127-138)
  • add_related_groups (221-232)
  • add_related_nodes (114-125)
  • add_related_nodes (208-219)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: unit-tests (3.12)
  • GitHub Check: unit-tests (3.10)
  • GitHub Check: unit-tests (3.11)
  • GitHub Check: unit-tests (3.13)
  • GitHub Check: integration-tests-latest-infrahub
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (6)
infrahub_sdk/node/node.py (6)

8-14: LGTM! Import addition is correctly placed.

The UninitializedError import is properly added and follows the existing alphabetical ordering pattern.


583-585: Good defensive programming with ID validation.

The check ensures the artifact has a valid ID before attempting to fetch its definition relationship and generate the artifact, preventing potential issues with uninitialized objects.


1176-1178: Consistent ID validation in sync version.

The ID validation logic matches the async implementation, maintaining consistency across both interfaces.


629-643: Excellent ID validation before group context operations.

The validation ensures nodes have valid IDs before adding them to group contexts, preventing operations on uninitialized objects. The error messages are clear and descriptive.


828-828: Good explicit type conversion for ID consistency.

The explicit str() conversion ensures IDs are consistently handled as strings throughout the codebase, preventing potential type-related issues.


1417-1417: Consistent ID type handling in sync version.

The explicit string conversion matches the async implementation, maintaining type consistency across both interfaces.

I do not remember changing this one
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.

2 participants