multids 0.2.0__tar.gz → 1.0.0rc1__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 (35) hide show
  1. multids-1.0.0rc1/PKG-INFO +466 -0
  2. multids-1.0.0rc1/README.md +422 -0
  3. {multids-0.2.0 → multids-1.0.0rc1}/pyproject.toml +33 -16
  4. multids-1.0.0rc1/src/multids/__init__.py +16 -0
  5. {multids-0.2.0 → multids-1.0.0rc1}/src/multids/cli.py +3 -2
  6. {multids-0.2.0 → multids-1.0.0rc1}/src/multids/connectors/athena.py +92 -17
  7. multids-1.0.0rc1/src/multids/connectors/mssql.py +242 -0
  8. {multids-0.2.0 → multids-1.0.0rc1}/src/multids/connectors/opensearch.py +71 -13
  9. {multids-0.2.0 → multids-1.0.0rc1}/src/multids/connectors/s3.py +246 -35
  10. multids-1.0.0rc1/src/multids/connectors/sql.py +349 -0
  11. {multids-0.2.0 → multids-1.0.0rc1}/src/multids/connectors/sync/athena.py +51 -9
  12. {multids-0.2.0 → multids-1.0.0rc1}/src/multids/connectors/sync/mssql.py +99 -29
  13. {multids-0.2.0 → multids-1.0.0rc1}/src/multids/connectors/sync/s3.py +114 -13
  14. multids-1.0.0rc1/src/multids/connectors/sync/sql.py +266 -0
  15. multids-1.0.0rc1/src/multids/error_mapping.py +163 -0
  16. multids-1.0.0rc1/src/multids/py.typed +0 -0
  17. multids-1.0.0rc1/src/multids/reliability.py +244 -0
  18. multids-1.0.0rc1/src/multids/telemetry.py +250 -0
  19. {multids-0.2.0 → multids-1.0.0rc1}/src/multids/workflows.py +19 -0
  20. multids-0.2.0/PKG-INFO +0 -382
  21. multids-0.2.0/README.md +0 -341
  22. multids-0.2.0/src/multids/__init__.py +0 -6
  23. multids-0.2.0/src/multids/connectors/mssql.py +0 -151
  24. multids-0.2.0/src/multids/connectors/sql.py +0 -131
  25. multids-0.2.0/src/multids/connectors/sync/sql.py +0 -117
  26. multids-0.2.0/src/multids/reliability.py +0 -63
  27. {multids-0.2.0 → multids-1.0.0rc1}/LICENSE +0 -0
  28. {multids-0.2.0 → multids-1.0.0rc1}/src/multids/ai.py +0 -0
  29. {multids-0.2.0 → multids-1.0.0rc1}/src/multids/connectors/__init__.py +0 -0
  30. {multids-0.2.0 → multids-1.0.0rc1}/src/multids/connectors/local.py +0 -0
  31. {multids-0.2.0 → multids-1.0.0rc1}/src/multids/connectors/sync/__init__.py +0 -0
  32. {multids-0.2.0 → multids-1.0.0rc1}/src/multids/connectors/sync/local.py +0 -0
  33. {multids-0.2.0 → multids-1.0.0rc1}/src/multids/contracts.py +0 -0
  34. {multids-0.2.0 → multids-1.0.0rc1}/src/multids/errors.py +0 -0
  35. {multids-0.2.0 → multids-1.0.0rc1}/src/multids/interfaces.py +0 -0
@@ -0,0 +1,466 @@
1
+ Metadata-Version: 2.4
2
+ Name: multids
3
+ Version: 1.0.0rc1
4
+ Summary: Async multi-data-source connectors (S3, OpenSearch, Athena, MySQL, SQL Server, local files) with AI hooks.
5
+ License-File: LICENSE
6
+ Author: Khaldoun Aljasem
7
+ Author-email: khaldoun.aljasem@gmail.com
8
+ Requires-Python: >=3.11,<4.0
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Programming Language :: Python :: 3.15
18
+ Provides-Extra: ai
19
+ Provides-Extra: all
20
+ Provides-Extra: local
21
+ Provides-Extra: mysql
22
+ Provides-Extra: opensearch
23
+ Provides-Extra: s3
24
+ Provides-Extra: sqlserver
25
+ Provides-Extra: sync
26
+ Requires-Dist: aioboto3 (>=10.4) ; extra == "s3" or extra == "all"
27
+ Requires-Dist: aiofiles (>=23.1,<24.0) ; extra == "local" or extra == "all"
28
+ Requires-Dist: aioodbc ; (python_version < "3.12") and (extra == "sqlserver" or extra == "all")
29
+ Requires-Dist: asyncmy (>=0.2,<0.3) ; extra == "mysql" or extra == "all"
30
+ Requires-Dist: boto3 (>=1.24.59) ; extra == "s3" or extra == "sync" or extra == "all"
31
+ Requires-Dist: cryptography (>=41.0) ; extra == "mysql" or extra == "sync" or extra == "all"
32
+ Requires-Dist: greenlet (>=2.0) ; extra == "mysql" or extra == "all"
33
+ Requires-Dist: httpx[http2] (>=0.27.0,<0.28.0) ; extra == "opensearch" or extra == "all"
34
+ Requires-Dist: openai (>=1.0,<2.0) ; extra == "ai" or extra == "all"
35
+ Requires-Dist: pymysql (>=1.1,<2.0) ; extra == "sync" or extra == "all"
36
+ Requires-Dist: pyodbc (>=4.0,<5.0) ; (python_version < "3.12") and (extra == "sqlserver" or extra == "sync" or extra == "all")
37
+ Requires-Dist: requests (>=2.31,<3.0) ; extra == "opensearch" or extra == "sync" or extra == "all"
38
+ Requires-Dist: sqlalchemy (>=2.0,<2.1) ; extra == "mysql" or extra == "sync" or extra == "all"
39
+ Project-URL: Documentation, https://aljasem-tech.github.io/multids/
40
+ Project-URL: Homepage, https://github.com/aljasem-tech/multids
41
+ Project-URL: Repository, https://github.com/aljasem-tech/multids
42
+ Description-Content-Type: text/markdown
43
+
44
+ # multids
45
+
46
+ [![Docs](https://github.com/aljasem-tech/multids/actions/workflows/docs.yml/badge.svg)](https://aljasem-tech.github.io/multids/)
47
+ [![CI](https://github.com/aljasem-tech/multids/actions/workflows/ci.yml/badge.svg)](https://github.com/aljasem-tech/multids/actions/workflows/ci.yml)
48
+ [![PyPI](https://img.shields.io/pypi/v/multids)](https://pypi.org/project/multids/)
49
+ [![Python](https://img.shields.io/pypi/pyversions/multids)](https://pypi.org/project/multids/)
50
+ [![License](https://img.shields.io/github/license/aljasem-tech/multids)](https://github.com/aljasem-tech/multids/blob/main/LICENSE)
51
+
52
+ Async-first connectors for moving data across S3, OpenSearch, Athena, MySQL, SQL Server, and local files — with a
53
+ single, consistent API for streaming, bulk I/O, resumable uploads, and AI enrichment.
54
+
55
+ `multids` gives you one interface for many backends. Write a pipeline once, then point it at local files for testing
56
+ and at S3 or a database for production. Every connector supports both async and sync usage, typed errors, automatic
57
+ retries, and structured telemetry.
58
+
59
+ Full documentation: **https://aljasem-tech.github.io/multids/**
60
+
61
+ ---
62
+
63
+ ## Connectors at a glance
64
+
65
+ | Backend | Async | Sync | Install | Good for |
66
+ |--------------|:-----:|:----:|-----------------|-------------------------------------------|
67
+ | Local files | ✅ | ✅ | `multids[local]` | Local disk, temp workspaces, testing |
68
+ | Amazon S3 | ✅ | ✅ | `multids[s3]` | Object storage, data lakes, multipart |
69
+ | OpenSearch | ✅ | — | `multids[opensearch]`| Search, indexing, analytics |
70
+ | Athena | ✅ | ✅ | `multids[s3]` | Querying S3 data with SQL (read-only) |
71
+ | MySQL | ✅ | ✅ | `multids[mysql]` | Relational data via SQLAlchemy |
72
+ | SQL Server | ✅ | ✅ | `multids[sqlserver]` | Relational data via ODBC |
73
+
74
+ Every connector implements the same core operations — `read_stream`, `read_bytes`, `write_stream`, `write_bytes`,
75
+ `read_json`, `write_json` — plus backend-specific methods like `bulk_insert` (SQL) and `bulk_index` (OpenSearch).
76
+
77
+ ---
78
+
79
+ ## Installation
80
+
81
+ ```bash
82
+ pip install multids
83
+ ```
84
+
85
+ Install only the backends you need:
86
+
87
+ ```bash
88
+ pip install 'multids[s3]' # S3 + local files
89
+ pip install 'multids[opensearch]' # OpenSearch / Elasticsearch
90
+ pip install 'multids[mysql]' # MySQL (asyncmy + SQLAlchemy)
91
+ pip install 'multids[sqlserver]' # SQL Server (aioodbc + pyodbc)
92
+ pip install 'multids[local]' # Local files (aiofiles)
93
+ pip install 'multids[ai]' # OpenAI-compatible AI hooks
94
+
95
+ # Or install everything:
96
+ pip install 'multids[all]'
97
+ ```
98
+
99
+ > **SQL Server note:** the `sqlserver` extra requires an ODBC driver on your system (e.g. *ODBC Driver 18 for SQL
100
+ > Server*). It is not available on Python 3.12+ because `pyodbc` does not publish wheels for those versions.
101
+
102
+ ---
103
+
104
+ ## Quick start
105
+
106
+ ### Async: write and read JSON locally
107
+
108
+ ```python
109
+ import asyncio
110
+ from multids.connectors.local import LocalConnector
111
+
112
+
113
+ async def main():
114
+ local = LocalConnector()
115
+
116
+ data = {"message": "Hello", "lang": "你好"}
117
+
118
+ # Write JSON with unescaped Unicode
119
+ await local.write_json(data, "path/to/data.json")
120
+
121
+ # Read it back
122
+ result = await local.read_json("path/to/data.json")
123
+ print(result)
124
+
125
+
126
+ asyncio.run(main())
127
+ ```
128
+
129
+ ### Async: upload to S3
130
+
131
+ ```python
132
+ import asyncio
133
+ from multids.connectors.s3 import S3Connector
134
+
135
+
136
+ async def main():
137
+ s3 = S3Connector(region_name="eu-central-1")
138
+
139
+ # Small payloads use a single PUT automatically
140
+ await s3.write_bytes(b"hello world", "my-bucket", "greeting.txt")
141
+
142
+ # Large streams use multipart upload automatically
143
+ async def gen():
144
+ for _ in range(100):
145
+ yield b"x" * (1024 * 1024) # 1 MiB chunks
146
+
147
+ await s3.write_stream(gen(), "my-bucket", "large-file.bin")
148
+
149
+ # Read back
150
+ data = await s3.read_bytes("my-bucket", "greeting.txt")
151
+ print(data)
152
+
153
+ await s3.close()
154
+
155
+
156
+ asyncio.run(main())
157
+ ```
158
+
159
+ ### Sync: same API, blocking calls
160
+
161
+ Prefer synchronous code? Every core connector has a sync twin under `multids.connectors.sync`:
162
+
163
+ ```python
164
+ from multids.connectors.sync.local import SyncLocalConnector
165
+ from multids.connectors.sync.s3 import SyncS3Connector
166
+
167
+ # Local files
168
+ local = SyncLocalConnector()
169
+ local.write_bytes(b"hello", "out.txt")
170
+ print(local.read_bytes("out.txt"))
171
+
172
+ # S3
173
+ s3 = SyncS3Connector(region_name="eu-central-1")
174
+ s3.write_bytes(b"hello from sync", "my-bucket", "sync.txt")
175
+ print(s3.read_bytes("my-bucket", "sync.txt"))
176
+ s3.close()
177
+ ```
178
+
179
+ ### Error handling
180
+
181
+ All connectors raise stable, typed errors from `multids.errors` — you never need to import a backend SDK's exception:
182
+
183
+ ```python
184
+ import asyncio
185
+ from multids.errors import ConnectorConnectionError, ConnectorOperationError
186
+ from multids.connectors.s3 import S3Connector
187
+
188
+
189
+ async def main():
190
+ s3 = S3Connector()
191
+ try:
192
+ await s3.read_bytes("my-bucket", "missing-key")
193
+ except ConnectorOperationError:
194
+ print("Backend rejected the request (e.g. 404, invalid input)")
195
+ except ConnectorConnectionError:
196
+ print("Backend unreachable after retries — check network/credentials")
197
+ finally:
198
+ await s3.close()
199
+
200
+
201
+ asyncio.run(main())
202
+ ```
203
+
204
+ | Error | Meaning |
205
+ |------------------------------|-----------------------------------------------------------------|
206
+ | `ConnectorError` | Base class for all connector errors |
207
+ | `ConnectorDependencyError` | An optional dependency (driver) is not installed |
208
+ | `ConnectorConnectionError` | Backend unreachable or timed out after retries (safe to retry) |
209
+ | `ConnectorOperationError` | Backend rejected a valid request |
210
+ | `ConnectorSchemaError` | Request/result shape is wrong (subclass of `ConnectorOperationError`) |
211
+ | `ConnectorDataError` | A row/document was rejected (subclass of `ConnectorOperationError`) |
212
+
213
+ ---
214
+
215
+ ## S3: multipart and resumable uploads
216
+
217
+ `S3Connector` automatically switches from a single `put_object` to a multipart upload when the payload exceeds
218
+ `min_multipart_upload_size` (default 5 MiB). You can also force multipart for checkpoint-based resume.
219
+
220
+ ```python
221
+ import asyncio
222
+ from multids.connectors.s3 import S3Connector
223
+
224
+
225
+ async def main():
226
+ s3 = S3Connector(part_size=5 * 1024 * 1024)
227
+
228
+ async def stream():
229
+ for _ in range(100):
230
+ yield b"{" + b" " * 1024 + b"}\n"
231
+
232
+ checkpoint = "/tmp/uploads/my-object.chk"
233
+
234
+ # First attempt: start upload and write a checkpoint
235
+ await s3.write_stream(
236
+ stream(),
237
+ "my-bucket",
238
+ "my-object.json",
239
+ checkpoint_path=checkpoint,
240
+ force_multipart=True,
241
+ )
242
+
243
+ # If interrupted, rerun with resume=True — committed parts are not re-uploaded
244
+ await s3.write_stream(
245
+ stream(),
246
+ "my-bucket",
247
+ "my-object.json",
248
+ checkpoint_path=checkpoint,
249
+ resume=True,
250
+ )
251
+
252
+ await s3.close()
253
+
254
+
255
+ asyncio.run(main())
256
+ ```
257
+
258
+ The checkpoint file stores the `bucket`, `key`, `upload_id`, and completed parts so a retry continues from the last
259
+ committed part instead of restarting from byte 0.
260
+
261
+ ---
262
+
263
+ ## SQL connectors (MySQL, SQL Server)
264
+
265
+ SQL connectors provide `execute`, `fetch_rows`, `bulk_insert`, and record-streaming helpers. They use SQLAlchemy
266
+ under the hood and create their engine lazily on first use.
267
+
268
+ ```python
269
+ import asyncio
270
+ from multids.connectors.sql import MySQLConnector
271
+
272
+
273
+ async def main():
274
+ mysql = MySQLConnector("mysql+asyncmy://user:pass@localhost:3306/db")
275
+
276
+ rows = [{"id": i, "name": f"name-{i}"} for i in range(1000)]
277
+ result = await mysql.bulk_insert("users", rows, chunk_size=200)
278
+ print(f"Inserted {result.items_written} rows")
279
+
280
+ fetched = await mysql.fetch_rows("SELECT id, name FROM users LIMIT 10")
281
+ for row in fetched:
282
+ print(row)
283
+
284
+ await mysql.close()
285
+
286
+
287
+ asyncio.run(main())
288
+ ```
289
+
290
+ Sync equivalent:
291
+
292
+ ```python
293
+ from multids.connectors.sync.sql import SyncMySQLConnector
294
+
295
+ mysql = SyncMySQLConnector("mysql+pymysql://user:pass@localhost:3306/db")
296
+ mysql.bulk_insert("users", [{"id": 1, "name": "alice"}], chunk_size=100)
297
+ rows = mysql.fetch_rows("SELECT id, name FROM users")
298
+ mysql.close()
299
+ ```
300
+
301
+ For SQL Server, use `MSSQLConnector` (async) or `SyncMSSQLConnector` (sync) with an ODBC connection string:
302
+
303
+ ```python
304
+ import asyncio
305
+ from multids.connectors.mssql import MSSQLConnector
306
+
307
+
308
+ async def main():
309
+ conn = MSSQLConnector(
310
+ "DRIVER={ODBC Driver 18 for SQL Server};SERVER=localhost,1433;DATABASE=master;UID=sa;PWD=YourPassword;TrustServerCertificate=yes"
311
+ )
312
+ await conn.connect_pool()
313
+ rows = await conn.fetch_rows("SELECT id, name FROM users")
314
+ await conn.close()
315
+
316
+
317
+ asyncio.run(main())
318
+ ```
319
+
320
+ ---
321
+
322
+ ## OpenSearch
323
+
324
+ `OpenSearchConnector` is an async, `httpx`-based client for indexing, searching, and scrolling OpenSearch /
325
+ Elasticsearch.
326
+
327
+ ```python
328
+ import asyncio
329
+ from multids.connectors.opensearch import OpenSearchConnector
330
+
331
+
332
+ async def main():
333
+ oc = OpenSearchConnector("http://localhost:9200")
334
+
335
+ # Index a single document
336
+ await oc.index_doc("my-index", {"name": "alice"})
337
+
338
+ # Bulk index
339
+ docs = [{"id": 1, "name": "a"}, {"id": 2, "name": "b"}]
340
+ await oc.bulk_index("my-index", docs, chunk_size=100)
341
+
342
+ # Search
343
+ result = await oc.search("my-index", {"query": {"match_all": {}}}, size=10)
344
+
345
+ # Scroll over large result sets
346
+ async for hit in oc.scroll("my-index", {"query": {"match_all": {}}}):
347
+ print(hit)
348
+
349
+ await oc.close()
350
+
351
+
352
+ asyncio.run(main())
353
+ ```
354
+
355
+ Authentication:
356
+
357
+ ```python
358
+ from multids.connectors.opensearch import OpenSearchConnector
359
+
360
+ # API key
361
+ oc = OpenSearchConnector("https://es.example.com", api_key="BASE64_API_KEY")
362
+
363
+ # Basic auth
364
+ oc = OpenSearchConnector("https://es.example.com", basic_auth=("user", "pass"))
365
+ ```
366
+
367
+ ---
368
+
369
+ ## AI enrichment
370
+
371
+ `multids.ai` provides a pluggable text-generation interface that works with any OpenAI-compatible client. Use it to
372
+ enrich records before indexing them:
373
+
374
+ ```python
375
+ import asyncio
376
+ from openai import AsyncOpenAI
377
+ from multids.ai import OpenAIClient
378
+ from multids.connectors.opensearch import OpenSearchConnector
379
+
380
+
381
+ async def main():
382
+ ai = OpenAIClient(AsyncOpenAI())
383
+ oc = OpenSearchConnector("http://localhost:9200")
384
+
385
+ docs = [{"id": "1", "text": "OpenSearch + AI"}]
386
+ for doc in docs:
387
+ response = await ai.generate(doc["text"], model="gpt-4o-mini")
388
+ doc["summary"] = response["content"]
389
+
390
+ await oc.bulk_index("my-index", docs)
391
+ await oc.close()
392
+
393
+
394
+ asyncio.run(main())
395
+ ```
396
+
397
+ ---
398
+
399
+ ## Data workflows
400
+
401
+ `multids.workflows` connects two connectors without buffering the whole payload in memory:
402
+
403
+ ```python
404
+ import asyncio
405
+ from multids.connectors.local import LocalConnector
406
+ from multids.connectors.s3 import S3Connector
407
+ from multids.workflows import copy_stream
408
+
409
+
410
+ async def main():
411
+ local = LocalConnector(base_path="./exports")
412
+ s3 = S3Connector(region_name="eu-central-1")
413
+
414
+ result = await copy_stream(
415
+ local,
416
+ s3,
417
+ source_args=("daily/events.jsonl",),
418
+ destination_args=("my-bucket", "exports/events.jsonl"),
419
+ )
420
+ print(f"Copied {result.bytes_copied} bytes in {result.chunks_copied} chunks")
421
+
422
+ await local.close()
423
+ await s3.close()
424
+
425
+
426
+ asyncio.run(main())
427
+ ```
428
+
429
+ See [docs/workflows.md](docs/workflows.md) for record transforms, batching, and checkpoints.
430
+
431
+ ---
432
+
433
+ ## CLI
434
+
435
+ A built-in CLI handles safe local-file operations:
436
+
437
+ ```bash
438
+ multids ping --path ./data
439
+ multids copy ./data/input.jsonl ./out/input.jsonl
440
+ multids validate workflow.json
441
+ ```
442
+
443
+ ---
444
+
445
+ ## Documentation
446
+
447
+ | Guide | Description |
448
+ |--------------------|----------------------------------------------------------|
449
+ | [Quickstart](docs/quickstart.md) | Install and run your first connector |
450
+ | [Usage](docs/usage.md) | Patterns for every backend, sync and async |
451
+ | [API reference](docs/api.md) | Method signatures, errors, contracts |
452
+ | [Data workflows](docs/workflows.md) | Copy, transform, and batch between connectors |
453
+ | [Reliability](docs/observability.md) | Retries, timeouts, telemetry, error handling |
454
+ | [Support matrix](docs/support.md) | Python versions, extras, CI coverage |
455
+
456
+ ---
457
+
458
+ ## Contributing
459
+
460
+ Contributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, testing, and the pull
461
+ request process.
462
+
463
+ ## License
464
+
465
+ MIT — see [LICENSE](LICENSE).
466
+