Skip to content

Commit

Permalink
Upload tool input test data directly from URL
Browse files Browse the repository at this point in the history
  • Loading branch information
davelopez committed Jun 28, 2023
1 parent 6c7c94f commit 4a47efa
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions lib/galaxy/tool_util/verify/interactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,15 +556,24 @@ def stage_data_async(
)
name = test_data["name"]
else:
name = os.path.basename(fname)
file_name = None
file_name_exists = False
location = self._ensure_valid_location_in(test_data)
if fname:
file_name = self.test_data_path(tool_id, fname, tool_version=tool_version)
file_name_exists = os.path.exists(f"{file_name}")
upload_from_location = not file_name_exists and location is not None
name = os.path.basename(location if upload_from_location else fname)
tool_input.update(
{
"files_0|NAME": name,
"files_0|type": "upload_dataset",
}
)
files = {}
if force_path_paste:
if upload_from_location:
tool_input.update({"files_0|url_paste": location})
elif force_path_paste:
file_name = self.test_data_path(tool_id, fname, tool_version=tool_version)
tool_input.update({"files_0|url_paste": f"file://{file_name}"})
else:
Expand All @@ -589,6 +598,13 @@ def stage_data_async(
assert len(jobs) > 0, f"Invalid response from server [{submit_response}], expecting a job."
return lambda: self.wait_for_job(jobs[0]["id"], history_id, maxseconds=maxseconds)

def _ensure_valid_location_in(self, test_data: dict) -> Optional[str]:
location: Optional[str] = test_data.get("location")
has_valid_location = location and util.is_url(location)
if location and not has_valid_location:
raise ValueError(f"Invalid `location` URL: `{location}`")
return location

def run_tool(self, testdef, history_id, resource_parameters=None) -> RunToolResponse:
# We need to handle the case where we've uploaded a valid compressed file since the upload
# tool will have uncompressed it on the fly.
Expand Down

0 comments on commit 4a47efa

Please sign in to comment.