1
1
"""Upload a batch of inferences to the Openlayer platform."""
2
2
3
3
import os
4
+ import time
5
+ import shutil
4
6
import tarfile
5
7
import tempfile
6
- import time
7
8
from typing import Optional
8
9
9
10
import httpx
10
11
import pandas as pd
11
12
13
+ from . import StorageType , _upload
14
+ from .. import utils
12
15
from ... import Openlayer
13
16
from ..._utils import maybe_transform
14
17
from ...types .inference_pipelines import data_stream_params
15
- from .. import utils
16
- from . import StorageType , _upload
17
18
18
19
19
20
def upload_batch_inferences (
@@ -41,11 +42,11 @@ def upload_batch_inferences(
41
42
42
43
# Write dataset and config to temp directory
43
44
with tempfile .TemporaryDirectory () as tmp_dir :
45
+ temp_file_path = f"{ tmp_dir } /dataset.csv"
44
46
if dataset_df is not None :
45
- temp_file_path = f"{ tmp_dir } /dataset.csv"
46
47
dataset_df .to_csv (temp_file_path , index = False )
47
48
else :
48
- temp_file_path = dataset_path
49
+ shutil . copy ( dataset_path , temp_file_path )
49
50
50
51
# Copy relevant files to tmp dir
51
52
config ["label" ] = "production"
@@ -56,11 +57,7 @@ def upload_batch_inferences(
56
57
57
58
tar_file_path = os .path .join (tmp_dir , object_name )
58
59
with tarfile .open (tar_file_path , mode = "w:gz" ) as tar :
59
- tar .add (temp_file_path , arcname = os .path .basename ("dataset.csv" ))
60
- tar .add (
61
- f"{ tmp_dir } /dataset_config.yaml" ,
62
- arcname = os .path .basename ("dataset_config.yaml" ),
63
- )
60
+ tar .add (tmp_dir , arcname = os .path .basename ("monitoring_data" ))
64
61
65
62
# Upload to storage
66
63
uploader .upload (
0 commit comments