Skip to content
This repository was archived by the owner on Sep 26, 2020. It is now read-only.

Commit 1f38746

Browse files
committed
Add upload_dataset
1 parent 3ac8c4a commit 1f38746

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

axon/client.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import ipify
55
import webbrowser
66
import os.path
7-
import axon.progress_reporter
87

98
all_perm = {
109
"FromPort": -1,
@@ -516,6 +515,20 @@ def impl_download_training_script(local_script_path, bucket_name, region):
516515
print("Downloaded from: {}\n".format(remote_path))
517516

518517

518+
def impl_upload_dataset(local_dataset_path, bucket_name, region):
519+
"""
520+
Uploads a dataset to S3.
521+
522+
:param local_dataset_path: The path to the dataset on disk.
523+
:param bucket_name: The S3 bucket name.
524+
:param region: The region, or `None` to pull the region from the environment.
525+
"""
526+
client = make_client("s3", region)
527+
remote_path = "axon-uploaded-datasets/" + os.path.basename(local_dataset_path)
528+
client.upload_file(local_dataset_path, bucket_name, remote_path)
529+
print("Uploaded to: {}\n".format(remote_path))
530+
531+
519532
def impl_download_dataset(local_dataset_path, bucket_name, region):
520533
"""
521534
Downloads a dataset from S3.
@@ -629,3 +642,11 @@ def download_training_script(local_script_path, bucket_name, region):
629642
@click.option("--region", default="us-east-1", help="The region to connect to.")
630643
def download_dataset(local_dataset_path, bucket_name, region):
631644
impl_download_dataset(local_dataset_path, bucket_name, region)
645+
646+
647+
@cli.command(name="upload-dataset")
648+
@click.argument("local-dataset-path")
649+
@click.argument("bucket-name")
650+
@click.option("--region", default="us-east-1", help="The region to connect to.")
651+
def upload_dataset(local_dataset_path, bucket_name, region):
652+
impl_upload_dataset(local_dataset_path, bucket_name, region)

0 commit comments

Comments
 (0)