You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Add 'schema_hash' parameter to client.schema.all to only optionally refresh the schema if the provided hash differs from what the client has already cached. ([#152](https://github.com/opsmill/infrahub-sdk-python/issues/152))
19
+
20
+
### Changed
21
+
22
+
- CoreStandardGroups created or updated by a generator in Infrahub are now stored as a member of the CoreGeneratorGroup. Previously they were being stored as children of the CoreGeneratorGroup.
23
+
24
+
### Fixed
25
+
26
+
- The SDK client query methods (get, filters, all) default behaviour has changed. The query methods will store the retrieved nodes in the internal store by default, where previously this behaviour had to be enabled explicitly using the `populate_store` argument. ([#15](https://github.com/opsmill/infrahub-sdk-python/issues/15))
Copy file name to clipboardExpand all lines: docs/docs/python-sdk/guides/store.mdx
+31-13Lines changed: 31 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,21 +14,39 @@ The store can also be used to store Nodes that we retrieve using the client quer
14
14
15
15
## Storing nodes in the store
16
16
17
-
Nodes retrieved from Infrahub using a query method, will be stored in the internal store when you set the `populate_store` argument to `True`.
18
-
Nodes stored in the store using this method can be retrieved using their `id` as the key in the store.
17
+
Nodes retrieved from Infrahub using a the SDK client's query methods, such as the `get``filters` or `all` method, will be automatically stored in the internal store. Nodes stored in the store using this method can be retrieved using their `id` as the key in the store.
19
18
20
19
<TabsgroupId="async-sync">
21
20
<TabItemvalue="Async"default>
22
21
23
22
```python
24
-
tag =await client.get(kind="BuiltinTag", name__value="RED", populate_store=True)
23
+
tag =await client.get(kind="BuiltinTag", name__value="RED")
24
+
```
25
+
26
+
</TabItem>
27
+
<TabItemvalue="Sync"default>
28
+
29
+
```python
30
+
tag = client.get(kind="BuiltinTag", name__value="RED")
31
+
```
32
+
33
+
</TabItem>
34
+
</Tabs>
35
+
36
+
This behaviour may not be desirable in all scenarios, therefor you can explicitly disable this behaviour by setting the `populate_store` argument to `False` when calling the query methods.
37
+
38
+
<TabsgroupId="async-sync">
39
+
<TabItemvalue="Async"default>
40
+
41
+
```python
42
+
tag =await client.get(kind="BuiltinTag", name__value="RED", populate_store=False)
25
43
```
26
44
27
45
</TabItem>
28
46
<TabItemvalue="Sync"default>
29
47
30
48
```python
31
-
tag = client.get(kind="BuiltinTag", name__value="RED", populate_store=True)
49
+
tag = client.get(kind="BuiltinTag", name__value="RED", populate_store=False)
32
50
```
33
51
34
52
</TabItem>
@@ -42,15 +60,15 @@ You can store nodes in the object store manually using the `set` method. This ha
42
60
<TabItemvalue="Async"default>
43
61
44
62
```python
45
-
tag =await client.get(kind="BuiltinTag", name__value="RED")
63
+
tag =await client.get(kind="BuiltinTag", name__value="RED", populate_store=False)
46
64
client.store.set(key=tag.name.value, node=tag)
47
65
```
48
66
49
67
</TabItem>
50
68
<TabItemvalue="Sync"default>
51
69
52
70
```python
53
-
tag = client.get(kind="BuiltinTag", name__value="RED")
71
+
tag = client.get(kind="BuiltinTag", name__value="RED", populate_store=False)
54
72
client.store.set(key=tag.name.value, node=tag)
55
73
```
56
74
@@ -60,13 +78,13 @@ You can store nodes in the object store manually using the `set` method. This ha
60
78
## Retrieving object from the store
61
79
62
80
Nodes can be retrieved from the internal store using the key that was used to store them.
63
-
For nodes that are stored using the `populate_store` argument on a query method, this will be their `id`.
81
+
For nodes that are stored by the client's query methods, this will be their `id`.
64
82
65
83
<TabsgroupId="async-sync">
66
84
<TabItemvalue="Async"default>
67
85
68
86
```python
69
-
tag =await client.get(kind="BuiltinTag", name__value="RED", populate_store=True)
87
+
tag =await client.get(kind="BuiltinTag", name__value="RED")
70
88
tag_in_store = client.store.get(key=tag.id)
71
89
assert tag == tag_in_store
72
90
```
@@ -75,7 +93,7 @@ For nodes that are stored using the `populate_store` argument on a query method,
75
93
<TabItemvalue="Sync"default>
76
94
77
95
```python
78
-
tag = client.get(kind="BuiltinTag", name__value="RED", populate_store=True)
96
+
tag = client.get(kind="BuiltinTag", name__value="RED")
79
97
tag_in_store = client.store.get(key=tag.id)
80
98
assert tag == tag_in_store
81
99
```
@@ -89,7 +107,7 @@ For nodes that have been added manually to the store, this will be the key that
89
107
<TabItemvalue="Async"default>
90
108
91
109
```python
92
-
tag =await client.get(kind="BuiltinTag", name__value="RED")
110
+
tag =await client.get(kind="BuiltinTag", name__value="RED", populate_store=False)
0 commit comments