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 ad1ef0f commit e69eec0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 21 deletions.
10 changes: 2 additions & 8 deletions client/src/api/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7982,7 +7982,7 @@ export interface components {
* Hash Function
* @description The hash function used to generate the hash.
*/
hash_function: components["schemas"]["HashFunctionNames"];
hash_function: components["schemas"]["HashFunctionNameEnum"];
/**
* Hash Value
* @description The hash value.
Expand Down Expand Up @@ -10848,16 +10848,10 @@ export interface components {
};
/**
* HashFunctionNameEnum
* @description Particular pieces of information that can be requested for a dataset.
* @description Hash function names that can be used to generate checksums for files.
* @enum {string}
*/
HashFunctionNameEnum: "MD5" | "SHA-1" | "SHA-256" | "SHA-512";
/**
* HashFunctionNames
* @description Hash function names that can be used to generate checksums for datasets.
* @enum {string}
*/
HashFunctionNames: "MD5" | "SHA-1" | "SHA-256" | "SHA-512";
/** HdaDestination */
HdaDestination: {
/**
Expand Down
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 e69eec0

Please sign in to comment.