MCPcopy Create free account
hub / github.com/feast-dev/feast / upload_df_to_s3

Function upload_df_to_s3

sdk/python/feast/infra/utils/aws_utils.py:186–211  ·  view source on GitHub ↗

Uploads a Pandas DataFrame to S3 as a parquet file Args: s3_resource: S3 Resource object s3_path: S3 path where the Parquet file is temporarily uploaded df: The Pandas DataFrame to upload Returns: None

(
    s3_resource,
    s3_path: str,
    df: pd.DataFrame,
)

Source from the content-addressed store, hash-verified

184
185
186def upload_df_to_s3(
187 s3_resource,
188 s3_path: str,
189 df: pd.DataFrame,
190) -> None:
191 """Uploads a Pandas DataFrame to S3 as a parquet file
192
193 Args:
194 s3_resource: S3 Resource object
195 s3_path: S3 path where the Parquet file is temporarily uploaded
196 df: The Pandas DataFrame to upload
197
198 Returns: None
199
200 """
201 bucket, key = get_bucket_and_key(s3_path)
202
203 # Drop the index so that we dont have unnecessary columns
204 df.reset_index(drop=True, inplace=True)
205
206 table = pa.Table.from_pandas(df)
207 # Write the PyArrow Table on disk in Parquet format and upload it to S3
208 with tempfile.TemporaryDirectory() as temp_dir:
209 file_path = f"{temp_dir}/{uuid.uuid4()}.parquet"
210 pq.write_table(table, file_path)
211 s3_resource.Object(bucket, key).put(Body=open(file_path, "rb"))
212
213
214def upload_df_to_redshift(

Callers

nothing calls this directly

Calls 4

get_bucket_and_keyFunction · 0.85
write_tableMethod · 0.80
putMethod · 0.80
from_pandasMethod · 0.45

Tested by

no test coverage detected