chilly-crayon-66346
07/12/2023, 3:33 PMcrooked-jordan-29960
07/12/2023, 4:08 PMself. all those pieces; instead you may want to chunk the data, then put the chunks in a cloud storage bucket or on your local disk like you suggest.chilly-crayon-66346
07/12/2023, 4:36 PMclass SomeFlow(FlowSpec):
...
@step
def some_step(self):
output_file_path = ...
function_that_produces_file(output_file_path)
with open(output_file_path, "r") as f:
self.file = f.read()
this works if the file stored in output_file_path is small enough to be read into RAM, but what should I do when it does not fit into RAM? I think chunking might help, but not really sure how to do that.crooked-jordan-29960
07/12/2023, 4:58 PMfunction_that_produces_file does?
2. What are you trying to do with the object loaded into self.file after reading it? Does the data need to get operated on together, or can you apply downstream logic to the chunks independently?
3. Does your Metaflow deployment use cloud storage at all, or is everything (flow runs, data storage, etc.) all happening locally?chilly-crayon-66346
07/12/2023, 5:16 PMcrooked-jordan-29960
07/12/2023, 6:17 PMfunction_that_produces_file? Your original idea about chunking these files on disk so they don't all need to simultaneously be in memory within that function is what I'd start with. If you have a sensible dimension in the data you can split on (chunk N is between dates X_n and Y_n, for example), thats a good place to start.
Given the eventual move to cloud storage:
• The chunking pattern has huge benefits in this context, especially when downstream processing of the chunks can be done in parallel tasks within in a Metaflow foreach.
• We wrote a post about "fast data" with .parquet data, which might be of interest. Lmk if you want to chat on a call sometime about details of your use case how we can apply and extend this pattern for it.crooked-jordan-29960
07/12/2023, 6:20 PMfunction_that_produces_file to account for. If you load the first JSON, can you produce one chunk at a time, write it to disk, and delete the in-memory version to free space?