relata-sdk 2.6.2__tar.gz → 2.7.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.
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/PKG-INFO +1 -1
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/pyproject.toml +1 -1
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/client.py +18 -15
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/mcp.py +3 -1
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/objects.py +6 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_multimedia_and_flight.py +27 -17
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/.github/workflows/publish.yml +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/LICENSE +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/README.md +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/examples/a2a.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/examples/advanced_query.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/examples/analytics.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/examples/audit.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/examples/basic_query.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/examples/bitemporal.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/examples/ephemeral_server.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/examples/face_search.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/examples/governance.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/examples/graph_traversal.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/examples/graphql.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/examples/hybrid_search.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/examples/hybrid_search_quickstart.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/examples/hybrid_search_via_search.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/examples/ingest.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/examples/intelligence.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/examples/investigation.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/examples/jobs_workflows.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/examples/lookups.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/examples/memory_quickstart.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/examples/multi_search.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/examples/multi_tenant.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/examples/parameterized.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/examples/streaming.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/examples/tenant_admin.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/examples/tokens.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/__init__.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/_http.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/_version.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/a2a.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/aml.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/audit.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/backup.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/canonical.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/coref.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/embedding_migration.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/exceptions.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/flight.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/governance.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/grpc_query.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/identity.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/ingest.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/ipython.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/log.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/memory.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/models.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/namespace.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/query.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/rag.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/rag_answer.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/rag_loop.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/rag_rank.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/rag_trace.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/rag_understanding.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/s3.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/search.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/streaming.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/structural_navigation.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/synthesis.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/system.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/tenants.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/tokens.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata/vectors.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata_adapters/__init__.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata_adapters/_base.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata_adapters/ag2.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata_adapters/autogen.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata_adapters/crewai.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata_adapters/langchain.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata_adapters/llamaindex.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata_adapters/pydantic_ai.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata_adapters/registry.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata_adapters/smolagents.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/relata_langgraph/__init__.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/conftest_ephemeral.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/fixtures/canonical-vectors.json +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_adapters.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_admin_listener_split.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_agent_verbs_coverage.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_aml.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_async_memory.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_async_parity_2757.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_audit_export_cap.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_canonical.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_coref.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_embedding_migration.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_grpc_query.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_introspection_and_headers.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_langgraph_checkpointer.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_log_tokens_backup_stats.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_maritime.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_matcher_hint_1189.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_mcp_wrapper_arg_names.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_memory.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_memory_completion_and_query_cursor.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_namespace.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_object_get_delete.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_rag.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_rag_answer.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_rag_fanout.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_rag_loop.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_rag_rank.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_rag_trace.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_rag_understanding.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_response_cap_3214.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_s3_sigv4_3215.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_same_identity.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_schema_alter_action_verbs_4704.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_schema_branch.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_sdk_modules_wave.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_search.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_sql_injection_3211.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_streaming_tenants_safety.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_structural_navigation.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_synthesis.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_system_jobs_workflows.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_transport_and_adapters.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_typed_search.py +0 -0
- {relata_sdk-2.6.2 → relata_sdk-2.7.2}/tests/test_url_injection_3212.py +0 -0
|
@@ -160,31 +160,35 @@ def _face_search_sql(
|
|
|
160
160
|
k: int,
|
|
161
161
|
threshold: float,
|
|
162
162
|
) -> str:
|
|
163
|
-
"""Build a ``
|
|
163
|
+
"""Build a bare ``FACE_SEARCH(...)`` ticket (#2251, #5497).
|
|
164
164
|
|
|
165
165
|
Mirrors the server operator registered in
|
|
166
166
|
``relata_query::parser`` — ``FACE_SEARCH('<csv floats>', '<gallery>',
|
|
167
|
-
K => <n>, THRESHOLD => <f>)`` (defaults K=10, THRESHOLD=0.7).
|
|
167
|
+
K => <n>, THRESHOLD => <f>)`` (defaults K=10, THRESHOLD=0.7). The
|
|
168
|
+
engine dispatches this as a bare top-level statement only — wrapping
|
|
169
|
+
it in ``SELECT * FROM`` is a parse error (#5497, fixed in the TS SDK
|
|
170
|
+
by #5496).
|
|
168
171
|
"""
|
|
169
172
|
if isinstance(embedding, str):
|
|
170
173
|
emb_csv = embedding
|
|
171
174
|
else:
|
|
172
175
|
emb_csv = ",".join(repr(float(x)) for x in embedding)
|
|
173
176
|
return (
|
|
174
|
-
"
|
|
177
|
+
"FACE_SEARCH("
|
|
175
178
|
f"{_sql_literal(emb_csv)}, {_sql_literal(gallery_id)}, "
|
|
176
179
|
f"K => {int(k)}, THRESHOLD => {float(threshold)})"
|
|
177
180
|
)
|
|
178
181
|
|
|
179
182
|
|
|
180
183
|
def _match_pdq_sql(corpus_id: str, query_hash: str, *, threshold: float) -> str:
|
|
181
|
-
"""Build a ``
|
|
184
|
+
"""Build a bare ``MATCH_PDQ(...)`` ticket (#2251, #5497).
|
|
182
185
|
|
|
183
186
|
Mirrors ``MATCH_PDQ('<hash>', '<corpus>', THRESHOLD => <f>)``
|
|
184
|
-
(default THRESHOLD=0.9).
|
|
187
|
+
(default THRESHOLD=0.9). Bare top-level form only — see
|
|
188
|
+
``_face_search_sql``'s #5497 note.
|
|
185
189
|
"""
|
|
186
190
|
return (
|
|
187
|
-
"
|
|
191
|
+
"MATCH_PDQ("
|
|
188
192
|
f"{_sql_literal(query_hash)}, {_sql_literal(corpus_id)}, "
|
|
189
193
|
f"THRESHOLD => {float(threshold)})"
|
|
190
194
|
)
|
|
@@ -196,15 +200,16 @@ def _similar_image_sql(
|
|
|
196
200
|
threshold: float | None,
|
|
197
201
|
index: str | None,
|
|
198
202
|
) -> str:
|
|
199
|
-
"""Build a ``
|
|
203
|
+
"""Build a bare ``SIMILAR_IMAGE(...)`` ticket (#2840, PR #2859, #5497).
|
|
200
204
|
|
|
201
205
|
Mirrors the server operator registered in ``relata_query::parser``
|
|
202
206
|
(``SIMILAR_IMAGE('<media_ref>', THRESHOLD => <f>, INDEX => '<corpus>')``
|
|
203
207
|
— ``THRESHOLD`` defaults to 0.9 server-side when omitted, ``INDEX`` is
|
|
204
208
|
optional with no server default and scopes the search to a named
|
|
205
|
-
corpus/index when given).
|
|
209
|
+
corpus/index when given). Bare top-level form only — see
|
|
210
|
+
``_face_search_sql``'s #5497 note.
|
|
206
211
|
"""
|
|
207
|
-
sql = f"
|
|
212
|
+
sql = f"SIMILAR_IMAGE({_sql_literal(media_ref)}"
|
|
208
213
|
if threshold is not None:
|
|
209
214
|
sql += f", THRESHOLD => {float(threshold)}"
|
|
210
215
|
if index is not None:
|
|
@@ -1688,8 +1693,7 @@ class RelataClient:
|
|
|
1688
1693
|
) -> QueryResult:
|
|
1689
1694
|
"""Biometric face k-NN search against a gallery (#2251, ADR-030).
|
|
1690
1695
|
|
|
1691
|
-
Executes ``
|
|
1692
|
-
``/query`` door.
|
|
1696
|
+
Executes ``FACE_SEARCH(...)`` through the governed ``/query`` door.
|
|
1693
1697
|
|
|
1694
1698
|
Args:
|
|
1695
1699
|
gallery_id: Gallery to search (matches ``MediaEmbedding.gallery_id``).
|
|
@@ -1739,8 +1743,8 @@ class RelataClient:
|
|
|
1739
1743
|
) -> QueryResult:
|
|
1740
1744
|
"""Perceptual-hash (PDQ) near-duplicate search over a corpus (#2251).
|
|
1741
1745
|
|
|
1742
|
-
Executes ``
|
|
1743
|
-
|
|
1746
|
+
Executes ``MATCH_PDQ(...)`` through the governed ``/query`` door. PDQ
|
|
1747
|
+
near-duplicates differ by ≤ 31 bits (ADR-187).
|
|
1744
1748
|
|
|
1745
1749
|
Args:
|
|
1746
1750
|
corpus_id: Hash corpus to search (matches ``MediaHash.corpus_id``).
|
|
@@ -1778,8 +1782,7 @@ class RelataClient:
|
|
|
1778
1782
|
) -> QueryResult:
|
|
1779
1783
|
"""Near-duplicate / similar-image search (#2840, PR #2859).
|
|
1780
1784
|
|
|
1781
|
-
Executes ``
|
|
1782
|
-
``/query`` door.
|
|
1785
|
+
Executes ``SIMILAR_IMAGE(...)`` through the governed ``/query`` door.
|
|
1783
1786
|
|
|
1784
1787
|
Args:
|
|
1785
1788
|
media_ref: Reference media identifier to search from.
|
|
@@ -137,7 +137,9 @@ class McpClient:
|
|
|
137
137
|
|
|
138
138
|
#253: the registered schema declares ``entity_type`` (not ``object_type``)
|
|
139
139
|
and ``filters`` as a key-value object (not a ``filter`` string); sending
|
|
140
|
-
the old names 400'd before dispatch.
|
|
140
|
+
the old names 400'd before dispatch. Filters are pushed into the SQL
|
|
141
|
+
WHERE clause server-side before LIMIT (#5533): string values match
|
|
142
|
+
exactly but case-insensitively, numbers/booleans exactly.
|
|
141
143
|
"""
|
|
142
144
|
args: dict[str, Any] = {"entity_type": object_type, "limit": limit}
|
|
143
145
|
if filters:
|
|
@@ -98,6 +98,12 @@ class ObjectClient:
|
|
|
98
98
|
on_conflict: ``"upsert"`` (default) overwrites; ``"skip"`` ignores
|
|
99
99
|
existing rows; ``"error"`` raises on conflict (HTTP 409).
|
|
100
100
|
|
|
101
|
+
Schema rejections do NOT raise: a rejected row resolves normally with
|
|
102
|
+
``rows_rejected > 0`` and a populated ``errors`` list (e.g.
|
|
103
|
+
``{"rows_queued": 0, "rows_rejected": 1, "errors": ["Type.field:
|
|
104
|
+
minCount 1 not met"]}``). "No exception" does not mean "stored" —
|
|
105
|
+
always check ``rows_rejected`` / ``errors`` on the returned ack.
|
|
106
|
+
|
|
101
107
|
Durability contract (#4628): ``POST /ingest`` is **asynchronous** —
|
|
102
108
|
this does NOT return the server's upsert receipt (``object_id``,
|
|
103
109
|
``write_seq``, ``valid_from``); that description was wrong. It
|
|
@@ -42,10 +42,7 @@ def test_face_search_sql_from_list() -> None:
|
|
|
42
42
|
from relata.client import _face_search_sql
|
|
43
43
|
|
|
44
44
|
sql = _face_search_sql("gallery-1", [0.1, 0.2, 0.3], k=5, threshold=0.6)
|
|
45
|
-
assert sql == (
|
|
46
|
-
"SELECT * FROM FACE_SEARCH('0.1,0.2,0.3', 'gallery-1', "
|
|
47
|
-
"K => 5, THRESHOLD => 0.6)"
|
|
48
|
-
)
|
|
45
|
+
assert sql == "FACE_SEARCH('0.1,0.2,0.3', 'gallery-1', K => 5, THRESHOLD => 0.6)"
|
|
49
46
|
|
|
50
47
|
|
|
51
48
|
def test_face_search_sql_from_string() -> None:
|
|
@@ -55,11 +52,25 @@ def test_face_search_sql_from_string() -> None:
|
|
|
55
52
|
assert "FACE_SEARCH('1.0,0.0', 'g', K => 10, THRESHOLD => 0.7)" in sql
|
|
56
53
|
|
|
57
54
|
|
|
55
|
+
def test_multimedia_sql_never_wraps_operator_in_select_from() -> None:
|
|
56
|
+
"""#5497: the engine only parses the bare top-level OPERATOR(...) form.
|
|
57
|
+
|
|
58
|
+
A ``SELECT * FROM`` wrapper parses the operator name as a table
|
|
59
|
+
identifier and fails on the trailing ``(`` — every builder here must
|
|
60
|
+
emit the bare form (mirrors the TS SDK's #5496 regression test).
|
|
61
|
+
"""
|
|
62
|
+
from relata.client import _face_search_sql, _match_pdq_sql, _similar_image_sql
|
|
63
|
+
|
|
64
|
+
assert "SELECT" not in _face_search_sql("g", [0.1], k=10, threshold=0.7)
|
|
65
|
+
assert "SELECT" not in _match_pdq_sql("c", "ff", threshold=0.9)
|
|
66
|
+
assert "SELECT" not in _similar_image_sql("m", threshold=None, index=None)
|
|
67
|
+
|
|
68
|
+
|
|
58
69
|
def test_match_pdq_sql_shape() -> None:
|
|
59
70
|
from relata.client import _match_pdq_sql
|
|
60
71
|
|
|
61
72
|
sql = _match_pdq_sql("ncmec", "ffff", threshold=0.9)
|
|
62
|
-
assert sql == "
|
|
73
|
+
assert sql == "MATCH_PDQ('ffff', 'ncmec', THRESHOLD => 0.9)"
|
|
63
74
|
|
|
64
75
|
|
|
65
76
|
def test_multimedia_sql_quotes_single_quotes() -> None:
|
|
@@ -67,10 +78,10 @@ def test_multimedia_sql_quotes_single_quotes() -> None:
|
|
|
67
78
|
from relata.client import _face_search_sql, _match_pdq_sql
|
|
68
79
|
|
|
69
80
|
assert _face_search_sql("o'reilly", [0.1], k=1, threshold=0.5) == (
|
|
70
|
-
"
|
|
81
|
+
"FACE_SEARCH('0.1', 'o''reilly', K => 1, THRESHOLD => 0.5)"
|
|
71
82
|
)
|
|
72
83
|
assert _match_pdq_sql("o'reilly", "ff", threshold=0.5) == (
|
|
73
|
-
"
|
|
84
|
+
"MATCH_PDQ('ff', 'o''reilly', THRESHOLD => 0.5)"
|
|
74
85
|
)
|
|
75
86
|
|
|
76
87
|
|
|
@@ -79,7 +90,7 @@ def test_similar_image_sql_bare_form() -> None:
|
|
|
79
90
|
from relata.client import _similar_image_sql
|
|
80
91
|
|
|
81
92
|
sql = _similar_image_sql("media-42", threshold=None, index=None)
|
|
82
|
-
assert sql == "
|
|
93
|
+
assert sql == "SIMILAR_IMAGE('media-42')"
|
|
83
94
|
|
|
84
95
|
|
|
85
96
|
def test_similar_image_sql_with_threshold_and_index() -> None:
|
|
@@ -87,7 +98,7 @@ def test_similar_image_sql_with_threshold_and_index() -> None:
|
|
|
87
98
|
|
|
88
99
|
sql = _similar_image_sql("media-42", threshold=0.6, index="ncmec")
|
|
89
100
|
assert sql == (
|
|
90
|
-
"
|
|
101
|
+
"SIMILAR_IMAGE('media-42', THRESHOLD => 0.6, INDEX => 'ncmec')"
|
|
91
102
|
)
|
|
92
103
|
|
|
93
104
|
|
|
@@ -95,7 +106,7 @@ def test_similar_image_sql_threshold_only() -> None:
|
|
|
95
106
|
from relata.client import _similar_image_sql
|
|
96
107
|
|
|
97
108
|
sql = _similar_image_sql("media-42", threshold=0.6, index=None)
|
|
98
|
-
assert sql == "
|
|
109
|
+
assert sql == "SIMILAR_IMAGE('media-42', THRESHOLD => 0.6)"
|
|
99
110
|
|
|
100
111
|
|
|
101
112
|
def test_similar_image_sql_quotes_single_quotes() -> None:
|
|
@@ -103,7 +114,7 @@ def test_similar_image_sql_quotes_single_quotes() -> None:
|
|
|
103
114
|
|
|
104
115
|
sql = _similar_image_sql("o'reilly", threshold=0.5, index="o'index")
|
|
105
116
|
assert sql == (
|
|
106
|
-
"
|
|
117
|
+
"SIMILAR_IMAGE('o''reilly', THRESHOLD => 0.5, INDEX => 'o''index')"
|
|
107
118
|
)
|
|
108
119
|
|
|
109
120
|
|
|
@@ -130,7 +141,8 @@ def test_face_search_posts_face_search_operator() -> None:
|
|
|
130
141
|
|
|
131
142
|
client = _mocked_client(handler)
|
|
132
143
|
result = client.face_search("gallery-1", [0.1, 0.2], k=5, threshold=0.6)
|
|
133
|
-
assert "
|
|
144
|
+
assert "FACE_SEARCH(" in str(seen[0]["sql"])
|
|
145
|
+
assert "SELECT" not in str(seen[0]["sql"])
|
|
134
146
|
assert "K => 5" in str(seen[0]["sql"])
|
|
135
147
|
assert "THRESHOLD => 0.6" in str(seen[0]["sql"])
|
|
136
148
|
assert seen[0]["purpose"] == "analytics"
|
|
@@ -150,9 +162,7 @@ def test_match_pdq_posts_match_pdq_operator() -> None:
|
|
|
150
162
|
|
|
151
163
|
client = _mocked_client(handler)
|
|
152
164
|
result = client.match_pdq("ncmec", "ffff", threshold=0.95, purpose="investigation")
|
|
153
|
-
assert str(seen[0]["sql"]) == (
|
|
154
|
-
"SELECT * FROM MATCH_PDQ('ffff', 'ncmec', THRESHOLD => 0.95)"
|
|
155
|
-
)
|
|
165
|
+
assert str(seen[0]["sql"]) == "MATCH_PDQ('ffff', 'ncmec', THRESHOLD => 0.95)"
|
|
156
166
|
assert seen[0]["purpose"] == "investigation"
|
|
157
167
|
assert result.rows[0]["entity_id"] == "e-9"
|
|
158
168
|
|
|
@@ -174,7 +184,7 @@ def test_similar_image_posts_similar_image_operator() -> None:
|
|
|
174
184
|
"media-42", threshold=0.6, index="ncmec", purpose="investigation"
|
|
175
185
|
)
|
|
176
186
|
assert str(seen[0]["sql"]) == (
|
|
177
|
-
"
|
|
187
|
+
"SIMILAR_IMAGE('media-42', THRESHOLD => 0.6, INDEX => 'ncmec')"
|
|
178
188
|
)
|
|
179
189
|
assert seen[0]["purpose"] == "investigation"
|
|
180
190
|
assert result.rows[0]["entity_id"] == "e-7"
|
|
@@ -202,7 +212,7 @@ async def test_asimilar_image_uses_same_sql() -> None:
|
|
|
202
212
|
def _async_similar_image_handler(req: httpx.Request) -> httpx.Response:
|
|
203
213
|
body = json.loads(req.content)
|
|
204
214
|
assert body["sql"] == (
|
|
205
|
-
"
|
|
215
|
+
"SIMILAR_IMAGE('media-42', THRESHOLD => 0.6, INDEX => 'ncmec')"
|
|
206
216
|
)
|
|
207
217
|
return httpx.Response(
|
|
208
218
|
200, json={"rows": [{"entity_id": "y"}], "query_id": "q", "elapsed_ms": 0}
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|