avrokit 0.0.6__tar.gz → 0.1.0__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.
- {avrokit-0.0.6 → avrokit-0.1.0}/.github/workflows/check.yml +7 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/.github/workflows/release.yml +4 -0
- avrokit-0.1.0/LICENSES/Apache-2.0.txt +73 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/Makefile +9 -5
- {avrokit-0.0.6 → avrokit-0.1.0}/PKG-INFO +7 -8
- {avrokit-0.0.6 → avrokit-0.1.0}/README.md +2 -6
- {avrokit-0.0.6 → avrokit-0.1.0}/avrokit/io/reader.py +2 -1
- {avrokit-0.0.6 → avrokit-0.1.0}/avrokit/io/writer.py +2 -7
- {avrokit-0.0.6 → avrokit-0.1.0}/avrokit/url/file.py +3 -1
- {avrokit-0.0.6 → avrokit-0.1.0}/avrokit/url/google.py +2 -1
- {avrokit-0.0.6 → avrokit-0.1.0}/avrokit/url/http.py +7 -3
- {avrokit-0.0.6 → avrokit-0.1.0}/avrokit/url/s3.py +2 -1
- {avrokit-0.0.6 → avrokit-0.1.0}/pyproject.toml +6 -5
- avrokit-0.1.0/tests/test_exports.py +118 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/tests/test_io_schema.py +223 -20
- {avrokit-0.0.6 → avrokit-0.1.0}/tests/test_tools_httpserver.py +49 -0
- avrokit-0.1.0/tests/test_url_contract.py +151 -0
- avrokit-0.1.0/tests/test_url_http.py +681 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/uv.lock +259 -3
- avrokit-0.1.0/uv.lock.license +3 -0
- avrokit-0.0.6/tests/test_url_http.py +0 -91
- {avrokit-0.0.6 → avrokit-0.1.0}/.gitignore +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/LICENSE +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/avrokit/__init__.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/avrokit/asyncio/__init__.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/avrokit/asyncio/reader.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/avrokit/asyncio/writer.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/avrokit/io/__init__.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/avrokit/io/compact.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/avrokit/io/schema.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/avrokit/py.typed +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/avrokit/tools/__init__.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/avrokit/tools/__main__.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/avrokit/tools/base.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/avrokit/tools/cat.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/avrokit/tools/concat.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/avrokit/tools/count.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/avrokit/tools/filesort.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/avrokit/tools/fromparquet.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/avrokit/tools/getmeta.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/avrokit/tools/getschema.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/avrokit/tools/httpserver.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/avrokit/tools/partition.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/avrokit/tools/repair.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/avrokit/tools/stats.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/avrokit/tools/tojson.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/avrokit/tools/toparquet.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/avrokit/url/__init__.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/avrokit/url/base.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/avrokit/url/factory.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/avrokit/url/utils.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/tests/__init__.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/tests/test_additional_coverage.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/tests/test_asyncio.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/tests/test_io.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/tests/test_plan_coverage.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/tests/test_property_based.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/tests/test_schema_advanced.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/tests/test_tools_integration.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/tests/test_tools_repair.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/tests/test_url.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/tests/test_url_file.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/tests/test_url_google.py +0 -0
- {avrokit-0.0.6 → avrokit-0.1.0}/tests/test_url_s3.py +0 -0
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Greg Brandt <brandt.greg@gmail.com>
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
1
5
|
name: Check
|
|
2
6
|
|
|
3
7
|
on:
|
|
@@ -29,3 +33,6 @@ jobs:
|
|
|
29
33
|
|
|
30
34
|
- name: Test
|
|
31
35
|
run: uv run pytest -n auto
|
|
36
|
+
|
|
37
|
+
- name: License check
|
|
38
|
+
run: uv run reuse lint
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
|
10
|
+
|
|
11
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
|
12
|
+
|
|
13
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
|
14
|
+
|
|
15
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
|
16
|
+
|
|
17
|
+
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
|
18
|
+
|
|
19
|
+
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
|
20
|
+
|
|
21
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
|
22
|
+
|
|
23
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
|
24
|
+
|
|
25
|
+
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
|
26
|
+
|
|
27
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
|
28
|
+
|
|
29
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
|
30
|
+
|
|
31
|
+
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
|
32
|
+
|
|
33
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
|
34
|
+
|
|
35
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
36
|
+
|
|
37
|
+
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
|
38
|
+
|
|
39
|
+
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
|
40
|
+
|
|
41
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
|
42
|
+
|
|
43
|
+
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
|
44
|
+
|
|
45
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
|
46
|
+
|
|
47
|
+
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
|
48
|
+
|
|
49
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
|
50
|
+
|
|
51
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
|
52
|
+
|
|
53
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
|
54
|
+
|
|
55
|
+
END OF TERMS AND CONDITIONS
|
|
56
|
+
|
|
57
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
58
|
+
|
|
59
|
+
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
|
|
60
|
+
|
|
61
|
+
Copyright [yyyy] [name of copyright owner]
|
|
62
|
+
|
|
63
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
64
|
+
you may not use this file except in compliance with the License.
|
|
65
|
+
You may obtain a copy of the License at
|
|
66
|
+
|
|
67
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
68
|
+
|
|
69
|
+
Unless required by applicable law or agreed to in writing, software
|
|
70
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
71
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
72
|
+
See the License for the specific language governing permissions and
|
|
73
|
+
limitations under the License.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
#
|
|
3
3
|
# SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
|
|
5
|
-
.PHONY: install test test-coverage lint
|
|
5
|
+
.PHONY: install test test-coverage lint fix typecheck format build publish lock check license-check bump help
|
|
6
6
|
|
|
7
7
|
help: ## Display this help
|
|
8
8
|
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
|
|
@@ -25,9 +25,6 @@ test-coverage: ## Run tests with coverage report
|
|
|
25
25
|
lint: ## Run ruff linter
|
|
26
26
|
uv run ruff check .
|
|
27
27
|
|
|
28
|
-
lint-fix: ## Run ruff linter and apply fixes
|
|
29
|
-
uv run ruff check --fix .
|
|
30
|
-
|
|
31
28
|
typecheck: ## Run type checker
|
|
32
29
|
uv run ty check
|
|
33
30
|
|
|
@@ -40,7 +37,14 @@ bump: ## Bump version: make bump part=patch|minor|major
|
|
|
40
37
|
lock: ## Update the lockfile
|
|
41
38
|
uv lock
|
|
42
39
|
|
|
43
|
-
|
|
40
|
+
fix: ## Run ruff linter and apply fixes
|
|
41
|
+
uv run ruff format .
|
|
42
|
+
uv run ruff check --fix .
|
|
43
|
+
|
|
44
|
+
check: lint typecheck format test license-check ## Run all checks (lint, typecheck, format, test)
|
|
45
|
+
|
|
46
|
+
license-check: ## Check that all files have REUSE license headers
|
|
47
|
+
uv run reuse lint
|
|
44
48
|
|
|
45
49
|
license: ## Annotate files with REUSE license headers
|
|
46
50
|
uv run reuse annotate \
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: avrokit
|
|
3
|
-
Version: 0.0
|
|
3
|
+
Version: 0.1.0
|
|
4
4
|
Summary: Python utilities for working with Avro data files
|
|
5
5
|
Project-URL: Homepage, https://github.com/brandtg/avrokit
|
|
6
6
|
Project-URL: Repository, https://github.com/brandtg/avrokit
|
|
@@ -12,10 +12,12 @@ Classifier: Development Status :: 3 - Alpha
|
|
|
12
12
|
Classifier: Intended Audience :: Developers
|
|
13
13
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
14
|
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
17
|
Classifier: Programming Language :: Python :: 3.12
|
|
16
18
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
17
19
|
Classifier: Typing :: Typed
|
|
18
|
-
Requires-Python: >=3.
|
|
20
|
+
Requires-Python: >=3.10
|
|
19
21
|
Requires-Dist: avro>=1.12.1
|
|
20
22
|
Requires-Dist: boto3-stubs[s3]>=1.38.8
|
|
21
23
|
Requires-Dist: datetime-truncate>=1.1.1
|
|
@@ -23,6 +25,7 @@ Requires-Dist: filelock>=3.18.0
|
|
|
23
25
|
Requires-Dist: pyarrow>=22.0.0
|
|
24
26
|
Requires-Dist: requests>=2.32.3
|
|
25
27
|
Requires-Dist: types-requests>=2.32.0.20250328
|
|
28
|
+
Requires-Dist: typing-extensions>=4.12.0
|
|
26
29
|
Provides-Extra: all
|
|
27
30
|
Requires-Dist: boto3>=1.38.7; extra == 'all'
|
|
28
31
|
Requires-Dist: google-cloud-storage>=3.6.0; extra == 'all'
|
|
@@ -80,7 +83,6 @@ pip install avrokit[all]
|
|
|
80
83
|
```bash
|
|
81
84
|
git clone https://github.com/brandtg/avrokit.git
|
|
82
85
|
cd avrokit
|
|
83
|
-
poetry env use python3.12
|
|
84
86
|
make install
|
|
85
87
|
```
|
|
86
88
|
|
|
@@ -321,15 +323,12 @@ avrokit toparquet INPUT.avro OUTPUT.parquet
|
|
|
321
323
|
### Prerequisites
|
|
322
324
|
|
|
323
325
|
- Python 3.12+
|
|
324
|
-
-
|
|
326
|
+
- uv
|
|
325
327
|
- Docker (for GCS/S3 integration tests)
|
|
326
328
|
|
|
327
329
|
### Setup
|
|
328
330
|
|
|
329
331
|
```bash
|
|
330
|
-
# Set up Python environment
|
|
331
|
-
poetry env use python3.12
|
|
332
|
-
|
|
333
332
|
# Install dependencies
|
|
334
333
|
make install
|
|
335
334
|
|
|
@@ -347,7 +346,7 @@ make test
|
|
|
347
346
|
make test-coverage
|
|
348
347
|
|
|
349
348
|
# Run tests in parallel (default)
|
|
350
|
-
|
|
349
|
+
uv run pytest -n auto
|
|
351
350
|
```
|
|
352
351
|
|
|
353
352
|
### Code Quality
|
|
@@ -44,7 +44,6 @@ pip install avrokit[all]
|
|
|
44
44
|
```bash
|
|
45
45
|
git clone https://github.com/brandtg/avrokit.git
|
|
46
46
|
cd avrokit
|
|
47
|
-
poetry env use python3.12
|
|
48
47
|
make install
|
|
49
48
|
```
|
|
50
49
|
|
|
@@ -285,15 +284,12 @@ avrokit toparquet INPUT.avro OUTPUT.parquet
|
|
|
285
284
|
### Prerequisites
|
|
286
285
|
|
|
287
286
|
- Python 3.12+
|
|
288
|
-
-
|
|
287
|
+
- uv
|
|
289
288
|
- Docker (for GCS/S3 integration tests)
|
|
290
289
|
|
|
291
290
|
### Setup
|
|
292
291
|
|
|
293
292
|
```bash
|
|
294
|
-
# Set up Python environment
|
|
295
|
-
poetry env use python3.12
|
|
296
|
-
|
|
297
293
|
# Install dependencies
|
|
298
294
|
make install
|
|
299
295
|
|
|
@@ -311,7 +307,7 @@ make test
|
|
|
311
307
|
make test-coverage
|
|
312
308
|
|
|
313
309
|
# Run tests in parallel (default)
|
|
314
|
-
|
|
310
|
+
uv run pytest -n auto
|
|
315
311
|
```
|
|
316
312
|
|
|
317
313
|
### Code Quality
|
|
@@ -6,10 +6,11 @@ from __future__ import annotations
|
|
|
6
6
|
|
|
7
7
|
from collections.abc import Generator, Iterator, Sequence
|
|
8
8
|
from contextlib import contextmanager
|
|
9
|
-
from typing import IO, Any,
|
|
9
|
+
from typing import IO, Any, cast
|
|
10
10
|
|
|
11
11
|
from avro.datafile import DataFileReader
|
|
12
12
|
from avro.io import DatumReader
|
|
13
|
+
from typing_extensions import Self
|
|
13
14
|
|
|
14
15
|
from ..url import URL
|
|
15
16
|
|
|
@@ -10,18 +10,13 @@ from collections.abc import Generator, Mapping, Sequence
|
|
|
10
10
|
from contextlib import contextmanager
|
|
11
11
|
from datetime import datetime
|
|
12
12
|
from itertools import groupby
|
|
13
|
-
from typing import
|
|
14
|
-
IO,
|
|
15
|
-
Any,
|
|
16
|
-
Literal,
|
|
17
|
-
Protocol,
|
|
18
|
-
Self,
|
|
19
|
-
)
|
|
13
|
+
from typing import IO, Any, Literal, Protocol
|
|
20
14
|
|
|
21
15
|
from avro.datafile import NULL_CODEC, DataFileWriter
|
|
22
16
|
from avro.io import DatumWriter
|
|
23
17
|
from avro.schema import Schema
|
|
24
18
|
from datetime_truncate import truncate as truncate_datetime
|
|
19
|
+
from typing_extensions import Self
|
|
25
20
|
|
|
26
21
|
from avrokit.url.utils import flatten_urls
|
|
27
22
|
|
|
@@ -7,11 +7,12 @@ import os
|
|
|
7
7
|
import tempfile
|
|
8
8
|
from collections.abc import Generator, Sequence
|
|
9
9
|
from contextlib import contextmanager
|
|
10
|
-
from typing import IO, Any, cast
|
|
10
|
+
from typing import IO, Any, cast
|
|
11
11
|
|
|
12
12
|
from google.api_core.exceptions import NotFound
|
|
13
13
|
from google.auth.credentials import AnonymousCredentials
|
|
14
14
|
from google.cloud import storage
|
|
15
|
+
from typing_extensions import override
|
|
15
16
|
|
|
16
17
|
from .base import URL
|
|
17
18
|
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
import io
|
|
6
6
|
import tempfile
|
|
7
7
|
from collections.abc import Sequence
|
|
8
|
-
from typing import IO, Any
|
|
8
|
+
from typing import IO, Any
|
|
9
9
|
|
|
10
10
|
import requests
|
|
11
|
+
from typing_extensions import override
|
|
11
12
|
|
|
12
13
|
from .base import URL
|
|
13
14
|
|
|
@@ -57,9 +58,12 @@ class HttpURL(URL):
|
|
|
57
58
|
try:
|
|
58
59
|
response = requests.head(self.url, timeout=5)
|
|
59
60
|
if response.ok:
|
|
60
|
-
|
|
61
|
+
content_length = response.headers.get("Content-Length")
|
|
62
|
+
if content_length is not None:
|
|
63
|
+
return int(content_length)
|
|
64
|
+
return 0
|
|
61
65
|
return 0
|
|
62
|
-
except requests.RequestException:
|
|
66
|
+
except (requests.RequestException, ValueError):
|
|
63
67
|
return 0
|
|
64
68
|
|
|
65
69
|
@override
|
|
@@ -6,10 +6,11 @@ import io
|
|
|
6
6
|
import tempfile
|
|
7
7
|
from collections.abc import Sequence
|
|
8
8
|
from contextlib import contextmanager
|
|
9
|
-
from typing import IO, Any, cast
|
|
9
|
+
from typing import IO, Any, cast
|
|
10
10
|
|
|
11
11
|
import boto3
|
|
12
12
|
from mypy_boto3_s3 import S3Client
|
|
13
|
+
from typing_extensions import override
|
|
13
14
|
|
|
14
15
|
from .base import URL
|
|
15
16
|
|
|
@@ -4,18 +4,20 @@
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "avrokit"
|
|
7
|
-
version = "0.0
|
|
7
|
+
version = "0.1.0"
|
|
8
8
|
description = "Python utilities for working with Avro data files"
|
|
9
9
|
authors = [{ name = "Greg Brandt", email = "brandt.greg@gmail.com" }]
|
|
10
10
|
license = "Apache-2.0"
|
|
11
11
|
readme = "README.md"
|
|
12
|
-
requires-python = ">=3.
|
|
12
|
+
requires-python = ">=3.10"
|
|
13
13
|
keywords = ["avro", "data", "serialization", "gcs", "s3", "parquet"]
|
|
14
14
|
classifiers = [
|
|
15
15
|
"Development Status :: 3 - Alpha",
|
|
16
16
|
"Intended Audience :: Developers",
|
|
17
17
|
"License :: OSI Approved :: Apache Software License",
|
|
18
18
|
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.10",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
19
21
|
"Programming Language :: Python :: 3.12",
|
|
20
22
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
21
23
|
"Typing :: Typed",
|
|
@@ -28,6 +30,7 @@ dependencies = [
|
|
|
28
30
|
"boto3-stubs[s3]>=1.38.8",
|
|
29
31
|
"types-requests>=2.32.0.20250328",
|
|
30
32
|
"pyarrow>=22.0.0",
|
|
33
|
+
"typing-extensions>=4.12.0",
|
|
31
34
|
]
|
|
32
35
|
|
|
33
36
|
[project.optional-dependencies]
|
|
@@ -61,14 +64,12 @@ dev = [
|
|
|
61
64
|
requires = ["hatchling"]
|
|
62
65
|
build-backend = "hatchling.build"
|
|
63
66
|
|
|
64
|
-
[tool.hatch.build.targets.wheel]
|
|
65
|
-
include = ["avrokit/py.typed"]
|
|
66
|
-
|
|
67
67
|
[tool.pytest.ini_options]
|
|
68
68
|
filterwarnings = ["ignore::DeprecationWarning:botocore.*"]
|
|
69
69
|
|
|
70
70
|
[tool.ruff]
|
|
71
71
|
exclude = []
|
|
72
|
+
target-version = "py310"
|
|
72
73
|
|
|
73
74
|
[tool.ruff.lint]
|
|
74
75
|
select = ["E", "F", "I", "UP"]
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Greg Brandt <brandt.greg@gmail.com>
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
"""
|
|
6
|
+
Regression test: verify all public symbols in avrokit.__all__ are importable
|
|
7
|
+
and resolve to the expected type. This guards against build configuration
|
|
8
|
+
changes (e.g. hatchling include/exclude rules) silently dropping source files
|
|
9
|
+
from the wheel.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import importlib
|
|
13
|
+
|
|
14
|
+
import pytest
|
|
15
|
+
|
|
16
|
+
# Every name declared in avrokit.__all__, paired with the type it must be.
|
|
17
|
+
# "callable" covers both functions and classes.
|
|
18
|
+
EXPECTED_EXPORTS: list[tuple[str, type | tuple[type, ...]]] = [
|
|
19
|
+
# io
|
|
20
|
+
("Appendable", type),
|
|
21
|
+
("PartitionedAvroReader", type),
|
|
22
|
+
("PartitionedAvroWriter", type),
|
|
23
|
+
("TimePartitionedAvroWriter", type),
|
|
24
|
+
("avro_reader", object),
|
|
25
|
+
("avro_records", object),
|
|
26
|
+
("avro_schema", object),
|
|
27
|
+
("avro_writer", object),
|
|
28
|
+
("compact_avro_data", object),
|
|
29
|
+
("read_avro_schema", object),
|
|
30
|
+
("read_avro_schema_from_first_nonempty_file", object),
|
|
31
|
+
("validate_avro_schema_evolution", object),
|
|
32
|
+
("add_avro_schema_fields", object),
|
|
33
|
+
# asyncio
|
|
34
|
+
("BlockingQueueAvroReader", type),
|
|
35
|
+
("DeferredAvroWriter", type),
|
|
36
|
+
# url
|
|
37
|
+
("URL", type),
|
|
38
|
+
("FileURL", type),
|
|
39
|
+
("parse_url", object),
|
|
40
|
+
("create_url_mapping", object),
|
|
41
|
+
("flatten_urls", object),
|
|
42
|
+
# tools
|
|
43
|
+
("CatTool", type),
|
|
44
|
+
("ConcatTool", type),
|
|
45
|
+
("FileSortTool", type),
|
|
46
|
+
("FromParquetTool", type),
|
|
47
|
+
("GetMetaTool", type),
|
|
48
|
+
("GetSchemaTool", type),
|
|
49
|
+
("HttpServerTool", type),
|
|
50
|
+
("PartitionTool", type),
|
|
51
|
+
("RepairTool", type),
|
|
52
|
+
("StatsTool", type),
|
|
53
|
+
("ToJsonTool", type),
|
|
54
|
+
("ToParquetTool", type),
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class TestPublicExports:
|
|
59
|
+
"""Verify avrokit.__all__ is complete and every symbol is importable."""
|
|
60
|
+
|
|
61
|
+
def test_all_is_defined(self):
|
|
62
|
+
import avrokit
|
|
63
|
+
|
|
64
|
+
assert hasattr(avrokit, "__all__"), "avrokit must define __all__"
|
|
65
|
+
assert len(avrokit.__all__) > 0
|
|
66
|
+
|
|
67
|
+
@pytest.mark.parametrize("name,expected_type", EXPECTED_EXPORTS)
|
|
68
|
+
def test_symbol_importable(self, name, expected_type):
|
|
69
|
+
"""Each symbol can be imported directly from avrokit."""
|
|
70
|
+
avrokit = importlib.import_module("avrokit")
|
|
71
|
+
assert hasattr(avrokit, name), (
|
|
72
|
+
f"avrokit.{name} is missing — was it dropped from the wheel?"
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
@pytest.mark.parametrize("name,expected_type", EXPECTED_EXPORTS)
|
|
76
|
+
def test_symbol_is_callable(self, name, expected_type):
|
|
77
|
+
"""Each exported symbol must be callable (function or class)."""
|
|
78
|
+
avrokit = importlib.import_module("avrokit")
|
|
79
|
+
obj = getattr(avrokit, name)
|
|
80
|
+
assert callable(obj), f"avrokit.{name} is not callable (got {type(obj)})"
|
|
81
|
+
|
|
82
|
+
def test_no_undeclared_exports(self):
|
|
83
|
+
"""Every name in __all__ is covered by EXPECTED_EXPORTS."""
|
|
84
|
+
import avrokit
|
|
85
|
+
|
|
86
|
+
expected_names = {name for name, _ in EXPECTED_EXPORTS}
|
|
87
|
+
undeclared = set(avrokit.__all__) - expected_names
|
|
88
|
+
assert not undeclared, (
|
|
89
|
+
f"These names are in __all__ but not in EXPECTED_EXPORTS: {undeclared}\n"
|
|
90
|
+
"Add them to EXPECTED_EXPORTS in tests/test_exports.py."
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
def test_all_matches_actual_imports(self):
|
|
94
|
+
"""Every name in EXPECTED_EXPORTS is also listed in __all__."""
|
|
95
|
+
import avrokit
|
|
96
|
+
|
|
97
|
+
for name, _ in EXPECTED_EXPORTS:
|
|
98
|
+
assert name in avrokit.__all__, (
|
|
99
|
+
f"avrokit.{name} is in EXPECTED_EXPORTS but missing from __all__"
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
def test_version_is_set(self):
|
|
103
|
+
import avrokit
|
|
104
|
+
|
|
105
|
+
assert hasattr(avrokit, "__version__")
|
|
106
|
+
assert isinstance(avrokit.__version__, str)
|
|
107
|
+
assert avrokit.__version__ # non-empty
|
|
108
|
+
|
|
109
|
+
def test_submodules_importable(self):
|
|
110
|
+
"""Core sub-packages must themselves be importable."""
|
|
111
|
+
for submodule in (
|
|
112
|
+
"avrokit.io",
|
|
113
|
+
"avrokit.url",
|
|
114
|
+
"avrokit.tools",
|
|
115
|
+
"avrokit.asyncio",
|
|
116
|
+
):
|
|
117
|
+
mod = importlib.import_module(submodule)
|
|
118
|
+
assert mod is not None, f"{submodule} could not be imported"
|