peridotml opened a new pull request, #23030:
URL: https://github.com/apache/beam/pull/23030
This is related to #22813. @TheNeuralBit I put up a draft. Let me know if
this still would be worth adding to the sdk or if there is way to do this
already.
This is an example of the pipeline:
```python
with TestPipeline() as p:
_ = p \
| RunInference(...) \
| BatchToArrowTable() \ # turns a dict of vectors into a pa.Table,
# e.g. {'id': [1, 2, 3], 'score': [0.9, 0.1,
0.8]} -> pa.Table
| WriteToParquetBatched(
path, self.SCHEMA, num_shards=1, shard_name_template='')
```
### Motivation
* Don't need to un-batch into a series of python dicts, which hurts
performance.
* Models naturally return batches, so it works
* I didn't add it in yet, but you can infer the schema from the first batch
(possibly will break something, but worked with dataflow)
### Open Questions
1. Controlling `row_group_size` would need to be handled upstream
2. A lot of duplicate code. Possibly some smart ways to refactor a bit (let
me know)
------------------------
Thank you for your contribution! Follow this checklist to help us
incorporate your contribution quickly and easily:
- [ ] [**Choose
reviewer(s)**](https://beam.apache.org/contribute/#make-your-change) and
mention them in a comment (`R: @username`).
- [ ] Mention the appropriate issue in your description (for example:
`addresses #123`), if applicable. This will automatically add a link to the
pull request in the issue. If you would like the issue to automatically close
on merging the pull request, comment `fixes #<ISSUE NUMBER>` instead.
- [ ] Update `CHANGES.md` with noteworthy changes.
- [ ] If this contribution is large, please file an Apache [Individual
Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
See the [Contributor Guide](https://beam.apache.org/contribute) for more
tips on [how to make review process
smoother](https://beam.apache.org/contribute/get-started-contributing/#make-the-reviewers-job-easier).
To check the build health, please visit
[https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md](https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md)
GitHub Actions Tests Status (on master branch)
------------------------------------------------------------------------------------------------
[](https://github.com/apache/beam/actions?query=workflow%3A%22Build+python+source+distribution+and+wheels%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Python+Tests%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Java+Tests%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Go+tests%22+branch%3Amaster+event%3Aschedule)
See [CI.md](https://github.com/apache/beam/blob/master/CI.md) for more
information about GitHub Actions CI.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]