-
Notifications
You must be signed in to change notification settings - Fork 6
Add docs for metadata and ordering #735
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
Conversation
WalkthroughThis 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)
✏️ 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. Comment |
Deploying infrahub-sdk-python with
|
| 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 |
|
|
||
| ### 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: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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
📒 Files selected for processing (2)
docs/docs/python-sdk/guides/query_data.mdxtest.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}: Usetextlanguage 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 withtitlefield 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:
No duplicate "Node metadata" section: Only one "## Node metadata" header appears in the file (at line 530). There is no duplication.
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
| from infrahub_sdk import InfrahubClientSync | ||
| from infrahub_sdk.types import NodeMetaOrder, Order | ||
| from infrahub_sdk.enums import OrderDirection | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| 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
| # 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove commented code and add trailing newline.
Two issues:
- Line 10 contains commented-out debug code that should be removed.
- 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.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.