synaops 0.2.0__tar.gz → 0.2.2__tar.gz

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.
Files changed (26) hide show
  1. {synaops-0.2.0 → synaops-0.2.2}/.github/workflows/ci.yml +13 -4
  2. {synaops-0.2.0 → synaops-0.2.2}/.github/workflows/release.yml +6 -6
  3. {synaops-0.2.0 → synaops-0.2.2}/Cargo.lock +15 -23
  4. {synaops-0.2.0 → synaops-0.2.2}/Cargo.toml +3 -3
  5. {synaops-0.2.0 → synaops-0.2.2}/PKG-INFO +2 -1
  6. {synaops-0.2.0 → synaops-0.2.2}/bench/test_parity.py +34 -0
  7. {synaops-0.2.0 → synaops-0.2.2}/pyproject.toml +2 -1
  8. {synaops-0.2.0 → synaops-0.2.2}/src/json_schema_utils.rs +5 -0
  9. {synaops-0.2.0 → synaops-0.2.2}/src/json_utils.rs +18 -4
  10. {synaops-0.2.0 → synaops-0.2.2}/src/json_utils_test.rs +20 -2
  11. {synaops-0.2.0 → synaops-0.2.2}/.cargo/config.toml +0 -0
  12. {synaops-0.2.0 → synaops-0.2.2}/.gitignore +0 -0
  13. {synaops-0.2.0 → synaops-0.2.2}/LICENSE +0 -0
  14. {synaops-0.2.0 → synaops-0.2.2}/README.md +0 -0
  15. {synaops-0.2.0 → synaops-0.2.2}/bench/README.md +0 -0
  16. {synaops-0.2.0 → synaops-0.2.2}/bench/before_after.png +0 -0
  17. {synaops-0.2.0 → synaops-0.2.2}/bench/conftest.py +0 -0
  18. {synaops-0.2.0 → synaops-0.2.2}/bench/plot.py +0 -0
  19. {synaops-0.2.0 → synaops-0.2.2}/bench/requirements.txt +0 -0
  20. {synaops-0.2.0 → synaops-0.2.2}/bench/speedup.png +0 -0
  21. {synaops-0.2.0 → synaops-0.2.2}/bench/test_bench.py +0 -0
  22. {synaops-0.2.0 → synaops-0.2.2}/src/json_schema_utils_test.rs +0 -0
  23. {synaops-0.2.0 → synaops-0.2.2}/src/lib.rs +0 -0
  24. {synaops-0.2.0 → synaops-0.2.2}/src/nlp_utils.rs +0 -0
  25. {synaops-0.2.0 → synaops-0.2.2}/src/nlp_utils_test.rs +0 -0
  26. {synaops-0.2.0 → synaops-0.2.2}/src/regex_cache.rs +0 -0
@@ -12,7 +12,7 @@ jobs:
12
12
  strategy:
13
13
  fail-fast: false
14
14
  matrix:
15
- python-version: ["3.10", "3.11", "3.12", "3.13"]
15
+ python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
16
16
 
17
17
  steps:
18
18
  - uses: actions/checkout@v5
@@ -32,11 +32,20 @@ jobs:
32
32
  run: |
33
33
  python -m pip install --upgrade pip
34
34
  pip install pytest pytest-benchmark
35
- pip install git+https://github.com/SynaLinks/synalinks.git
36
35
  pip install .
37
36
 
38
37
  - name: Parity tests
39
- run: pytest bench/test_parity.py -v
38
+ # Parity pulls in synalinks -> litellm. synaops itself supports the
39
+ # whole 3.10-3.14 matrix (built/imported above), but the reference
40
+ # stack constrains where the parity suite can run:
41
+ # - synalinks requires Python >=3.12 (excludes 3.10, 3.11)
42
+ # - litellm declares Requires-Python <3.14 (excludes 3.14)
43
+ # so the parity suite runs on 3.12-3.13. Revisit the 3.14 skip once
44
+ # litellm raises its upper Python bound.
45
+ if: matrix.python-version == '3.12' || matrix.python-version == '3.13'
46
+ run: |
47
+ pip install git+https://github.com/SynaLinks/synalinks.git
48
+ pytest bench/test_parity.py -v
40
49
 
41
50
  test-cross:
42
51
  name: smoke ${{ matrix.os }} / py${{ matrix.python-version }}
@@ -45,7 +54,7 @@ jobs:
45
54
  fail-fast: false
46
55
  matrix:
47
56
  os: [macos-latest, windows-latest]
48
- python-version: ["3.10", "3.13"]
57
+ python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
49
58
 
50
59
  steps:
51
60
  - uses: actions/checkout@v5
@@ -40,7 +40,7 @@ jobs:
40
40
  target: ${{ matrix.target }}
41
41
  args: --release --out dist
42
42
  manylinux: auto
43
- - uses: actions/upload-artifact@v5
43
+ - uses: actions/upload-artifact@v7
44
44
  with:
45
45
  name: wheels-manylinux-${{ matrix.target }}
46
46
  path: dist
@@ -62,7 +62,7 @@ jobs:
62
62
  target: ${{ matrix.target }}
63
63
  args: --release --out dist
64
64
  manylinux: musllinux_1_2
65
- - uses: actions/upload-artifact@v5
65
+ - uses: actions/upload-artifact@v7
66
66
  with:
67
67
  name: wheels-musllinux-${{ matrix.target }}
68
68
  path: dist
@@ -83,7 +83,7 @@ jobs:
83
83
  with:
84
84
  target: ${{ matrix.target }}
85
85
  args: --release --out dist
86
- - uses: actions/upload-artifact@v5
86
+ - uses: actions/upload-artifact@v7
87
87
  with:
88
88
  name: wheels-macos-${{ matrix.target }}
89
89
  path: dist
@@ -105,7 +105,7 @@ jobs:
105
105
  with:
106
106
  target: ${{ matrix.target }}
107
107
  args: --release --out dist
108
- - uses: actions/upload-artifact@v5
108
+ - uses: actions/upload-artifact@v7
109
109
  with:
110
110
  name: wheels-windows-${{ matrix.target }}
111
111
  path: dist
@@ -119,7 +119,7 @@ jobs:
119
119
  with:
120
120
  command: sdist
121
121
  args: --out dist
122
- - uses: actions/upload-artifact@v5
122
+ - uses: actions/upload-artifact@v7
123
123
  with:
124
124
  name: wheels-sdist
125
125
  path: dist
@@ -133,7 +133,7 @@ jobs:
133
133
  name: pypi
134
134
  url: https://pypi.org/p/synaops
135
135
  steps:
136
- - uses: actions/download-artifact@v5
136
+ - uses: actions/download-artifact@v8
137
137
  with:
138
138
  pattern: wheels-*
139
139
  path: dist
@@ -17,12 +17,6 @@ version = "1.5.0"
17
17
  source = "registry+https://github.com/rust-lang/crates.io-index"
18
18
  checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
19
19
 
20
- [[package]]
21
- name = "cfg-if"
22
- version = "1.0.4"
23
- source = "registry+https://github.com/rust-lang/crates.io-index"
24
- checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
25
-
26
20
  [[package]]
27
21
  name = "equivalent"
28
22
  version = "1.0.2"
@@ -110,11 +104,10 @@ dependencies = [
110
104
 
111
105
  [[package]]
112
106
  name = "pyo3"
113
- version = "0.22.6"
107
+ version = "0.26.0"
114
108
  source = "registry+https://github.com/rust-lang/crates.io-index"
115
- checksum = "f402062616ab18202ae8319da13fa4279883a2b8a9d9f83f20dbade813ce1884"
109
+ checksum = "7ba0117f4212101ee6544044dae45abe1083d30ce7b29c4b5cbdfa2354e07383"
116
110
  dependencies = [
117
- "cfg-if",
118
111
  "indoc",
119
112
  "libc",
120
113
  "memoffset",
@@ -128,19 +121,18 @@ dependencies = [
128
121
 
129
122
  [[package]]
130
123
  name = "pyo3-build-config"
131
- version = "0.22.6"
124
+ version = "0.26.0"
132
125
  source = "registry+https://github.com/rust-lang/crates.io-index"
133
- checksum = "b14b5775b5ff446dd1056212d778012cbe8a0fbffd368029fd9e25b514479c38"
126
+ checksum = "4fc6ddaf24947d12a9aa31ac65431fb1b851b8f4365426e182901eabfb87df5f"
134
127
  dependencies = [
135
- "once_cell",
136
128
  "target-lexicon",
137
129
  ]
138
130
 
139
131
  [[package]]
140
132
  name = "pyo3-ffi"
141
- version = "0.22.6"
133
+ version = "0.26.0"
142
134
  source = "registry+https://github.com/rust-lang/crates.io-index"
143
- checksum = "9ab5bcf04a2cdcbb50c7d6105de943f543f9ed92af55818fd17b660390fc8636"
135
+ checksum = "025474d3928738efb38ac36d4744a74a400c901c7596199e20e45d98eb194105"
144
136
  dependencies = [
145
137
  "libc",
146
138
  "pyo3-build-config",
@@ -148,9 +140,9 @@ dependencies = [
148
140
 
149
141
  [[package]]
150
142
  name = "pyo3-macros"
151
- version = "0.22.6"
143
+ version = "0.26.0"
152
144
  source = "registry+https://github.com/rust-lang/crates.io-index"
153
- checksum = "0fd24d897903a9e6d80b968368a34e1525aeb719d568dba8b3d4bfa5dc67d453"
145
+ checksum = "2e64eb489f22fe1c95911b77c44cc41e7c19f3082fc81cce90f657cdc42ffded"
154
146
  dependencies = [
155
147
  "proc-macro2",
156
148
  "pyo3-macros-backend",
@@ -160,9 +152,9 @@ dependencies = [
160
152
 
161
153
  [[package]]
162
154
  name = "pyo3-macros-backend"
163
- version = "0.22.6"
155
+ version = "0.26.0"
164
156
  source = "registry+https://github.com/rust-lang/crates.io-index"
165
- checksum = "36c011a03ba1e50152b4b394b479826cad97e7a21eb52df179cd91ac411cbfbe"
157
+ checksum = "100246c0ecf400b475341b8455a9213344569af29a3c841d29270e53102e0fcf"
166
158
  dependencies = [
167
159
  "heck",
168
160
  "proc-macro2",
@@ -173,9 +165,9 @@ dependencies = [
173
165
 
174
166
  [[package]]
175
167
  name = "pythonize"
176
- version = "0.22.0"
168
+ version = "0.26.0"
177
169
  source = "registry+https://github.com/rust-lang/crates.io-index"
178
- checksum = "90fcf491425978bd889015d5430f6473d91bdfa2097262f1e731aadcf6c2113e"
170
+ checksum = "11e06e4cff9be2bbf2bddf28a486ae619172ea57e79787f856572878c62dcfe2"
179
171
  dependencies = [
180
172
  "pyo3",
181
173
  "serde",
@@ -281,7 +273,7 @@ dependencies = [
281
273
 
282
274
  [[package]]
283
275
  name = "synaops"
284
- version = "0.2.0"
276
+ version = "0.2.2"
285
277
  dependencies = [
286
278
  "pyo3",
287
279
  "pythonize",
@@ -291,9 +283,9 @@ dependencies = [
291
283
 
292
284
  [[package]]
293
285
  name = "target-lexicon"
294
- version = "0.12.16"
286
+ version = "0.13.5"
295
287
  source = "registry+https://github.com/rust-lang/crates.io-index"
296
- checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
288
+ checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
297
289
 
298
290
  [[package]]
299
291
  name = "unicode-ident"
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "synaops"
3
- version = "0.2.0"
3
+ version = "0.2.2"
4
4
  edition = "2021"
5
5
  license = "Apache-2.0"
6
6
  description = "Native Rust implementations of synalinks JSON/schema operations."
@@ -11,7 +11,7 @@ name = "synaops"
11
11
  crate-type = ["cdylib", "rlib"]
12
12
 
13
13
  [dependencies]
14
- pyo3 = { version = "0.22", features = ["extension-module", "abi3-py310"] }
15
- pythonize = "0.22"
14
+ pyo3 = { version = "0.26", features = ["extension-module", "abi3-py310"] }
15
+ pythonize = "0.26"
16
16
  serde_json = { version = "1", features = ["preserve_order"] }
17
17
  regex = "1"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: synaops
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Classifier: Operating System :: OS Independent
5
5
  Classifier: Programming Language :: Rust
6
6
  Classifier: Programming Language :: Python
@@ -9,6 +9,7 @@ Classifier: Programming Language :: Python :: 3.10
9
9
  Classifier: Programming Language :: Python :: 3.11
10
10
  Classifier: Programming Language :: Python :: 3.12
11
11
  Classifier: Programming Language :: Python :: 3.13
12
+ Classifier: Programming Language :: Python :: 3.14
12
13
  Classifier: Programming Language :: Python :: Implementation :: CPython
13
14
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
14
15
  License-File: LICENSE
@@ -36,3 +36,37 @@ def test_schema_parity(op, size_name, schema_payload_by_size):
36
36
  py_out = call(getattr(py_sch, f"_py_{base}"), payload)
37
37
  rs_out = call(getattr(rs, base), payload)
38
38
  assert py_out == rs_out, f"{op_name}[{size_name}]: py != rs"
39
+
40
+
41
+ SCHEMA_STR = {"type": "string"}
42
+ SCHEMA_STRS = {"type": "array", "items": {"type": "string"}}
43
+ PLURAL_CASES = {
44
+ "plural_only": ({"answers": ["a", "b"]}, {"answers": SCHEMA_STRS}),
45
+ "plural_and_other": (
46
+ {"query": "q", "answers": ["a"]},
47
+ {"query": SCHEMA_STR, "answers": SCHEMA_STRS},
48
+ ),
49
+ "singular_then_plural": (
50
+ {"answer": "x", "answers": ["y"]},
51
+ {"answer": SCHEMA_STR, "answers": SCHEMA_STRS},
52
+ ),
53
+ "plural_then_singular": (
54
+ {"answers": ["y"], "answer": "x"},
55
+ {"answers": SCHEMA_STRS, "answer": SCHEMA_STR},
56
+ ),
57
+ }
58
+
59
+
60
+ @pytest.mark.parametrize("case", list(PLURAL_CASES))
61
+ def test_factorize_plural_parity(case):
62
+ # SynaLinks/synalinks#200: plural keys dropped, singular+plural lost data.
63
+ from synalinks.src.backend.common import json_schema_utils as py_sch
64
+ from synalinks.src.backend.common import json_utils as py_json
65
+ import synaops as rs
66
+
67
+ data, props = PLURAL_CASES[case]
68
+ schema = {"title": "T", "type": "object", "properties": props, "required": list(props)}
69
+ assert rs.factorize_json(data) == py_json._py_factorize_json(dict(data))
70
+ assert rs.factorize_schema(schema) == py_sch._py_factorize_schema(
71
+ {**schema, "properties": dict(props)}
72
+ )
@@ -4,7 +4,7 @@ build-backend = "maturin"
4
4
 
5
5
  [project]
6
6
  name = "synaops"
7
- version = "0.2.0"
7
+ version = "0.2.2"
8
8
  description = "Native Rust implementations of synalinks JSON/schema operations."
9
9
  readme = "README.md"
10
10
  license = "Apache-2.0"
@@ -20,6 +20,7 @@ classifiers = [
20
20
  "Programming Language :: Python :: 3.11",
21
21
  "Programming Language :: Python :: 3.12",
22
22
  "Programming Language :: Python :: 3.13",
23
+ "Programming Language :: Python :: 3.14",
23
24
  "Programming Language :: Python :: Implementation :: CPython",
24
25
  "Topic :: Software Development :: Libraries :: Python Modules",
25
26
  ]
@@ -370,6 +370,11 @@ pub fn factorize_schema(mut schema: Value) -> Value {
370
370
  let prop_value = std::mem::take(&mut prop_entries[i].1);
371
371
  out_required.push(Value::String(base_key.clone()));
372
372
  out_props.insert(base_key.clone(), prop_value);
373
+ } else if is_plural_key && !has_siblings {
374
+ // A plural with siblings is covered by the array grouped from them.
375
+ let (key, prop_value) = std::mem::take(&mut prop_entries[i]);
376
+ out_required.push(Value::String(key.clone()));
377
+ out_props.insert(key, prop_value);
373
378
  }
374
379
  }
375
380
 
@@ -131,6 +131,11 @@ pub fn factorize_json(json: Value) -> Value {
131
131
  }
132
132
  } else if !is_plural_key {
133
133
  result.insert(base_key.clone(), prop_value);
134
+ } else if let (Some(Value::Array(arr)), Value::Array(items)) =
135
+ (result.get_mut(&prop_key), &prop_value)
136
+ {
137
+ // Extend a list already grouped from its singular siblings.
138
+ arr.extend(items.iter().cloned());
134
139
  } else {
135
140
  result.insert(prop_key, prop_value);
136
141
  }
@@ -260,10 +265,19 @@ fn in_mask_value(
260
265
  }
261
266
  }
262
267
  Value::Array(_) => {
263
- result.insert(
264
- key.clone(),
265
- in_mask_value(val, mask, pattern, true),
266
- );
268
+ // Like objects, an array is kept only when its key
269
+ // matches the mask/pattern; when kept, its items
270
+ // are masked recursively. Force-keeping arrays made
271
+ // the value masker disagree with the schema masker
272
+ // (which drops unmatched arrays), leaving stray list
273
+ // fields on the output and breaking, e.g., ExactMatch
274
+ // field comparisons.
275
+ if keep {
276
+ result.insert(
277
+ key.clone(),
278
+ in_mask_value(val, mask, pattern, true),
279
+ );
280
+ }
267
281
  }
268
282
  _ => {
269
283
  if keep {
@@ -414,7 +414,25 @@ fn test_in_mask_deeply_nested() {
414
414
  }
415
415
 
416
416
  #[test]
417
- fn test_in_mask_in_array() {
417
+ fn test_in_mask_in_array_drops_unmatched_array() {
418
+ // An array whose key is not in the mask is dropped, like an unmatched
419
+ // object, keeping the value masker consistent with the schema masker.
420
+ let json = v(json!({
421
+ "items": [
422
+ {"foo": "test", "bar": "test"},
423
+ {"foo_1": "test", "bar_1": "test"}
424
+ ]
425
+ }));
426
+ let expected = v(json!({}));
427
+
428
+ let result = in_mask_json(&json, Some(&["foo"]), true);
429
+ assert_eq!(result, expected);
430
+ }
431
+
432
+ #[test]
433
+ fn test_in_mask_keeps_matched_array_and_masks_items() {
434
+ // When the array key matches the mask, the array is kept and its items
435
+ // are masked recursively.
418
436
  let json = v(json!({
419
437
  "items": [
420
438
  {"foo": "test", "bar": "test"},
@@ -428,7 +446,7 @@ fn test_in_mask_in_array() {
428
446
  ]
429
447
  }));
430
448
 
431
- let result = in_mask_json(&json, Some(&["foo"]), true);
449
+ let result = in_mask_json(&json, Some(&["item", "foo"]), true);
432
450
  assert_eq!(result, expected);
433
451
  }
434
452
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes