Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/docs/python-sdk/reference/compatibility.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Each Infrahub release pins a specific SDK version. Using the matching SDK versio
<!-- vale off -->
| Infrahub | Required SDK | Release date |
| --- | --- | --- |
| 1.9.x | >= 1.20.0 | April 2026 |
| 1.8.x | >= 1.19.0 | March 2026 |
| 1.7.x | >= 1.18.1 | January 2026 |
| 1.6.x | >= 1.16.0 | December 2025 |
Expand All @@ -31,6 +32,12 @@ The table below shows the exact SDK version pinned to each Infrahub release.
<!-- vale off -->
| Infrahub | SDK version | Infrahub release date |
| --- | --- | --- |
| 1.9.3 | 1.20.0 | 2026-05-05 |
| 1.9.2 | 1.20.0 | 2026-04-30 |
| 1.9.1 | 1.20.0 | 2026-04-29 |
| 1.9.0 | 1.20.0 | 2026-04-24 |
| 1.8.6 | 1.19.0 | 2026-04-21 |
| 1.8.5 | 1.19.0 | 2026-04-17 |
| 1.8.4 | 1.19.0 | 2026-04-02 |
| 1.8.3 | 1.19.0 | 2026-03-31 |
| 1.8.2 | 1.19.0 | 2026-03-25 |
Expand Down
20 changes: 12 additions & 8 deletions docs/docs/python-sdk/sdk_ref/infrahub_sdk/client.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,9 @@ Allocate a new IP address by using the provided resource pool.
- `timeout`: Flag to indicate whether to populate the store with the retrieved nodes.
- `tracker`: The offset for pagination.

Returns:
InfrahubNode: Node corresponding to the allocated resource.
**Returns:**

- Node corresponding to the allocated resource.

</details>
#### `allocate_next_ip_prefix`
Expand Down Expand Up @@ -359,8 +360,9 @@ Allocate a new IP prefix by using the provided resource pool.
- `timeout`: Flag to indicate whether to populate the store with the retrieved nodes.
- `tracker`: The offset for pagination.

Returns:
InfrahubNode: Node corresponding to the allocated resource.
**Returns:**

- Node corresponding to the allocated resource.

</details>
#### `create_batch`
Expand Down Expand Up @@ -708,8 +710,9 @@ Allocate a new IP address by using the provided resource pool.
- `timeout`: Flag to indicate whether to populate the store with the retrieved nodes.
- `tracker`: The offset for pagination.

Returns:
InfrahubNodeSync: Node corresponding to the allocated resource.
**Returns:**

- Node corresponding to the allocated resource.

</details>
#### `allocate_next_ip_prefix`
Expand Down Expand Up @@ -747,8 +750,9 @@ Allocate a new IP prefix by using the provided resource pool.
- `timeout`: Flag to indicate whether to populate the store with the retrieved nodes.
- `tracker`: The offset for pagination.

Returns:
InfrahubNodeSync: Node corresponding to the allocated resource.
**Returns:**

- Node corresponding to the allocated resource.

</details>
#### `repository_update_commit`
Expand Down
11 changes: 11 additions & 0 deletions docs/docs_generation/compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class ReleaseMapping:
infrahub: Infrahub server version (e.g. "1.8.4").
sdk: SDK version pinned to this release (e.g. "1.19.0").
date: Infrahub release date in YYYY-MM-DD format.

"""

infrahub: str
Expand All @@ -32,6 +33,7 @@ class VersionRange:
infrahub: Infrahub minor version pattern (e.g. "1.8.x").
min_sdk: Minimum required SDK version (e.g. "1.19.0").
date: Approximate release month (e.g. "March 2026").

"""

infrahub: str
Expand All @@ -46,6 +48,7 @@ class PythonSupport:
Args:
sdk_range: SDK version range description (e.g. ">= 1.17.0").
python_versions: Comma-separated Python versions (e.g. "3.10, 3.11, 3.12, 3.13, 3.14").

"""

sdk_range: str
Expand All @@ -60,6 +63,7 @@ class FeatureRequirement:
feature: Feature name or description.
min_sdk: Minimum SDK version required.
min_infrahub: Minimum Infrahub version required.

"""

feature: str
Expand All @@ -70,6 +74,7 @@ class FeatureRequirement:
# Mapping of Infrahub minor version series to minimum SDK versions.
# Auto-updated by update_compatibility.py.
VERSION_RANGES: list[VersionRange] = [
VersionRange(infrahub="1.9.x", min_sdk="1.20.0", date="April 2026"),
VersionRange(infrahub="1.8.x", min_sdk="1.19.0", date="March 2026"),
VersionRange(infrahub="1.7.x", min_sdk="1.18.1", date="January 2026"),
VersionRange(infrahub="1.6.x", min_sdk="1.16.0", date="December 2025"),
Expand All @@ -85,6 +90,12 @@ class FeatureRequirement:
# Detailed mapping of every Infrahub release to its pinned SDK version.
# Auto-updated by update_compatibility.py.
RELEASE_MAPPINGS: list[ReleaseMapping] = [
ReleaseMapping(infrahub="1.9.3", sdk="1.20.0", date="2026-05-05"),
ReleaseMapping(infrahub="1.9.2", sdk="1.20.0", date="2026-04-30"),
ReleaseMapping(infrahub="1.9.1", sdk="1.20.0", date="2026-04-29"),
ReleaseMapping(infrahub="1.9.0", sdk="1.20.0", date="2026-04-24"),
ReleaseMapping(infrahub="1.8.6", sdk="1.19.0", date="2026-04-21"),
ReleaseMapping(infrahub="1.8.5", sdk="1.19.0", date="2026-04-17"),
ReleaseMapping(infrahub="1.8.4", sdk="1.19.0", date="2026-04-02"),
ReleaseMapping(infrahub="1.8.3", sdk="1.19.0", date="2026-03-31"),
ReleaseMapping(infrahub="1.8.2", sdk="1.19.0", date="2026-03-25"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class CommandOutputDocContentGenMethod(ADocContentGenMethod):
command=TyperCommand(module="infrahub_sdk.ctl.cli_commands", name="dump", app_name="infrahubctl", is_function=True),
)
content = method.apply()
"""

def __init__(self, context: Context, working_directory: Path, command: ACommand) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class FilePrintingDocContentGenMethod(ADocContentGenMethod):

Args:
file: The ``MdxFile`` whose content will be returned.

"""

def __init__(self, file: MdxFile) -> None:
Expand Down
1 change: 1 addition & 0 deletions docs/docs_generation/content_gen_methods/jinja2_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Jinja2DocContentGenMethod(ADocContentGenMethod):
template_variables={"builtin": BUILTIN_FILTERS},
)
content = method.apply()

"""

def __init__(self, template: Jinja2Template, template_variables: dict[str, Any]) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class MdxCodeDocumentation(ACodeDocumentation):

doc = MdxCodeDocumentation()
files = doc.generate(context=ctx, modules_to_document=["infrahub_sdk.node"])

"""

def __init__(
Expand Down
2 changes: 2 additions & 0 deletions docs/docs_generation/content_gen_methods/mdx/mdx_priority.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class PagePriority:
classes: Ordered list of class/function names to appear first on the page.
methods: Per-class ordered list of method names to appear first.
Key is class name, value is ordered method name list.

"""

sections: list[str] = field(default_factory=list)
Expand All @@ -46,6 +47,7 @@ class SectionPriority:
names: Ordered list of child section names to appear first.
sub_priorities: Per-child priorities for deeper nesting.
Key is child name, value is ordered subsection name list.

"""

names: list[str] = field(default_factory=list)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class MdxSection(ASection):
name: Item name extracted from the heading (e.g. class or method name).
heading_level: Markdown heading level (2, 3, or 4).
_lines: All lines belonging to this section, including the heading.

"""

name: str
Expand Down
2 changes: 2 additions & 0 deletions docs/docs_generation/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def get_env_vars() -> dict[str, list[str]]:

Returns:
Mapping of field name to list of upper-cased environment variable names.

"""
env_vars: dict[str, list[str]] = defaultdict(list)
settings = ConfigBase()
Expand Down Expand Up @@ -47,6 +48,7 @@ def build_config_properties() -> list[dict[str, Any]]:
Returns:
List of dicts with keys: ``name``, ``description``, ``type``,
``choices``, ``default``, ``env_vars``.

"""
schema = ConfigBase.model_json_schema()
env_vars = get_env_vars()
Expand Down
2 changes: 2 additions & 0 deletions docs/docs_generation/pages/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class DocPage:

page = DocPage(content_gen_method=Jinja2DocContentGenMethod(...))
print(page.content())

"""

def __init__(self, content_gen_method: ADocContentGenMethod) -> None:
Expand All @@ -38,6 +39,7 @@ class MDXDocPage:

mdx = MDXDocPage(page=my_page, output_path=Path("docs/ref/client.mdx"))
mdx.to_mdx()

"""

_CONTROL_CHAR_RE = re.compile(r"[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]")
Expand Down
11 changes: 11 additions & 0 deletions docs/docs_generation/update_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def _paginated_get(client: httpx.Client, url: str) -> list[dict]:

Returns:
Combined list of JSON objects from all pages.

"""
results: list[dict] = []
while url:
Expand All @@ -72,6 +73,7 @@ def _fetch_infrahub_tags(client: httpx.Client) -> dict[str, str]:

Returns:
Dict mapping version strings (e.g. "1.8.4") to commit SHAs.

"""
tags = _paginated_get(client, f"{API_BASE}/repos/{INFRAHUB_REPO}/tags?per_page=100")
result = {}
Expand All @@ -90,6 +92,7 @@ def _fetch_sdk_tags(client: httpx.Client) -> dict[str, str]:

Returns:
Dict mapping commit SHAs to version strings (e.g. "1.19.0").

"""
tags = _paginated_get(client, f"{API_BASE}/repos/{SDK_REPO}/tags?per_page=100")
result = {}
Expand All @@ -109,6 +112,7 @@ def _get_submodule_sha(client: httpx.Client, commit_sha: str) -> str | None:

Returns:
The submodule commit SHA, or None if not found.

"""
resp = client.get(f"{API_BASE}/repos/{INFRAHUB_REPO}/git/trees/{commit_sha}")
resp.raise_for_status()
Expand All @@ -128,6 +132,7 @@ def _get_commit_date(client: httpx.Client, repo: str, sha: str) -> str:

Returns:
Date string in YYYY-MM-DD format.

"""
resp = client.get(f"{API_BASE}/repos/{repo}/git/commits/{sha}")
resp.raise_for_status()
Expand All @@ -153,6 +158,7 @@ def _find_nearest_sdk_version(

Returns:
SDK version string, or None if no version could be resolved.

"""
if submodule_sha in sdk_tag_map:
return sdk_tag_map[submodule_sha]
Expand Down Expand Up @@ -181,6 +187,7 @@ def _version_sort_key(version: str) -> tuple[int, ...]:

Returns:
Tuple of integers for comparison.

"""
return tuple(int(x) for x in version.split("."))

Expand All @@ -199,6 +206,7 @@ def _derive_version_ranges(
Returns:
List of (infrahub_pattern, min_sdk, month_year) tuples, sorted by
version descending.

"""
groups: dict[str, list[tuple[str, str]]] = defaultdict(list)
for infrahub_ver, sdk_ver, date in release_mappings:
Expand Down Expand Up @@ -228,6 +236,7 @@ def _format_release_mappings(mappings: list[tuple[str, str, str]]) -> str:

Returns:
Python source for the RELEASE_MAPPINGS list assignment.

"""
lines = [
"# Detailed mapping of every Infrahub release to its pinned SDK version.",
Expand All @@ -248,6 +257,7 @@ def _format_version_ranges(ranges: list[tuple[str, str, str]]) -> str:

Returns:
Python source for the VERSION_RANGES list assignment.

"""
lines = [
"# Mapping of Infrahub minor version series to minimum SDK versions.",
Expand All @@ -266,6 +276,7 @@ def _update_file(release_mappings: list[tuple[str, str, str]]) -> None:
Args:
release_mappings: List of (infrahub_version, sdk_version, date) tuples,
sorted by version descending.

"""
content = COMPATIBILITY_FILE.read_text()

Expand Down
1 change: 1 addition & 0 deletions infrahub_sdk/_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def import_module(module_path: Path, import_root: str | None = None, relative_pa
module_path (Path): Absolute path of the module to import.
import_root (Optional[str]): Absolute string path to the current repository.
relative_path (Optional[str]): Relative string path between module_path and import_root.

"""
import_root = import_root or str(module_path.parent)

Expand Down
6 changes: 2 additions & 4 deletions infrahub_sdk/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ def log_entries(self) -> str:
@property
def branch_name(self) -> str:
"""Return the name of the current git branch."""

if self.branch:
return self.branch

Expand All @@ -149,13 +148,12 @@ def validate(self, data: dict) -> None:

async def collect_data(self) -> dict:
"""Query the result of the GraphQL Query defined in self.query and return the result"""

return await self.client.query_gql_query(name=self.query, branch_name=self.branch_name, variables=self.params)

async def run(self, data: dict | None = None) -> bool:
"""Execute the check after collecting the data from the GraphQL query.
The result of the check is determined based on the presence or not of ERROR log messages."""

The result of the check is determined based on the presence or not of ERROR log messages.
"""
if not data:
data = await self.collect_data()
unpacked = data.get("data") or data
Expand Down
Loading
Loading