pycarlo 0.11.15__py3-none-any.whl → 0.12.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pycarlo/features/metadata/metadata_filters_container.py +13 -9
- pycarlo/lib/README.md +34 -2
- pycarlo/lib/schema.json +2296 -28
- pycarlo/lib/schema.py +1373 -419
- pycarlo/lib/types.py +68 -0
- {pycarlo-0.11.15.dist-info → pycarlo-0.12.5.dist-info}/METADATA +52 -35
- {pycarlo-0.11.15.dist-info → pycarlo-0.12.5.dist-info}/RECORD +10 -9
- {pycarlo-0.11.15.dist-info → pycarlo-0.12.5.dist-info}/WHEEL +1 -1
- {pycarlo-0.11.15.dist-info → pycarlo-0.12.5.dist-info}/LICENSE +0 -0
- {pycarlo-0.11.15.dist-info → pycarlo-0.12.5.dist-info}/top_level.txt +0 -0
|
@@ -214,7 +214,7 @@ class MetadataFiltersContainer:
|
|
|
214
214
|
|
|
215
215
|
default_effect_conditions = default_effect_op.join(
|
|
216
216
|
[
|
|
217
|
-
|
|
217
|
+
self._get_sql_field_condition(f, column_mapping, encoder, force_lowercase)
|
|
218
218
|
for f in default_effect_filters
|
|
219
219
|
]
|
|
220
220
|
)
|
|
@@ -224,13 +224,15 @@ class MetadataFiltersContainer:
|
|
|
224
224
|
for f in other_effect_filters
|
|
225
225
|
]
|
|
226
226
|
)
|
|
227
|
-
|
|
228
|
-
if
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
227
|
+
|
|
228
|
+
if default_effect_conditions and other_effect_conditions:
|
|
229
|
+
return f"(({default_effect_conditions}){default_effect_op}({other_effect_conditions}))"
|
|
230
|
+
elif default_effect_conditions:
|
|
231
|
+
return f"({default_effect_conditions})"
|
|
232
|
+
elif other_effect_conditions:
|
|
233
|
+
return f"({other_effect_conditions})"
|
|
234
|
+
else:
|
|
235
|
+
return None
|
|
234
236
|
|
|
235
237
|
@staticmethod
|
|
236
238
|
def _get_sql_field_condition(
|
|
@@ -238,7 +240,7 @@ class MetadataFiltersContainer:
|
|
|
238
240
|
column_mapping: Dict,
|
|
239
241
|
encoder: Callable[[str, str, FilterType], str],
|
|
240
242
|
force_lowercase: Optional[bool] = True,
|
|
241
|
-
):
|
|
243
|
+
) -> str:
|
|
242
244
|
# The comparison is performed case-insensitive (check MetadataFilter._safe_match)
|
|
243
245
|
# We can use LOWER here since it is part of standard SQL (like AND/OR/NOT), so including it
|
|
244
246
|
# here is a way to make sure that all comparisons are case-insensitive in the SQL sentences
|
|
@@ -255,4 +257,6 @@ class MetadataFiltersContainer:
|
|
|
255
257
|
if getattr(mf, field) is not None
|
|
256
258
|
]
|
|
257
259
|
)
|
|
260
|
+
if not conditions:
|
|
261
|
+
return ""
|
|
258
262
|
return f"NOT({conditions})" if mf.effect == FilterEffectType.BLOCK else f"({conditions})"
|
pycarlo/lib/README.md
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
-
|
|
1
|
+
# Monte Carlo GraphQL Schema Library
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The `schema.json` and `schema.py` files are auto-generated. **Do not edit them directly**!
|
|
4
|
+
|
|
5
|
+
If you need to customize the schema, see below. Refer to the
|
|
6
|
+
[CONTRIBUTING.md](../../CONTRIBUTING.md) for general development guidelines.
|
|
7
|
+
|
|
8
|
+
## Schema Customizations
|
|
9
|
+
|
|
10
|
+
The generated `schema.py` is automatically modified during the build process to apply the following
|
|
11
|
+
customizations. This is done via `sed` commands in the [Makefile](../../Makefile), but if we need to
|
|
12
|
+
get fancier, we just can update the `customize-schema` target there to call whatever we need to do.
|
|
13
|
+
|
|
14
|
+
### Connection Type Fix
|
|
15
|
+
|
|
16
|
+
The `Connection` class is changed from `sgqlc.types.relay.Connection` to `sgqlc.types.Type`.
|
|
17
|
+
|
|
18
|
+
**Why:** sgqlc automatically makes all types ending in "Connection" inherit from `relay.Connection`,
|
|
19
|
+
which makes `Connection` not a valid field type. This causes requests to fail when attempting to
|
|
20
|
+
resolve it. Changing it to inherit from `sgqlc.types.Type` fixes this issue.
|
|
21
|
+
|
|
22
|
+
[Related PR](https://github.com/monte-carlo-data/python-sdk/pull/63)
|
|
23
|
+
|
|
24
|
+
### Backward-Compatible Enums
|
|
25
|
+
|
|
26
|
+
All GraphQL enum types use `pycarlo.lib.types.Enum` instead of `sgqlc.types.Enum`. This custom enum
|
|
27
|
+
class gracefully handles unknown enum values by returning them as strings instead of raising errors.
|
|
28
|
+
|
|
29
|
+
**Why:** When new enum values are added to the Monte Carlo API, older SDK versions would crash when
|
|
30
|
+
deserializing responses containing these new values. Our custom Enum prevents this by:
|
|
31
|
+
|
|
32
|
+
- Returning unknown values as plain strings (same type as known values)
|
|
33
|
+
- Logging a warning when unknown values are encountered
|
|
34
|
+
|
|
35
|
+
See [pycarlo/lib/types.py](types.py) for implementation details.
|