From 72b1e6170fe0ba2eec9d59c4cdd866aeb343f15f Mon Sep 17 00:00:00 2001 From: Baptiste Date: Wed, 16 Apr 2025 10:30:12 +0200 Subject: [PATCH 1/2] Add known issue --- docs/_templates/sdk_template_reference.j2 | 12 ++++++++++++ docs/docs/python-sdk/reference/templating.mdx | 14 +++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/docs/_templates/sdk_template_reference.j2 b/docs/_templates/sdk_template_reference.j2 index dcd59d78..7b7148db 100644 --- a/docs/_templates/sdk_template_reference.j2 +++ b/docs/_templates/sdk_template_reference.j2 @@ -25,3 +25,15 @@ The following Jinja2 filters from Netu | {{ filter.name }} | {% if filter.trusted %}✅{% else %}❌{% endif %} | {% endfor %} + +## Known issues + +### Unable to combine the map and sort filters (https://github.com/pallets/jinja/issues/2081) + +When using the `map` filter with the `sort` filter, you may encounter the following error: + +```python +TypeError: 'async_generator' object is not iterable +``` + +**As a workaround you can use the `list` filter between `map` and `sort` filter.** diff --git a/docs/docs/python-sdk/reference/templating.mdx b/docs/docs/python-sdk/reference/templating.mdx index 62f1b8aa..043d8dcc 100644 --- a/docs/docs/python-sdk/reference/templating.mdx +++ b/docs/docs/python-sdk/reference/templating.mdx @@ -150,4 +150,16 @@ The following Jinja2 filters from Netu | vlanconfig_to_list | ✅ | | vlanlist_to_config | ✅ | | wildcardmask_to_netmask | ✅ | - \ No newline at end of file + + +## Known issues + +### Unable to combine the map and sort filters (https://github.com/pallets/jinja/issues/2081) + +When using the `map` filter with the `sort` filter, you may encounter the following error: + +```python +TypeError: 'async_generator' object is not iterable +``` + +**As a workaround you can use the `list` filter between `map` and `sort` filter.** \ No newline at end of file From 54d00e5cb3a923e99cc0f0985358a9d515dcf3f6 Mon Sep 17 00:00:00 2001 From: wvandeun Date: Wed, 16 Apr 2025 14:59:11 +0200 Subject: [PATCH 2/2] docs: fix create update delete nodes guide --- docs/docs/python-sdk/guides/create_update_delete.mdx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/docs/python-sdk/guides/create_update_delete.mdx b/docs/docs/python-sdk/guides/create_update_delete.mdx index 8d90edf6..212b0e8e 100644 --- a/docs/docs/python-sdk/guides/create_update_delete.mdx +++ b/docs/docs/python-sdk/guides/create_update_delete.mdx @@ -67,7 +67,7 @@ nodes: A node can be created using the `create` method. The `create` method will first construct a `InfrahubNode` object in memory. This `InfrahubNode` object will then need to be saved into Infrahub using the `save` method. -The attributes and relationships of the `InfrahubNode` you want to create can be passed as arguments to the `create` method, or you can pass then using a dictionary. +The attributes and relationships of the `InfrahubNode` you want to create can be passed as arguments to the `create` method, or you can pass them using a dictionary. @@ -138,7 +138,7 @@ The attributes and relationships of the `InfrahubNode` you want to create can be ```python - interfaces = await client.get(kind="TestInterface", name__values=["Ethernet1", "Ethernet2"]) + interfaces = await client.filters(kind="TestInterface", name__values=["Ethernet1", "Ethernet2"]) device = await client.create(kind="TestDevice", name="atl1-edge1", interfaces=interfaces) await device.save() ``` @@ -147,7 +147,7 @@ The attributes and relationships of the `InfrahubNode` you want to create can be ```python - interfaces = client.get(kind="TestInterface", name__values=["Ethernet1", "Ethernet2"]) + interfaces = client.filters(kind="TestInterface", name__values=["Ethernet1", "Ethernet2"]) device = client.create(kind="TestDevice", name="atl1-edge1", interfaces=interfaces) device.save() ``` @@ -222,7 +222,7 @@ Adding a single relation: ```python - interface = client.get(kind="TestInterface", name__values="Ethernet1") + interface = client.get(kind="TestInterface", name__value="Ethernet1") device = client.get(kind="TestDevice", name__value="atl1-edge1") device.interfaces.add(interface) device.save() @@ -236,7 +236,7 @@ Adding multiple relations: ```python - interfaces = await client.filters(kind="TestInterface", name__value=["Ethernet1", "Ethernet2"]) + interfaces = await client.filters(kind="TestInterface", name__values=["Ethernet1", "Ethernet2"]) device = await client.get(kind="TestDevice", name__value="atl1-edge1") device.interfaces.extend(interfaces) await device.save() @@ -246,7 +246,7 @@ Adding multiple relations: ```python - interfaces = client.filters(kind="TestInterface", name__value=["Ethernet1", "Ethernet2"]) + interfaces = client.filters(kind="TestInterface", name__values=["Ethernet1", "Ethernet2"]) device = client.get(kind="TestDevice", name__value="atl1-edge1") device.interfaces.extend(interfaces) device.save()