Skip to content
This repository has been archived by the owner on Jul 24, 2020. It is now read-only.

Commit

Permalink
Merge pull request #118 from jmchilton/uri_test_data
Browse files Browse the repository at this point in the history
Allow URIs in test data inputs.
  • Loading branch information
jmchilton committed May 22, 2018
2 parents da3497c + 87c4ec6 commit 02d9f7f
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions galaxy/tools/cwl/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,24 @@ def _handle_pseudo_location(properties, pseduo_location):
properties["location"] = properties["basename"]


def abs_path_or_uri(path_or_uri, relative_to):
"""Return an absolute path if this isn't a URI, otherwise keep the URI the same.
"""
is_uri = "://" in path_or_uri
if not is_uri and not os.path.isabs(path_or_uri):
path_or_uri = os.path.join(relative_to, path_or_uri)
if not is_uri:
_ensure_file_exists(path_or_uri)
return path_or_uri


def path_or_uri_to_uri(path_or_uri):
if "://" not in path_or_uri:
return "file://%s" % path_or_uri
else:
return path_or_uri


def galactic_job_json(
job, test_data_directory, upload_func, collection_create_func, tool_or_workflow="workflow"
):
Expand All @@ -74,9 +92,7 @@ def galactic_job_json(
dataset_collections = []

def upload_file(file_path, secondary_files):
if not os.path.isabs(file_path):
file_path = os.path.join(test_data_directory, file_path)
_ensure_file_exists(file_path)
file_path = abs_path_or_uri(file_path, test_data_directory)
target = FileUploadTarget(file_path, secondary_files)
upload_response = upload_func(target)
dataset = upload_response["outputs"][0]
Expand All @@ -85,9 +101,7 @@ def upload_file(file_path, secondary_files):
return {"src": "hda", "id": dataset_id}

def upload_tar(file_path):
if not os.path.isabs(file_path):
file_path = os.path.join(test_data_directory, file_path)
_ensure_file_exists(file_path)
file_path = abs_path_or_uri(file_path, test_data_directory)
target = DirectoryUploadTarget(file_path)
upload_response = upload_func(target)
dataset = upload_response["outputs"][0]
Expand Down

0 comments on commit 02d9f7f

Please sign in to comment.