Skip to content

Conversation

@minitriga
Copy link
Contributor

@minitriga minitriga commented Jan 5, 2026

Summary by CodeRabbit

  • Documentation
    • Added comprehensive guidance on using node metadata in queries, how to include and access metadata fields, and examples for combining metadata with ordering.
    • Added examples for ordering results by metadata, disabling default ordering for performance, and both async and sync usage patterns.
    • Note: the node metadata section was duplicated in the docs.
  • Tests
    • Added a Python example demonstrating fetching items with metadata and ordered results.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 5, 2026

Walkthrough

This pull request updates the Python SDK query data documentation guide to add comprehensive node metadata coverage. It introduces sections that define node metadata, show how to include it in queries, and explain how to access metadata via get_node_metadata(). It adds guidance and examples for ordering query results by metadata (Order, NodeMetaOrder, OrderDirection), disabling default ordering (Order(disable=True)), and combining metadata inclusion with ordering for both all and filters methods. Async and sync examples are provided. A duplicate node metadata block appears twice in the same file. No public API declarations were changed.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add docs for metadata and ordering' directly and clearly summarizes the main changes: documentation additions covering node metadata and query result ordering.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added the type/documentation Improvements or additions to documentation label Jan 5, 2026
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 5, 2026

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0a44c59
Status: ✅  Deploy successful!
Preview URL: https://40cc355e.infrahub-sdk-python.pages.dev
Branch Preview URL: https://atg-20260105-metadata-docs.infrahub-sdk-python.pages.dev

View logs


### Accessing node metadata

Once metadata is included in the query, you can access it using the `get_node_metadata()` method. The metadata object contains the following fields:
Copy link
Contributor

Choose a reason for hiding this comment

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

There's also a get_relationship_metadata() method on RelatedNode objects to access the metadata of relationships.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ogenstad I have pushed a new commit which should resolve this.

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: 2

🤖 Fix all issues with AI agents
In @test.py:
- Around line 10-12: Remove the leftover commented debug line that prints
tag.name.value (the commented "print(f\"Tag: {tag.name.value}\")") so only
active code remains; ensure the remaining lines use tag.get_node_metadata() and
the print(f"{tag.name.value} - Last updated: {metadata.updated_at}") call, and
add a final trailing newline at the end of the file so the print line ends with
a newline character.
- Around line 1-4: Reorder the imports to satisfy the linter by grouping and
alphabetizing module paths and names: keep the top-level import
"InfrahubClientSync" first, then import from "infrahub_sdk.enums"
(OrderDirection), and finally from "infrahub_sdk.types" with the names sorted
(NodeMetaOrder, Order); update the three import lines accordingly.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4d73593 and f08a9c3.

📒 Files selected for processing (2)
  • docs/docs/python-sdk/guides/query_data.mdx
  • test.py
🧰 Additional context used
📓 Path-based instructions (4)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Use type hints on all function signatures
Never mix async/sync inappropriately
Never bypass type checking without justification

Files:

  • test.py
**/*.{md,mdx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{md,mdx}: Use text language for directory structure code blocks in markdown documentation
Add blank lines before and after lists in markdown documentation
Always specify language in fenced code blocks in markdown documentation

Files:

  • docs/docs/python-sdk/guides/query_data.mdx
docs/docs/**/*.mdx

📄 CodeRabbit inference engine (docs/AGENTS.md)

docs/docs/**/*.mdx: Create MDX files in appropriate directory within docs structure (guides, topics, or reference)
Add frontmatter with title field to MDX documentation files
Use callouts (:::warning, :::note, etc.) for important notes and information in documentation

Files:

  • docs/docs/python-sdk/guides/query_data.mdx
docs/docs/python-sdk/{guides,topics}/**/*.mdx

📄 CodeRabbit inference engine (docs/AGENTS.md)

docs/docs/python-sdk/{guides,topics}/**/*.mdx: Use Tabs component from '@theme/Tabs' for async/sync examples in documentation
Include both async/sync examples using Tabs in documentation

Files:

  • docs/docs/python-sdk/guides/query_data.mdx
🪛 GitHub Actions: CI
test.py

[error] 1-4: Ruff: Import block is unsorted. Organize imports.


[error] 12-12: Ruff: No newline at end of file. Add trailing newline.

⏰ 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). (1)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (3)
docs/docs/python-sdk/guides/query_data.mdx (3)

530-668: Excellent documentation of metadata features.

The Node metadata and Relationship metadata sections are well-documented with:

  • Clear explanations of concepts
  • Both async and sync examples using Tabs
  • Proper code block language specifications
  • Helpful callout note distinguishing node vs. relationship metadata
  • Consistent examples that align with the test file usage

669-801: Well-structured ordering documentation.

The ordering section provides comprehensive coverage of:

  • Ordering by node metadata with clear examples
  • Performance optimization via Order(disable=True)
  • Combining metadata inclusion with ordering
  • Proper use of OrderDirection enum values
  • Helpful callout note about mutual exclusivity of ordering fields

The examples are consistent and demonstrate practical use cases effectively.


530-801: No action required—the file already complies with all formatting guidelines.

The review identified two concerns that do not actually exist:

  1. No duplicate "Node metadata" section: Only one "## Node metadata" header appears in the file (at line 530). There is no duplication.

  2. Blank lines are already present before both lists:

    • Line 559: A blank line already exists between the explanatory text and the metadata fields list.
    • Line 605: A blank line already exists between the explanatory text and the NodeProperty fields list.

The documentation already follows the coding guideline requiring blank lines before and after lists.

test.py Outdated
Comment on lines 1 to 4
from infrahub_sdk import InfrahubClientSync
from infrahub_sdk.types import NodeMetaOrder, Order
from infrahub_sdk.enums import OrderDirection

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Fix import sorting as indicated by the linter.

The pipeline reports that imports are unsorted. Organize the imports according to the project's linting rules.

📦 Proposed fix for import order
 from infrahub_sdk import InfrahubClientSync
-from infrahub_sdk.types import NodeMetaOrder, Order
 from infrahub_sdk.enums import OrderDirection
+from infrahub_sdk.types import NodeMetaOrder, Order
📝 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
from infrahub_sdk import InfrahubClientSync
from infrahub_sdk.types import NodeMetaOrder, Order
from infrahub_sdk.enums import OrderDirection
from infrahub_sdk import InfrahubClientSync
from infrahub_sdk.enums import OrderDirection
from infrahub_sdk.types import NodeMetaOrder, Order
🧰 Tools
🪛 GitHub Actions: CI

[error] 1-4: Ruff: Import block is unsorted. Organize imports.

🤖 Prompt for AI Agents
In @test.py around lines 1 - 4, Reorder the imports to satisfy the linter by
grouping and alphabetizing module paths and names: keep the top-level import
"InfrahubClientSync" first, then import from "infrahub_sdk.enums"
(OrderDirection), and finally from "infrahub_sdk.types" with the names sorted
(NodeMetaOrder, Order); update the three import lines accordingly.

test.py Outdated
Comment on lines 10 to 12
# print(f"Tag: {tag.name.value}")
metadata = tag.get_node_metadata()
print(f"{tag.name.value} - Last updated: {metadata.updated_at}") No newline at end of file
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Remove commented code and add trailing newline.

Two issues:

  1. Line 10 contains commented-out debug code that should be removed.
  2. Line 12 is missing a trailing newline (flagged by pipeline).
🧹 Proposed fix
 for tag in tags:
-    # print(f"Tag: {tag.name.value}")
     metadata = tag.get_node_metadata()
     print(f"{tag.name.value} - Last updated: {metadata.updated_at}")
+
🧰 Tools
🪛 GitHub Actions: CI

[error] 12-12: Ruff: No newline at end of file. Add trailing newline.

🤖 Prompt for AI Agents
In @test.py around lines 10 - 12, Remove the leftover commented debug line that
prints tag.name.value (the commented "print(f\"Tag: {tag.name.value}\")") so
only active code remains; ensure the remaining lines use tag.get_node_metadata()
and the print(f"{tag.name.value} - Last updated: {metadata.updated_at}") call,
and add a final trailing newline at the end of the file so the print line ends
with a newline character.

@minitriga minitriga merged commit 927892c into infrahub-develop Jan 8, 2026
15 checks passed
@minitriga minitriga deleted the atg-20260105-metadata-docs branch January 8, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants