Conversation
Merge develop into infrahub-develop
Merge develop into infrahub-develop
Merge develop into infrahub-develop
Merge develop into infrahub-develop
Merge develop into infrahub-develop
Merge develop into infrahub-develop
This change adds support to create, update and retrieve nodes which schemas implement `CoreFileObject`.
The proposed user exposed API follows these key points:
- `node.upload_from_path(path)` to select a file from disk for upload (streams during upload)
- `node.upload_from_bytes(content, name)` to set content for upload (supports bytes or BinaryIO)
- `node.download_file(dest)` to download a file to memory or stream to disk
Being able to stream a file to disk or from a disk is important in order to support large files and to avoid them being loaded completely into memory (which would be problematic for +1GB files in general).
The choice of using `upload_from_path` and `upload_from_bytes` is to prevent a collision with a potential attribute or relationship called `file` in the schema. That is also the reason why the `file` GraphQL parameter is outside the `data` one instead of inside it.
Here we introduce a couple of components to try to make our code SOLID (it's not much for now, but it's honest work):
- `FileHandler` / `FileHandlerSync` dedicated classes for file I/O operations
- `MultipartBuilder` GraphQL Multipart Request Spec payload building
It sure won't make our code SOLID but it won't add to the burden for now.
So given the user who loaded a schema, using our SDK will look like:
#### Upload a file when creating a node
```python
from pathlib import Path
from infrahub_sdk import InfrahubClientSync
client = InfrahubClientSync()
contract = client.create(
kind="NetworkCircuitContract", contract_start="2026-01-01", contract_end="2026-12-31"
)
# Option 1: Select file from disk (will be streamed during upload)
contract.upload_from_path(path=Path("/tmp/contract.pdf"))
# Option 2: Upload from memory (for small files or dynamically generated content)
contract.upload_from_bytes(content=b"file content", name="contract.pdf")
# Save as usual
contract.save()
```
#### Download a file from a node
```python
from pathlib import Path
contract = client.get(kind="NetworkCircuitContract", id="abc123")
# Download to memory (suitable for small files)
content = contract.download_file()
# Or stream directly to disk (suitable for large files)
bytes_written = contract.download_file(dest=Path("/tmp/downloaded.pdf"))
```
This was broken because the API server will now expose the `created_by` and `created_at` values inside the node metadata. Also add `get_node_metadata` to `CoreNodeBase` protocol.
…key` instead of `if`-`else`-block
These tests won't pass yet, as we need the upcoming Infrahub 1.8 to run them, hence marking them as XFAIL for now.
…20260210 Merge 'develop' into 'infrahub-develop' with resolved conflicts
Use ternary operator instead of `if`-`else`-block
Merge develop into infrahub-develop
Linting: Incorrect import of `pytest`; use `import pytest` instead
Avoid + operator to concatenate collections
Break apart ty violations into smaller components
Merge develop into infrahub-develop
Add py.typed
- Strip relationship fields that match schema loading defaults (direction: bidirectional, on_delete: no-action, cardinality: many, optional: true, min_count: 0, max_count: 0) - Exclude branch from attribute/relationship dumps (inherited from node) - Ensure scalar fields appear before attributes/relationships lists Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
read_only was unconditionally excluded from attribute dumps; move it to _ATTR_EXPORT_DEFAULTS so it is stripped only when False (the default) and kept when True (computed/read-only attributes). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Reraise exceptions where applicable
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Resolve conflicts: - Keep export command in ctl/schema.py (removed on stable, added on branch) - Accept deletion of tests/unit/ctl/test_schema_export.py (tests moved to tests/unit/sdk/) - Move RESTRICTED_NAMESPACES into schema/export.py (removed from constants.py on stable) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Merge develop into infrahub-develop
Fix: Wrong type passed to first argument of `pytest.mark.parametrize`
- Fix import ordering in test_schema_export.py (infrahub_sdk.schema above TYPE_CHECKING) - Use clients fixture + client_types pattern matching existing test conventions - Fix warnings.warn stacklevel from 2 to 3 for correct caller attribution - Pass populate_cache=False in both async/sync export to prevent cache poisoning Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…antic models Addresses PR review feedback: export() now returns a proper SchemaExport object instead of dict[str, dict[str, list[dict[str, Any]]]], making the API easier to understand and use. Includes .to_dict() for serialization. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Merge develop into infrahub-develop
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add the ability to export the schema in yaml
…-develop-into-infrahub-develop # Conflicts: # tests/unit/sdk/conftest.py
…infrahub-develop Manual merge from develop into infrahub-develop. This includes additional test-only typing and linting rules adaptation
Merge develop into infrahub-develop
Set version to 1.19.0 release candidate 0
prepare release v1.19.0
Deploying infrahub-sdk-python with
|
| Latest commit: |
84ee9ef
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://e5b0e805.infrahub-sdk-python.pages.dev |
ogenstad
approved these changes
Mar 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Merging stable into develop after merging pull request #870.