🎉 feat(cgns writter): add callback function to save_to_disk#478
🎉 feat(cgns writter): add callback function to save_to_disk#478tmolcard wants to merge 2 commits into
Conversation
|
Hi @tmolcard, thanks you for your contribution! Can you provide more elements to you use case. For what I understood, I'm not sure you need is really writing a plaid dataset, since you seem to want to act on the sample or modify it rather than write it to disk. The |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Hi @casenave, thank you very much for your quick review! Regarding our use case: yes, we are indeed writing a dataset. We are currently designing a very simple data pipeline that writes our data from various formats to a unified PLAID format, and in particular we do this on remote object storage. The pipeline is still very simple and early-stage: That said, I understand this might be too narrow a use case to justify changing PLAID's core. We could also work with samples and metadata using Let me know what you think! |
|
Thanks @tmolcard, that use case makes it crystal clear — and it's a legitimate one. Reading from S3 → building PLAID samples in memory → writing → uploading back, at hundreds of GB / TB scale, is exactly the case where you can't afford to materialize the whole dataset before getting control back. And you're right that To be clear on @casenave's earlier point: applying a function to Two suggestions:
Happy to keep this PR minimal (cgns + mono-proc) and track the parallel variant as a follow-up if you'd rather land something small first. Also, a small design note: exposing |
|
Regarding suggestion 2 (writing straight to remote storage): I've opened #479 to track it, so this PR can stay focused on the minimal local hook (cgns + mono-proc). The longer-term fsspec-aware |
|
Hi @tmolcard, My view is that the proposed changes are too specific to be incorporated into write_to_disk, as they target a single backend and impose constraints on num_proc. Your suggested workaround—using save_to_dir, save_problem_definitions_to_disk, and save_infos_to_disk separately for samples and metadata—seems spot-on. @xroynard has opened issue #479 to discuss a more general evolution, and you are very welcome to contribute there. It would also be valuable to document this workaround in the user documentation in another PR. With your agreement, I suggest that we close this PR. Please be assured that your interest and contribution are greatly appreciated, regardless of the outcome of this PR. Thank you! |
e89eca4 to
43eaa36
Compare
|
Thank you @xroynard for your feedback and the opening of the issue. I agree with your points :
Also about your last message @casenave, I don't know if the extension to Concerning the documentation of the workaround, it pushes PLAID's sample-directory convention onto the caller. I'd hardcode data/{split}/sample_{i:09d} myself. That's the public layout coupling @xroynard flagged. The post-write hook keeps that ownership inside PLAID. I'd be a bit hesitant to document the workaround as a recommended pattern i would rather point users to #479. That said, if it still feels too specific I'm ok with closing the PR, using the work around and contributing to the issue ! Thank you again for your time ! |
Checklist
📋 Description
Add callback function to cgns storage save_to_disk method.
Context:
We need to read datasets, process them and save them to an external object storage.
Current implementation only enables us to save the whole dataset to disk before processing it. However, when using cgns, once written, a sample remains untouched and could be processed.
This feature sends a callback after each samples is written. It lets callers process samples out (e.g. upload to object storage then delete locally) sample per sample instead of processing the whole dataset.
Currently supported for the
cgnsbackend withnum_proc == 1.