Skip to content

Commit

Permalink
Refactor input back to filename as it causes issues in cloud API.
Browse files Browse the repository at this point in the history
  • Loading branch information
VJalili committed Aug 3, 2018
1 parent df28396 commit 4b7615e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions tools/cloud/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ def load_credential(credentials_file):
return json.loads(credentials)


def download(provider, credentials_file, bucket, object_label, input, overwrite_existing):
if not os.path.exists(input):
raise Exception("The file `{}` does not exist.".format(input))
def download(provider, credentials_file, bucket, object_label, filename, overwrite_existing):
if not os.path.exists(filename):
raise Exception("The file `{}` does not exist.".format(filename))
credentials = load_credential(credentials_file)
if CloudProviderFactory is None:
raise Exception(NO_CLOUDBRIDGE_ERROR_MESSAGE)
Expand All @@ -43,7 +43,7 @@ def download(provider, credentials_file, bucket, object_label, input, overwrite_
if overwrite_existing is False and bucket_obj.get(object_label) is not None:
object_label += "-" + datetime.datetime.now().strftime("%y-%m-%d-%H-%M-%S")
created_obj = bucket_obj.create_object(object_label)
created_obj.upload_from_file(input)
created_obj.upload_from_file(filename)

def __main__():
parser = argparse.ArgumentParser()
Expand Down Expand Up @@ -73,8 +73,8 @@ def __main__():
"the data to be persisted",
required=True)

parser.add_argument('-i',
'--input',
parser.add_argument('-f',
'--filename',
type=str,
help="The (absolute) filename of the data to be persisted on the "
"cloud-based storage",
Expand All @@ -90,7 +90,7 @@ def __main__():

args = parser.parse_args(sys.argv[1:])
overwrite_existing = args.overwrite_existing.lower() == "true"
download(args.provider, args.credentials_file, args.bucket, args.object_label, args.input, overwrite_existing)
download(args.provider, args.credentials_file, args.bucket, args.object_label, args.filename, overwrite_existing)

if __name__ == "__main__":
sys.exit(__main__())
4 changes: 2 additions & 2 deletions tools/cloud/download.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
</requirements>
<command interpreter="python">
download.py
--input=$input
--input=$filename
--provider=$provider
--credentials_file=$credentials_file
--bucket=$bucket
--object_label=$object_label
--overwrite_existing=$overwrite_existing
</command>
<inputs>
<param name="input" type="data" label="Datasets to be downloaded to a cloud-based storage:" />
<param name="filename" type="data" label="Datasets to be downloaded to a cloud-based storage:" />
<param name="provider" label="Provider" type="select">
<option value="aws">Amazon Simple Storage Service (S3)</option>
<option value="azure">Microsoft Azure Blob Storage</option>
Expand Down

0 comments on commit 4b7615e

Please sign in to comment.