Skip to content

Commit

Permalink
Merge pull request #19113 from mvdbeek/stage_hashes
Browse files Browse the repository at this point in the history
Enable specifying dataset hash in test jobs
  • Loading branch information
mvdbeek authored Nov 7, 2024
2 parents 3efa4c1 + feb3747 commit 8a0fbf6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
4 changes: 1 addition & 3 deletions lib/galaxy/model/store/discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -930,9 +930,7 @@ def replace_request_syntax_sugar(obj):
new_hashes.append({"hash_function": key, "hash_value": obj[key.lower()]})
del obj[key.lower()]

if "hashes" not in obj:
obj["hashes"] = []
obj["hashes"].extend(new_hashes)
obj.setdefault("hashes", []).extend(new_hashes)


class DiscoveredFile(NamedTuple):
Expand Down
9 changes: 4 additions & 5 deletions lib/galaxy/tool_util/client/staging.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def _attach_file(upload_payload: Dict[str, Any], uri: str, index: int = 0) -> Di
dbkey=dbkey,
to_posix_lines=to_posix_lines,
decompress=upload_target.properties.get("decompress") or DEFAULT_DECOMPRESS,
hashes=upload_target.properties.get("hashes"),
)
name = _file_path_to_name(file_path)
if file_path is not None:
Expand Down Expand Up @@ -177,11 +178,7 @@ def _attach_file(upload_payload: Dict[str, Any], uri: str, index: int = 0) -> No
file_path = upload_target.path
file_type = upload_target.properties.get("filetype", None) or DEFAULT_FILE_TYPE
dbkey = upload_target.properties.get("dbkey", None) or DEFAULT_DBKEY
upload_payload = _upload_payload(
history_id,
file_type=file_type,
to_posix_lines=dbkey,
)
upload_payload = _upload_payload(history_id, file_type=file_type, to_posix_lines=dbkey)
name = _file_path_to_name(file_path)
upload_payload["inputs"]["files_0|auto_decompress"] = False
upload_payload["inputs"]["auto_decompress"] = False
Expand Down Expand Up @@ -334,6 +331,8 @@ def _fetch_payload(history_id, file_type=DEFAULT_FILE_TYPE, dbkey=DEFAULT_DBKEY,
for arg in ["to_posix_lines", "space_to_tab"]:
if arg in kwd:
element[arg] = kwd[arg]
if kwd.get("hashes"):
element["hashes"] = kwd["hashes"]
if "file_name" in kwd:
element["name"] = kwd["file_name"]
if "decompress" in kwd:
Expand Down
2 changes: 2 additions & 0 deletions lib/galaxy/tool_util/cwl/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ def replacement_file(value):
kwd["dbkey"] = value.get("dbkey")
if "decompress" in value:
kwd["decompress"] = value["decompress"]
if value.get("hashes"):
kwd["hashes"] = value["hashes"]
if composite_data_raw:
composite_data = []
for entry in composite_data_raw:
Expand Down
3 changes: 3 additions & 0 deletions lib/galaxy_test/api/test_tools_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,16 @@ def test_newlines_stage_fetch(self, history_id: str) -> None:
"class": "File",
"format": "txt",
"path": "test-data/simple_line_no_newline.txt",
"hashes": [{"hash_function": "SHA-1", "hash_value": "f030155d3459c233efd37e13bc1061c1dc744ebf"}],
}
}
inputs, datasets = stage_inputs(self.galaxy_interactor, history_id, job, use_path_paste=False)
dataset = datasets[0]
content = self.dataset_populator.get_history_dataset_content(history_id=history_id, dataset=dataset)
# By default this appends the newline.
assert content == "This is a line of text.\n"
dataset = self.dataset_populator.get_history_dataset_details(history_id, content_id=dataset["id"])
assert dataset["hashes"][0]["hash_value"] == "f030155d3459c233efd37e13bc1061c1dc744ebf"

def test_stage_object(self, history_id: str) -> None:
job = {"input1": "randomstr"}
Expand Down

0 comments on commit 8a0fbf6

Please sign in to comment.