Skip to content

Merge stable into develop#871

Merged
ogenstad merged 69 commits intodevelopfrom
stable
Mar 17, 2026
Merged

Merge stable into develop#871
ogenstad merged 69 commits intodevelopfrom
stable

Conversation

@infrahub-github-bot-app
Copy link
Contributor

Merging stable into develop after merging pull request #870.

ogenstad and others added 30 commits January 9, 2026 09:38
Merge develop into infrahub-develop
* IHS-183: Fix typing errors for protocols

* fix ty

* fix failing tests

* address comments

Co-authored-by: Babatunde Olusola <solababatunde12@gmail.com>
Merge develop into infrahub-develop
This reverts commit 6c0bf35.

Co-authored-by: Babatunde Olusola <solababatunde12@gmail.com>
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.
Co-authored-by: Babatunde Olusola <solababatunde12@gmail.com>
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
- 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>
ogenstad and others added 23 commits February 20, 2026 10:14
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
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Mar 16, 2026

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: 84ee9ef
Status: ✅  Deploy successful!
Preview URL: https://e5b0e805.infrahub-sdk-python.pages.dev

View logs

@github-actions github-actions bot added the type/documentation Improvements or additions to documentation label Mar 16, 2026
@ogenstad ogenstad merged commit a4c5ecb into develop Mar 17, 2026
47 checks passed
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.

6 participants