synaops 0.2.1__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.1 → synaops-0.2.2}/.github/workflows/ci.yml +11 -2
  2. {synaops-0.2.1 → synaops-0.2.2}/.github/workflows/release.yml +6 -6
  3. {synaops-0.2.1 → synaops-0.2.2}/Cargo.lock +1 -1
  4. {synaops-0.2.1 → synaops-0.2.2}/Cargo.toml +1 -1
  5. {synaops-0.2.1 → synaops-0.2.2}/PKG-INFO +1 -1
  6. {synaops-0.2.1 → synaops-0.2.2}/bench/test_parity.py +34 -0
  7. {synaops-0.2.1 → synaops-0.2.2}/pyproject.toml +1 -1
  8. {synaops-0.2.1 → synaops-0.2.2}/src/json_schema_utils.rs +5 -0
  9. {synaops-0.2.1 → synaops-0.2.2}/src/json_utils.rs +5 -0
  10. {synaops-0.2.1 → synaops-0.2.2}/.cargo/config.toml +0 -0
  11. {synaops-0.2.1 → synaops-0.2.2}/.gitignore +0 -0
  12. {synaops-0.2.1 → synaops-0.2.2}/LICENSE +0 -0
  13. {synaops-0.2.1 → synaops-0.2.2}/README.md +0 -0
  14. {synaops-0.2.1 → synaops-0.2.2}/bench/README.md +0 -0
  15. {synaops-0.2.1 → synaops-0.2.2}/bench/before_after.png +0 -0
  16. {synaops-0.2.1 → synaops-0.2.2}/bench/conftest.py +0 -0
  17. {synaops-0.2.1 → synaops-0.2.2}/bench/plot.py +0 -0
  18. {synaops-0.2.1 → synaops-0.2.2}/bench/requirements.txt +0 -0
  19. {synaops-0.2.1 → synaops-0.2.2}/bench/speedup.png +0 -0
  20. {synaops-0.2.1 → synaops-0.2.2}/bench/test_bench.py +0 -0
  21. {synaops-0.2.1 → synaops-0.2.2}/src/json_schema_utils_test.rs +0 -0
  22. {synaops-0.2.1 → synaops-0.2.2}/src/json_utils_test.rs +0 -0
  23. {synaops-0.2.1 → synaops-0.2.2}/src/lib.rs +0 -0
  24. {synaops-0.2.1 → synaops-0.2.2}/src/nlp_utils.rs +0 -0
  25. {synaops-0.2.1 → synaops-0.2.2}/src/nlp_utils_test.rs +0 -0
  26. {synaops-0.2.1 → synaops-0.2.2}/src/regex_cache.rs +0 -0
@@ -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 }}
@@ -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
@@ -273,7 +273,7 @@ dependencies = [
273
273
 
274
274
  [[package]]
275
275
  name = "synaops"
276
- version = "0.2.1"
276
+ version = "0.2.2"
277
277
  dependencies = [
278
278
  "pyo3",
279
279
  "pythonize",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "synaops"
3
- version = "0.2.1"
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."
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: synaops
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Classifier: Operating System :: OS Independent
5
5
  Classifier: Programming Language :: Rust
6
6
  Classifier: Programming Language :: Python
@@ -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.1"
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"
@@ -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
  }
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
File without changes