|
11 | 11 |
|
12 | 12 | def s3_import_export():
|
13 | 13 | local_frame = h2o.import_file(path=pyunit_utils.locate("smalldata/logreg/prostate.csv"))
|
14 |
| - for scheme in ["s3a"]: # s3n is deprecated since HDP3/CDH6 |
15 |
| - timestamp = datetime.today().utcnow().strftime("%Y%m%d-%H%M%S") |
| 14 | + for scheme in ["s3a"]: # s3n is deprecated since HDP3/CDH6 |
| 15 | + timestamp = datetime.today().utcnow().strftime("%Y%m%d-%H%M%S.%f") |
16 | 16 | unique_suffix = str(uuid.uuid4())
|
17 | 17 | s3_path = scheme + "://test.0xdata.com/h2o-hadoop-tests/test-export/" + scheme + "/exported." + \
|
18 | 18 | timestamp + "." + unique_suffix + ".csv.zip"
|
19 | 19 | h2o.export_file(local_frame, s3_path)
|
| 20 | + |
| 21 | + s3 = boto3.resource('s3') |
| 22 | + client = boto3.client('s3') |
| 23 | + # S3 might have a delay in indexing the file (usually milliseconds or hundreds of milliseconds) |
| 24 | + # Wait for the file to be available, if not available in the biginning, try every 2 seconds, up to 10 times |
| 25 | + client.get_waiter('object_exists').wait(Bucket='test.0xdata.com', |
| 26 | + Key="h2o-hadoop-tests/test-export/" + scheme + "/exported." + \ |
| 27 | + timestamp + "." + unique_suffix + ".csv.zip", |
| 28 | + WaiterConfig={ |
| 29 | + 'Delay': 2, |
| 30 | + 'MaxAttempts': 10 |
| 31 | + }) |
20 | 32 | s3_frame = h2o.import_file(s3_path)
|
21 | 33 | assert_frame_equal(local_frame.as_data_frame(), s3_frame.as_data_frame())
|
22 | 34 |
|
23 |
| - #Delete the file afterwards |
24 |
| - s3 = boto3.resource('s3') |
25 | 35 | s3.Object(bucket_name='test.0xdata.com', key="h2o-hadoop-tests/test-export/" + scheme + "/exported." + \
|
26 | 36 | timestamp + "." + unique_suffix + ".csv.zip").delete()
|
27 | 37 |
|
|
0 commit comments