red-fountain-16335
12/03/2022, 2:53 PMself.df = df, it seems to spike the memory usage!
I have already increased the @resource to use 30Gb memory and it is still failing with OutOfMemory error.
Funny enough, I can run the flow locally and it almost bricks my computer, but it does complete fine. The laptop only has 16Gb ram and had other programs running, such as Chrome, Teams, Outlook etc.
Note: the dataframe.info() shows usage of about 3Gb, for ~7 million rows with 100+ columns.
It feels like storing artifact is causing duplication of memory instead of just pointing to the variable reference.
Am I missing something? Is there a best practice/pattern to follow?
My flow is defined as the following steps:
1. Start: pandas.read_sql with a simple select * from … Snowflake
2. Transform: applies additional feature engineering, such as one hot encoding (get_dummies) -> it runs fine, running out of memory on the last part where I store it as class attribute to be used on subsequent steps
3. Train Models in parallel
4. Select best model and store it as artifactstraight-shampoo-11124
12/03/2022, 9:51 PMstraight-shampoo-11124
12/03/2022, 9:54 PM@resources enough (even @resources(memory=64000) ) so you can confirm that there's some amount that makes it succeed.straight-shampoo-11124
12/03/2022, 9:55 PMself.df = df , do self.df = to_parquetbytes(df)straight-shampoo-11124
12/03/2022, 9:56 PMpyarrow package installed. You can include it in your Docker image or use @conda)straight-shampoo-11124
12/03/2022, 10:01 PMstraight-shampoo-11124
12/03/2022, 10:01 PMred-fountain-16335
12/04/2022, 10:37 AMdf.read_sql querying Snowflake performed muuuuch better than the alternative:
a. Snowflake to S3, using a COPY INTO data_type=parquet
b. Using the metaflow.S3.get_recursive / or just using pyarrow’s <http://dataset.to|dataset.to>_table(usethreads=True)
c. Finally, converting the parquet table into a dataframe df = <http://table.to|table.to>_pandas(split_blocks=True, self_destruct=True)
I am trying to shove most data transformation to the data-warehouse side, so the Metaflow Flow becomes simpler and can leverage the benefits of pyarrow.
But it requires a whole lot of effort, whereas the idea was to move quick from prototype (Notebook) to production (running on a schedule with Step Functions)
I like the to_parquetbytes /`to_pandas` idea. I will give it a try.
I am trying to optimise the developer experience, making it super easy to onboard new users - which means minimising extra details to be learned.
But this sounds like a feasible compromise 👍
🤔 The only thing that still bugs me is that the actual Flow completed successfully in my local Mac (with only 16Gb ram while running other programs), but looking at the resource usage in AWS I can see mega spikes going from 10 to 20+ Gb)red-fountain-16335
12/04/2022, 10:39 AMred-fountain-16335
12/04/2022, 2:06 PMvictorious-lawyer-58417
12/05/2022, 3:18 AMambitious-bird-15073
12/05/2022, 12:43 PMred-fountain-16335
12/05/2022, 12:56 PMambitious-bird-15073
12/06/2022, 1:41 AMcurved-island-17262
02/20/2023, 6:59 AMred-fountain-16335
02/27/2023, 8:06 AM