13
13
from __future__ import absolute_import
14
14
15
15
import gzip
16
- import io
17
16
import json
18
17
import os
19
18
import pickle
20
19
import sys
21
20
import time
22
21
23
- import boto3
24
22
import numpy as np
25
23
import pytest
26
24
@@ -368,6 +366,7 @@ def test_tuning_byo_estimator(sagemaker_session):
368
366
Default predictor is updated with json serializer and deserializer.
369
367
"""
370
368
image_name = registry (sagemaker_session .boto_session .region_name ) + '/factorization-machines:1'
369
+ training_data_path = os .path .join (DATA_DIR , 'dummy_tensor' )
371
370
372
371
with timeout (minutes = 15 ):
373
372
data_path = os .path .join (DATA_DIR , 'one_p_mnist' , 'mnist.pkl.gz' )
@@ -376,19 +375,10 @@ def test_tuning_byo_estimator(sagemaker_session):
376
375
with gzip .open (data_path , 'rb' ) as f :
377
376
train_set , _ , _ = pickle .load (f , ** pickle_args )
378
377
379
- # take 100 examples for faster execution
380
- vectors = np .array ([t .tolist () for t in train_set [0 ][:100 ]]).astype ('float32' )
381
- labels = np .where (np .array ([t .tolist () for t in train_set [1 ][:100 ]]) == 0 , 1.0 , 0.0 ).astype ('float32' )
382
-
383
- buf = io .BytesIO ()
384
- write_numpy_to_dense_tensor (buf , vectors , labels )
385
- buf .seek (0 )
386
-
387
- bucket = sagemaker_session .default_bucket ()
388
378
prefix = 'test_byo_estimator'
389
379
key = 'recordio-pb-data'
390
- boto3 . resource ( 's3' ). Bucket ( bucket ). Object ( os . path . join ( prefix , 'train' , key )). upload_fileobj ( buf )
391
- s3_train_data = 's3://{}/{}/ train/{}' . format ( bucket , prefix , key )
380
+ s3_train_data = sagemaker_session . upload_data ( path = training_data_path ,
381
+ key_prefix = os . path . join ( prefix , ' train' , key ) )
392
382
393
383
estimator = Estimator (image_name = image_name ,
394
384
role = 'SageMakerRole' , train_instance_count = 1 ,
0 commit comments