Skip to content

Commit

Permalink
Replace redundant HashFunctionNames with HashFunctionNameEnum
Browse files Browse the repository at this point in the history
And fix a typo.
  • Loading branch information
nsoranzo committed Nov 19, 2024
1 parent ead2d84 commit 00d9f64
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
12 changes: 2 additions & 10 deletions lib/galaxy/schema/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
OffsetNaiveDatetime,
RelativeUrl,
)
from galaxy.util.hash_util import HashFunctionNameEnum
from galaxy.util.sanitize_html import sanitize_html

USER_MODEL_CLASS = Literal["User"]
Expand Down Expand Up @@ -121,15 +122,6 @@ class DatasetCollectionPopulatedState(str, Enum):
FAILED = "failed" # some problem populating state, won't be populated


class HashFunctionNames(str, Enum):
"""Hash function names that can be used to generate checksums for datasets."""

md5 = "MD5"
sha1 = "SHA-1"
sha256 = "SHA-256"
sha512 = "SHA-512"


# Generic and common Field annotations that can be reused across models

RelativeUrlField = Annotated[
Expand Down Expand Up @@ -733,7 +725,7 @@ class DatasetHash(Model):
title="ID",
description="Encoded ID of the dataset hash.",
)
hash_function: HashFunctionNames = Field(
hash_function: HashFunctionNameEnum = Field(
...,
title="Hash Function",
description="The hash function used to generate the hash.",
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/util/hash_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@


class HashFunctionNameEnum(str, Enum):
"""Particular pieces of information that can be requested for a dataset."""
"""Hash function names that can be used to generate checksums for files."""

md5 = "MD5"
sha1 = "SHA-1"
Expand Down
4 changes: 2 additions & 2 deletions lib/galaxy/webapps/galaxy/services/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,11 +537,11 @@ def get_drs_object(self, trans: ProvidesHistoryContext, object_id: str, request_
checksums.append(Checksum(type=type, checksum=checksum))

if len(checksums) == 0:
hash_funciton = HashFunctionNameEnum.md5
hash_function = HashFunctionNameEnum.md5
request = ComputeDatasetHashTaskRequest(
dataset_id=dataset_instance.dataset.id,
extra_files_path=None,
hash_function=hash_funciton,
hash_function=hash_function,
user=None,
)
compute_dataset_hash.delay(request=request, task_user_id=getattr(trans.user, "id", None))
Expand Down

0 comments on commit 00d9f64

Please sign in to comment.