Skip to content

Commit 66771bd

Browse files
fix(closes OPEN-12012): upload batch inferences presigned URL bug
1 parent bf22b28 commit 66771bd

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

‎src/openlayer/lib/data/batch_inferences.py‎

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,19 @@ def upload_batch_inferences(
4242

4343
# Write dataset and config to temp directory
4444
with tempfile.TemporaryDirectory() as tmp_dir:
45-
# If DataFrame is provided, convert it to Arrow Table and write it using IPC
46-
# writer
47-
if dataset_df is not None:
48-
temp_file_path = f"{tmp_dir}/dataset.arrow"
49-
pa_table = pa.Table.from_pandas(dataset_df)
50-
pa_schema = pa_table.schema
51-
52-
with pa.ipc.RecordBatchStreamWriter(temp_file_path, pa_schema) as writer:
53-
writer.write_table(pa_table, max_chunksize=16384)
54-
else:
55-
object_name = f"batch_data_{time.time()}_{inference_pipeline_id}.csv"
56-
temp_file_path = dataset_path
45+
# Both inputs are uploaded as an Arrow IPC stream. The object key is already
46+
# committed to `.arrow` by the presigned URL above, and the backend dispatches
47+
# on that extension when it reads the batch back — so a CSV has to be
48+
# converted here rather than uploaded as-is.
49+
if dataset_df is None:
50+
dataset_df = pd.read_csv(dataset_path)
51+
52+
temp_file_path = f"{tmp_dir}/dataset.arrow"
53+
pa_table = pa.Table.from_pandas(dataset_df)
54+
pa_schema = pa_table.schema
55+
56+
with pa.ipc.RecordBatchStreamWriter(temp_file_path, pa_schema) as writer:
57+
writer.write_table(pa_table, max_chunksize=16384)
5758

5859
# camelCase the config
5960
config = maybe_transform(config, data_stream_params.Config)

0 commit comments

Comments
 (0)