From fe51bb1cf32f8f3748ec872e3643dc6c2fc44d9d Mon Sep 17 00:00:00 2001 From: wvandeun Date: Thu, 5 Jun 2025 14:35:59 +0200 Subject: [PATCH 1/5] bump version to 1.12.2 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 7354170..10e4950 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "infrahub-sdk" -version = "1.12.1" +version = "1.12.2" description = "Python Client to interact with Infrahub" authors = ["OpsMill "] readme = "README.md" From 76883be5ea2f725d3c6b2f1da0996c2489938dbd Mon Sep 17 00:00:00 2001 From: wvandeun Date: Thu, 5 Jun 2025 14:46:46 +0200 Subject: [PATCH 2/5] add changelog --- CHANGELOG.md | 16 ++++++++++++++++ changelog/+26b92d23.housekeeping.md | 1 - 2 files changed, 16 insertions(+), 1 deletion(-) delete mode 100644 changelog/+26b92d23.housekeeping.md diff --git a/CHANGELOG.md b/CHANGELOG.md index ba08464..50e85f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,22 @@ This project uses [*towncrier*](https://towncrier.readthedocs.io/) and the chang +## [1.12.2](https://github.com/opsmill/infrahub-sdk-python/tree/v1.12.2) - 2025-06-05 + +### Fixed + +- fix bug in Timestamp.add by @ajtmccarty in [#403](https://github.com/opsmill/infrahub-sdk-python/pull/403) +- utils.py: improve file not found exception message by @granoe668 in [#425](https://github.com/opsmill/infrahub-sdk-python/pull/425) + +### Changed + +- Add partial_match to the client.count() by @BeArchiTek in [#411](https://github.com/opsmill/infrahub-sdk-python/pull/411) + +### Housekeeping + +- Loosen pinned requirement for `whenever` to allow versions from 0.7.2 up to but not including 0.8.0. +- Bump http-proxy-middleware from 2.0.7 to 2.0.9 in /docs by @dependabot in [#418](https://github.com/opsmill/infrahub-sdk-python/pull/418) + ## [1.12.1](https://github.com/opsmill/infrahub-sdk-python/tree/v1.12.1) - 2025-05-12 ### Changed diff --git a/changelog/+26b92d23.housekeeping.md b/changelog/+26b92d23.housekeeping.md deleted file mode 100644 index 6a49d75..0000000 --- a/changelog/+26b92d23.housekeeping.md +++ /dev/null @@ -1 +0,0 @@ -Loosen pinned requirement for `whenever` to allow versions from 0.7.2 up to but not including 0.8.0. From 1018811d152f8861db476a61aa5ca3d3b75365d9 Mon Sep 17 00:00:00 2001 From: Patrick Ogenstad Date: Thu, 5 Jun 2025 16:46:54 +0200 Subject: [PATCH 3/5] Add transform infrahub_node argument --- infrahub_sdk/pytest_plugin/items/python_transform.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/infrahub_sdk/pytest_plugin/items/python_transform.py b/infrahub_sdk/pytest_plugin/items/python_transform.py index a030f8a..02977f4 100644 --- a/infrahub_sdk/pytest_plugin/items/python_transform.py +++ b/infrahub_sdk/pytest_plugin/items/python_transform.py @@ -7,6 +7,7 @@ import ujson from httpx import HTTPStatusError +from ...node import InfrahubNode from ..exceptions import OutputMatchError, PythonTransformDefinitionError from ..models import InfrahubTestExpectedResult from .base import InfrahubItem @@ -41,7 +42,7 @@ def instantiate_transform(self) -> None: ) client = self.session.infrahub_client # type: ignore[attr-defined] # TODO: Look into seeing how a transform class may use the branch, but set as a empty string for the time being to keep current behaviour - self.transform_instance = transform_class(branch="", client=client) + self.transform_instance = transform_class(branch="", client=client, infrahub_node=InfrahubNode) def run_transform(self, variables: dict[str, Any]) -> Any: self.instantiate_transform() From deaaa36072f5df7193a81a597c320d6a32cc875d Mon Sep 17 00:00:00 2001 From: wvandeun Date: Fri, 6 Jun 2025 08:39:06 +0200 Subject: [PATCH 4/5] allow rich from v12.0.0 and below v14.0.0 --- poetry.lock | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/poetry.lock b/poetry.lock index 2558510..a1b4c06 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2394,4 +2394,4 @@ tests = ["Jinja2", "pytest", "pyyaml", "rich"] [metadata] lock-version = "2.1" python-versions = "^3.9, <3.14" -content-hash = "8fb3db8c3b2045247ef681d483005c7f3d19579fb9f982d9595a3ec7b94f8b24" +content-hash = "978a8ed3c6f4f4e46d39b8c33affb767a91275ee2bee532a48a7abc3d224deb8" diff --git a/pyproject.toml b/pyproject.toml index 10e4950..d347fee 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,7 +35,7 @@ numpy = [ { version = "^1.26.2", optional = true, python = ">=3.12" }, ] pyarrow = { version = ">=14", optional = true } -rich = { version = "^13", optional = true } +rich = { version = ">=12, <14", optional = true } toml = { version = "^0.10", optional = true } typer = { version = "^0.12.3", optional = true } pytest = { version = "*", optional = true } From 0ad164d3441139bc298255a4a0600d6283ab86af Mon Sep 17 00:00:00 2001 From: wvandeun Date: Sat, 7 Jun 2025 01:08:39 +0200 Subject: [PATCH 5/5] add pytest plugin python-transform-unit-process test --- tests/unit/pytest_plugin/test_plugin.py | 58 +++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/tests/unit/pytest_plugin/test_plugin.py b/tests/unit/pytest_plugin/test_plugin.py index 5d33682..8d4b7b7 100644 --- a/tests/unit/pytest_plugin/test_plugin.py +++ b/tests/unit/pytest_plugin/test_plugin.py @@ -231,3 +231,61 @@ def test_jinja2_transform_unexpected_output(pytester): result = pytester.runpytest("--infrahub-repo-config=infrahub_config.yml") result.assert_outcomes(failed=1) + + +def test_python_transform(pytester): + pytester.makefile( + ".yml", + test_python_transform=""" + --- + version: "1.0" + infrahub_tests: + - resource: "PythonTransform" + resource_name: "device_config" + tests: + - name: "base_config" + expect: PASS + spec: + kind: "python-transform-unit-process" + directory: device_config/base_config + """, + ) + pytester.makefile( + ".yml", + infrahub_config=""" + --- + schemas: + - schemas/dcim.yml + + python_transforms: + - name: device_config + class_name: "DeviceConfig" + file_path: "transforms/device_config.py" + """, + ) + test_input = pytester.makefile( + ".json", input='{"data": { "InfraDevice": { "edges": [ { "node": { "name": {"value": "atl1-edge1"} } } ] } } }' + ) + test_output = pytester.makefile(".json", output='{"hostname": "atl1-edge1"}') + test_template = pytester.makefile( + ".py", + device_config=""" + from infrahub_sdk.transforms import InfrahubTransform + + class DeviceConfig(InfrahubTransform): + query = "device_config" + async def transform(self, data): + return {"hostname": data["InfraDevice"]["edges"][0]["node"]["name"]["value"]} + """, + ) + + pytester.mkdir("device_config") + test_dir = pytester.mkdir("device_config/base_config") + pytester.run("mv", test_input, test_dir) + pytester.run("mv", test_output, test_dir) + + transform_dir = pytester.mkdir("transforms") + pytester.run("mv", test_template, transform_dir) + + result = pytester.runpytest("--infrahub-repo-config=infrahub_config.yml") + result.assert_outcomes(passed=1)