avrokit 0.0.1__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 (38) hide show
  1. avrokit-0.0.1/LICENSE +201 -0
  2. avrokit-0.0.1/PKG-INFO +485 -0
  3. avrokit-0.0.1/README.md +448 -0
  4. avrokit-0.0.1/avrokit/__init__.py +111 -0
  5. avrokit-0.0.1/avrokit/asyncio/__init__.py +11 -0
  6. avrokit-0.0.1/avrokit/asyncio/reader.py +48 -0
  7. avrokit-0.0.1/avrokit/asyncio/writer.py +48 -0
  8. avrokit-0.0.1/avrokit/io/__init__.py +35 -0
  9. avrokit-0.0.1/avrokit/io/compact.py +36 -0
  10. avrokit-0.0.1/avrokit/io/reader.py +84 -0
  11. avrokit-0.0.1/avrokit/io/schema.py +166 -0
  12. avrokit-0.0.1/avrokit/io/writer.py +199 -0
  13. avrokit-0.0.1/avrokit/py.typed +0 -0
  14. avrokit-0.0.1/avrokit/tools/__init__.py +31 -0
  15. avrokit-0.0.1/avrokit/tools/__main__.py +81 -0
  16. avrokit-0.0.1/avrokit/tools/base.py +30 -0
  17. avrokit-0.0.1/avrokit/tools/cat.py +103 -0
  18. avrokit-0.0.1/avrokit/tools/concat.py +174 -0
  19. avrokit-0.0.1/avrokit/tools/count.py +74 -0
  20. avrokit-0.0.1/avrokit/tools/filesort.py +141 -0
  21. avrokit-0.0.1/avrokit/tools/fromparquet.py +207 -0
  22. avrokit-0.0.1/avrokit/tools/getmeta.py +32 -0
  23. avrokit-0.0.1/avrokit/tools/getschema.py +32 -0
  24. avrokit-0.0.1/avrokit/tools/httpserver.py +269 -0
  25. avrokit-0.0.1/avrokit/tools/partition.py +107 -0
  26. avrokit-0.0.1/avrokit/tools/repair.py +237 -0
  27. avrokit-0.0.1/avrokit/tools/stats.py +66 -0
  28. avrokit-0.0.1/avrokit/tools/tojson.py +33 -0
  29. avrokit-0.0.1/avrokit/tools/toparquet.py +153 -0
  30. avrokit-0.0.1/avrokit/url/__init__.py +10 -0
  31. avrokit-0.0.1/avrokit/url/base.py +98 -0
  32. avrokit-0.0.1/avrokit/url/factory.py +34 -0
  33. avrokit-0.0.1/avrokit/url/file.py +108 -0
  34. avrokit-0.0.1/avrokit/url/google.py +168 -0
  35. avrokit-0.0.1/avrokit/url/http.py +122 -0
  36. avrokit-0.0.1/avrokit/url/s3.py +141 -0
  37. avrokit-0.0.1/avrokit/url/utils.py +60 -0
  38. avrokit-0.0.1/pyproject.toml +67 -0
avrokit-0.0.1/LICENSE ADDED
@@ -0,0 +1,201 @@
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,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Greg Brandt
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
avrokit-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,485 @@
1
+ Metadata-Version: 2.4
2
+ Name: avrokit
3
+ Version: 0.0.1
4
+ Summary: Python utilities for working with Avro data files
5
+ License: Apache-2.0
6
+ License-File: LICENSE
7
+ Keywords: avro,data,serialization,gcs,s3,parquet
8
+ Author: Greg Brandt
9
+ Author-email: brandt.greg@gmail.com
10
+ Requires-Python: >=3.12,<4.0
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
+ Classifier: Typing :: Typed
20
+ Provides-Extra: all
21
+ Provides-Extra: aws
22
+ Provides-Extra: gcp
23
+ Requires-Dist: avro (>=1.12.1,<2.0.0)
24
+ Requires-Dist: boto3 (>=1.38.7,<2.0.0) ; extra == "aws" or extra == "all"
25
+ Requires-Dist: boto3-stubs[s3] (>=1.38.8,<2.0.0)
26
+ Requires-Dist: datetime-truncate (>=1.1.1,<2.0.0)
27
+ Requires-Dist: filelock (>=3.18.0,<4.0.0)
28
+ Requires-Dist: google-cloud-storage (>=3.6.0,<4.0.0) ; extra == "gcp" or extra == "all"
29
+ Requires-Dist: google-crc32c (>=1.7.1,<2.0.0) ; extra == "gcp" or extra == "all"
30
+ Requires-Dist: pyarrow (>=22.0.0,<23.0.0)
31
+ Requires-Dist: requests (>=2.32.3,<3.0.0)
32
+ Requires-Dist: types-requests (>=2.32.0.20250328,<3.0.0.0)
33
+ Project-URL: Homepage, https://github.com/brandtg/avrokit
34
+ Project-URL: Repository, https://github.com/brandtg/avrokit
35
+ Description-Content-Type: text/markdown
36
+
37
+ <!--
38
+ SPDX-FileCopyrightText: 2026 Greg Brandt <brandt.greg@gmail.com>
39
+
40
+ SPDX-License-Identifier: Apache-2.0
41
+ -->
42
+
43
+ # avrokit
44
+
45
+ Python utilities for working with Avro data files with support for local files, GCS, S3, and HTTP/HTTPS URLs.
46
+
47
+ ## Features
48
+
49
+ - **Unified URL Interface**: Read and write Avro files transparently across local filesystem, GCS, S3, and HTTP/HTTPS
50
+ - **CLI Tools**: Comprehensive command-line tools for common Avro operations
51
+ - **Python API**: Rich programmatic interface for reading, writing, and transforming Avro data
52
+ - **Partitioned I/O**: Support for reading and writing partitioned/multi-file datasets
53
+ - **Async Support**: Non-blocking I/O primitives for high-throughput applications
54
+ - **Parquet Conversion**: Bidirectional conversion between Avro and Parquet formats
55
+ - **Schema Operations**: Schema extraction, validation, and evolution checking
56
+
57
+ ## Installation
58
+
59
+ ### Basic Installation
60
+
61
+ ```bash
62
+ pip install avrokit
63
+ ```
64
+
65
+ ### With Cloud Storage Support
66
+
67
+ ```bash
68
+ # AWS S3 support
69
+ pip install avrokit[aws]
70
+
71
+ # Google Cloud Storage support
72
+ pip install avrokit[gcp]
73
+
74
+ # All extras (S3 + GCS)
75
+ pip install avrokit[all]
76
+ ```
77
+
78
+ ### Development Installation
79
+
80
+ ```bash
81
+ git clone https://github.com/brandtg/avrokit.git
82
+ cd avrokit
83
+ poetry env use python3.12
84
+ make install
85
+ ```
86
+
87
+ ## Quick Start
88
+
89
+ ### CLI Usage
90
+
91
+ ```bash
92
+ # View statistics for an Avro file
93
+ avrokit stats gs://bucket/data.avro
94
+
95
+ # Convert Avro to JSON
96
+ avrokit tojson s3://bucket/data.avro > output.json
97
+
98
+ # Extract sample records
99
+ avrokit cat file:///path/to/data.avro --limit 10
100
+
101
+ # Get schema
102
+ avrokit getschema data.avro
103
+
104
+ # Convert to Parquet
105
+ avrokit toparquet data.avro output.parquet
106
+
107
+ # Concatenate multiple files
108
+ avrokit concat file1.avro file2.avro s3://bucket/file3.avro output.avro
109
+ ```
110
+
111
+ ### Python API
112
+
113
+ ```python
114
+ from avrokit import avro_reader, avro_records, avro_writer, avro_schema, parse_url
115
+
116
+ # Read records from any URL
117
+ url = parse_url('gs://bucket/data.avro', mode='rb')
118
+ for record in avro_records(url):
119
+ print(record)
120
+
121
+ # Write Avro data
122
+ schema = avro_schema({
123
+ 'type': 'record',
124
+ 'name': 'User',
125
+ 'fields': [
126
+ {'name': 'name', 'type': 'string'},
127
+ {'name': 'age', 'type': 'int'}
128
+ ]
129
+ })
130
+
131
+ url = parse_url('output.avro', mode='wb')
132
+ with avro_writer(url, schema) as writer:
133
+ writer.append({'name': 'Alice', 'age': 30})
134
+ writer.append({'name': 'Bob', 'age': 25})
135
+ ```
136
+
137
+ ## Architecture
138
+
139
+ avrokit is organized into four main layers:
140
+
141
+ ### 1. URL Layer (`avrokit.url`)
142
+
143
+ Provides a unified abstraction over different storage backends. All URL types implement the `URL` protocol with common operations:
144
+
145
+ - **`URL`** (base protocol): Abstract interface for all URL types
146
+ - **`FileURL`**: Local filesystem access with glob pattern support
147
+ - **`GCSURL`**: Google Cloud Storage via `google-cloud-storage`
148
+ - **`S3URL`**: Amazon S3 via `boto3`
149
+ - **`HTTPURL`**: HTTP/HTTPS with range request support for streaming
150
+
151
+ The `parse_url()` factory function automatically instantiates the correct URL class based on the scheme:
152
+
153
+ ```python
154
+ from avrokit.url import parse_url
155
+
156
+ # All of these return the appropriate URL subclass
157
+ url1 = parse_url('file:///path/to/data.avro') # FileURL
158
+ url2 = parse_url('gs://bucket/data.avro') # GCSURL
159
+ url3 = parse_url('s3://bucket/data.avro') # S3URL
160
+ url4 = parse_url('https://example.com/data.avro') # HTTPURL
161
+ ```
162
+
163
+ ### 2. I/O Layer (`avrokit.io`)
164
+
165
+ High-level Avro reading and writing primitives built on the URL layer:
166
+
167
+ **Reading:**
168
+
169
+ - `avro_reader(url)`: Context manager for `DataFileReader`
170
+ - `avro_records(url)`: Generator yielding records as dictionaries
171
+ - `PartitionedAvroReader`: Reads from multiple files or glob patterns as a single stream
172
+
173
+ **Writing:**
174
+
175
+ - `avro_writer(url, schema)`: Context manager for `DataFileWriter`
176
+ - `PartitionedAvroWriter`: Writes to multiple files with configurable size limits
177
+ - `TimePartitionedAvroWriter`: Time-based partitioning (e.g., hourly/daily files)
178
+
179
+ **Schema Operations:**
180
+
181
+ - `avro_schema(dict)`: Create schema from dictionary
182
+ - `read_avro_schema(url)`: Extract schema from file
183
+ - `validate_avro_schema_evolution()`: Check backward/forward compatibility
184
+ - `add_avro_schema_fields()`: Schema augmentation utilities
185
+
186
+ **Utilities:**
187
+
188
+ - `compact_avro_data()`: Remove deleted/updated records by key
189
+
190
+ ### 3. Async I/O Layer (`avrokit.asyncio`)
191
+
192
+ Non-blocking primitives for async applications:
193
+
194
+ - `DeferredAvroWriter`: Async writer that batches records and flushes in background
195
+ - `BlockingQueueAvroReader`: Queue-based async reader for producer/consumer patterns
196
+
197
+ ### 4. Tools Layer (`avrokit.tools`)
198
+
199
+ CLI commands implemented as classes following the `Tool` protocol:
200
+
201
+ | Tool | Command | Description |
202
+ | ----------------- | ------------- | ---------------------------------------------------- |
203
+ | `CatTool` | `cat` | Extract sample records with optional random sampling |
204
+ | `ConcatTool` | `concat` | Concatenate multiple Avro files into one |
205
+ | `CountTool` | `count` | Count records in files |
206
+ | `FileSortTool` | `filesort` | Sort records by key across multiple files |
207
+ | `FromParquetTool` | `fromparquet` | Convert Parquet to Avro |
208
+ | `GetMetaTool` | `getmeta` | Extract file metadata (schema, compression, etc.) |
209
+ | `GetSchemaTool` | `getschema` | Extract and print schema |
210
+ | `HttpServerTool` | `httpserver` | Serve Avro files over HTTP with filtering/sampling |
211
+ | `PartitionTool` | `partition` | Split files into multiple partitions |
212
+ | `RepairTool` | `repair` | Fix corrupted Avro files |
213
+ | `StatsTool` | `stats` | Compute statistics (count, nulls, sizes) |
214
+ | `ToJsonTool` | `tojson` | Convert to newline-delimited JSON |
215
+ | `ToParquetTool` | `toparquet` | Convert to Parquet format |
216
+
217
+ ## CLI Reference
218
+
219
+ ### Global Options
220
+
221
+ ```
222
+ avrokit --debug <command> # Enable debug logging
223
+ ```
224
+
225
+ ### Available Commands
226
+
227
+ #### cat - Extract Sample Records
228
+
229
+ ```bash
230
+ avrokit cat FILE [OPTIONS]
231
+ --limit N Maximum records to output (default: 10)
232
+ --sample-rate F Random sampling rate (0.0-1.0)
233
+ ```
234
+
235
+ #### concat - Concatenate Files
236
+
237
+ ```bash
238
+ avrokit concat INPUT1 [INPUT2 ...] OUTPUT
239
+ INPUT can be local files, GCS, S3, or HTTP URLs
240
+ OUTPUT schema must be compatible with all inputs
241
+ ```
242
+
243
+ #### count - Count Records
244
+
245
+ ```bash
246
+ avrokit count FILE [FILE ...]
247
+ Returns total record count across all files
248
+ ```
249
+
250
+ #### filesort - Sort Records
251
+
252
+ ```bash
253
+ avrokit filesort INPUT OUTPUT --keys KEY1 [KEY2 ...]
254
+ Sorts records by specified keys using external merge sort
255
+ ```
256
+
257
+ #### fromparquet - Parquet to Avro
258
+
259
+ ```bash
260
+ avrokit fromparquet INPUT.parquet OUTPUT.avro
261
+ ```
262
+
263
+ #### getmeta - File Metadata
264
+
265
+ ```bash
266
+ avrokit getmeta FILE
267
+ Outputs: schema, codec, sync marker, block count, etc.
268
+ ```
269
+
270
+ #### getschema - Extract Schema
271
+
272
+ ```bash
273
+ avrokit getschema FILE
274
+ Outputs Avro schema as JSON
275
+ ```
276
+
277
+ #### httpserver - HTTP Server
278
+
279
+ ```bash
280
+ avrokit httpserver --port 8080 --files "*.avro"
281
+ Serves Avro files with filtering and sampling support
282
+ ```
283
+
284
+ #### partition - Partition Files
285
+
286
+ ```bash
287
+ avrokit partition INPUT OUTPUT --count N
288
+ Splits INPUT into N approximately equal partitions
289
+ ```
290
+
291
+ #### repair - Fix Corrupted Files
292
+
293
+ ```bash
294
+ avrokit repair INPUT OUTPUT
295
+ Attempts to recover readable records from damaged files
296
+ ```
297
+
298
+ #### stats - Compute Statistics
299
+
300
+ ```bash
301
+ avrokit stats FILE [FILE ...]
302
+ Outputs: record count, file sizes, null counts per field
303
+ ```
304
+
305
+ #### tojson - Convert to JSON
306
+
307
+ ```bash
308
+ avrokit tojson FILE [FILE ...]
309
+ One JSON record per line (newline-delimited JSON)
310
+ ```
311
+
312
+ #### toparquet - Convert to Parquet
313
+
314
+ ```bash
315
+ avrokit toparquet INPUT.avro OUTPUT.parquet
316
+ Type mapping: Avro types → Parquet types
317
+ ```
318
+
319
+ ## Development
320
+
321
+ ### Prerequisites
322
+
323
+ - Python 3.12+
324
+ - Poetry
325
+ - Docker (for GCS/S3 integration tests)
326
+
327
+ ### Setup
328
+
329
+ ```bash
330
+ # Set up Python environment
331
+ poetry env use python3.12
332
+
333
+ # Install dependencies
334
+ make install
335
+
336
+ # Pull fake-gcs-server for testing
337
+ docker pull fsouza/fake-gcs-server
338
+ ```
339
+
340
+ ### Running Tests
341
+
342
+ ```bash
343
+ # Run all tests
344
+ make test
345
+
346
+ # Run with coverage
347
+ make test-coverage
348
+
349
+ # Run tests in parallel (default)
350
+ poetry run pytest -n auto
351
+ ```
352
+
353
+ ### Code Quality
354
+
355
+ ```bash
356
+ # Format code
357
+ make format
358
+
359
+ # Lint code
360
+ make lint
361
+
362
+ # Type checking
363
+ make typecheck
364
+
365
+ # Add license headers
366
+ make license
367
+ ```
368
+
369
+ ### Building
370
+
371
+ ```bash
372
+ make build # Build wheel and source distribution
373
+ ```
374
+
375
+ ### Releasing to PyPI
376
+
377
+ Releases are automated via GitHub Actions using [Trusted Publishing](https://docs.pypi.org/trusted-publishers/) (OIDC) - no API tokens needed.
378
+
379
+ **One-time PyPI setup:**
380
+ 1. Log into [PyPI](https://pypi.org)
381
+ 2. Go to your project → Publishing
382
+ 3. Add a new pending publisher:
383
+ - **Owner**: `brandtg`
384
+ - **Repository**: `avrokit`
385
+ - **Workflow name**: `release.yml`
386
+ 4. Save the configuration
387
+
388
+ **To release a new version:**
389
+ 1. Update version in `pyproject.toml` (e.g., `0.1.1`)
390
+ 2. Commit and push the version bump
391
+ 3. Go to GitHub → Releases → [Draft a new release](https://github.com/brandtg/avrokit/releases/new)
392
+ 4. Create a new tag matching the version (e.g., `v0.1.1`)
393
+ 5. Click **Publish release**
394
+
395
+ The GitHub Actions workflow will automatically build and publish to PyPI.
396
+
397
+ ## Python API Examples
398
+
399
+ ### Working with Partitioned Files
400
+
401
+ ```python
402
+ from avrokit import PartitionedAvroReader, PartitionedAvroWriter, parse_url
403
+
404
+ # Read from multiple files as single stream
405
+ url = parse_url('data-*.avro', mode='rb')
406
+ with PartitionedAvroReader(url) as reader:
407
+ for record in reader:
408
+ process(record)
409
+
410
+ # Write to multiple files (roll every 10000 records)
411
+ url = parse_url('output/', mode='wb')
412
+ with PartitionedAvroWriter(url, schema, max_records=10000) as writer:
413
+ for record in records:
414
+ writer.append(record)
415
+ if should_roll():
416
+ writer.roll() # Create new partition file
417
+ ```
418
+
419
+ ### Time-Based Partitioning
420
+
421
+ ```python
422
+ from avrokit import TimePartitionedAvroWriter, parse_url
423
+ from datetime import datetime
424
+
425
+ # Creates hourly files: output/2024/01/15/10.avro
426
+ url = parse_url('output/', mode='wb')
427
+ with TimePartitionedAvroWriter(
428
+ url,
429
+ schema,
430
+ time_granularity='hour',
431
+ time_field='timestamp'
432
+ ) as writer:
433
+ for record in records:
434
+ writer.append(record, timestamp=record['timestamp'])
435
+ ```
436
+
437
+ ### Async Operations
438
+
439
+ ```python
440
+ import asyncio
441
+ from avrokit.asyncio import DeferredAvroWriter
442
+ from avrokit import parse_url, avro_schema
443
+
444
+ async def write_async():
445
+ url = parse_url('output.avro', mode='wb')
446
+ schema = avro_schema({...})
447
+
448
+ async with DeferredAvroWriter(url, schema) as writer:
449
+ for record in records:
450
+ await writer.append(record)
451
+ # Flushes happen automatically in background
452
+
453
+ asyncio.run(write_async())
454
+ ```
455
+
456
+ ### Schema Evolution
457
+
458
+ ```python
459
+ from avrokit import validate_avro_schema_evolution, read_avro_schema
460
+ from avrokit.url import parse_url
461
+
462
+ # Check if new schema is backward compatible
463
+ reader_schema = read_avro_schema(parse_url('old.avro', 'rb'))
464
+ writer_schema = read_avro_schema(parse_url('new.avro', 'rb'))
465
+
466
+ is_valid = validate_avro_schema_evolution(
467
+ reader_schema,
468
+ writer_schema,
469
+ strategy='backward' # or 'forward', 'full'
470
+ )
471
+ ```
472
+
473
+ ## License
474
+
475
+ Apache-2.0 - See [LICENSE](LICENSE) for details.
476
+
477
+ ## Contributing
478
+
479
+ Contributions welcome! Please ensure:
480
+
481
+ 1. Code follows the existing style (enforced by `make format` and `make lint`)
482
+ 2. All tests pass (`make test`)
483
+ 3. Type checks pass (`make typecheck`)
484
+ 4. License headers are present (`make license`)
485
+