Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP,RFC] Convert Enums to Literals in schema #15774

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 36 additions & 54 deletions client/src/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1883,8 +1883,9 @@ export interface components {
* Type
* @description The type of content to be created in the history.
* @default dataset
* @enum {string}
*/
type?: components["schemas"]["HistoryContentType"];
type?: "dataset" | "dataset_collection";
};
/**
* CreateHistoryFromStore
Expand Down Expand Up @@ -3489,8 +3490,9 @@ export interface components {
/**
* Content Type
* @description The type of this item.
* @enum {string}
*/
history_content_type: components["schemas"]["HistoryContentType"];
history_content_type: "dataset" | "dataset_collection";
/**
* History ID
* @description The encoded ID of the history associated with this item.
Expand Down Expand Up @@ -3701,8 +3703,9 @@ export interface components {
/**
* Content Type
* @description The type of this item.
* @enum {string}
*/
history_content_type: components["schemas"]["HistoryContentType"];
history_content_type: "dataset" | "dataset_collection";
/**
* History ID
* @description The encoded ID of the history associated with this item.
Expand Down Expand Up @@ -3816,8 +3819,9 @@ export interface components {
/**
* Content Type
* @description The type of this item.
* @enum {string}
*/
history_content_type: components["schemas"]["HistoryContentType"];
history_content_type: "dataset" | "dataset_collection";
/**
* History ID
* @description The encoded ID of the history associated with this item.
Expand All @@ -3839,8 +3843,9 @@ export interface components {
/**
* Job Source Type
* @description The type of job (model class) that produced this dataset collection. Used to track the state of the job.
* @enum {string}
*/
job_source_type?: components["schemas"]["JobSourceType"];
job_source_type?: "Job" | "ImplicitCollectionJobs" | "WorkflowInvocation";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a big downside IMO, making reuse harder.

/**
* Job State Summary
* @description Overview of the job states working inside the dataset collection.
Expand Down Expand Up @@ -3950,8 +3955,9 @@ export interface components {
/**
* Content Type
* @description The type of this item.
* @enum {string}
*/
history_content_type: components["schemas"]["HistoryContentType"];
history_content_type: "dataset" | "dataset_collection";
/**
* History ID
* @description The encoded ID of the history associated with this item.
Expand All @@ -3973,8 +3979,9 @@ export interface components {
/**
* Job Source Type
* @description The type of job (model class) that produced this dataset collection. Used to track the state of the job.
* @enum {string}
*/
job_source_type?: components["schemas"]["JobSourceType"];
job_source_type?: "Job" | "ImplicitCollectionJobs" | "WorkflowInvocation";
/**
* Job State Summary
* @description Overview of the job states working inside the dataset collection.
Expand Down Expand Up @@ -4250,8 +4257,9 @@ export interface components {
/**
* Content Type
* @description The type of this item.
* @enum {string}
*/
history_content_type: components["schemas"]["HistoryContentType"];
history_content_type: "dataset" | "dataset_collection";
/**
* ID
* @description The encoded ID of this entity.
Expand Down Expand Up @@ -4291,12 +4299,6 @@ export interface components {
*/
total_matches: number;
};
/**
* HistoryContentType
* @description Available types of History contents.
* @enum {string}
*/
HistoryContentType: "dataset" | "dataset_collection";
/**
* HistoryContentsResult
* @description List of history content items.
Expand Down Expand Up @@ -4850,12 +4852,6 @@ export interface components {
*/
update_time: string;
};
/**
* JobIndexSortByEnum
* @description An enumeration.
* @enum {string}
*/
JobIndexSortByEnum: "create_time" | "update_time";
/**
* JobIndexViewEnum
* @description An enumeration.
Expand All @@ -4870,12 +4866,6 @@ export interface components {
*/
active: boolean;
};
/**
* JobSourceType
* @description Available types of job sources (model classes) that produce dataset collections.
* @enum {string}
*/
JobSourceType: "Job" | "ImplicitCollectionJobs" | "WorkflowInvocation";
/**
* JobStateSummary
* @description Base model definition with common configuration used by all derived models.
Expand Down Expand Up @@ -5174,12 +5164,6 @@ export interface components {
/** Total Rows */
total_rows: number;
};
/**
* LibraryFolderPermissionAction
* @description An enumeration.
* @enum {string}
*/
LibraryFolderPermissionAction: "set_permissions";
/**
* LibraryFolderPermissionsPayload
* @description Base model definition with common configuration used by all derived models.
Expand All @@ -5188,8 +5172,9 @@ export interface components {
/**
* Action
* @description Indicates what action should be performed on the library folder.
* @enum {string}
*/
action?: components["schemas"]["LibraryFolderPermissionAction"];
action?: "set_permissions";
/**
* Add IDs
* @description A list of role encoded IDs defining roles that should be able to add items to the library.
Expand Down Expand Up @@ -6496,8 +6481,10 @@ export interface components {
* - make_public: The contents of the resource will be made publicly accessible.
* - make_accessible_to_shared: This will automatically create a new `sharing role` allowing protected contents to be accessed only by the desired users.
* - no_changes: This won't change the current permissions for the contents. The user which this resource will be shared may not be able to access all its contents.
*
* @enum {string}
*/
share_option?: components["schemas"]["SharingOptions"];
share_option?: "make_public" | "make_accessible_to_shared" | "no_changes";
/**
* User Identifiers
* @description A collection of encoded IDs (or email addresses) of users that this resource will be shared with.
Expand Down Expand Up @@ -6563,12 +6550,6 @@ export interface components {
*/
users_shared_with?: components["schemas"]["UserEmail"][];
};
/**
* SharingOptions
* @description Options for sharing resources that may have restricted access to all or part of their contents.
* @enum {string}
*/
SharingOptions: "make_public" | "make_accessible_to_shared" | "no_changes";
/**
* SharingStatus
* @description Base model definition with common configuration used by all derived models.
Expand Down Expand Up @@ -6975,8 +6956,9 @@ export interface components {
/**
* Content Type
* @description The type of this item.
* @enum {string}
*/
history_content_type: components["schemas"]["HistoryContentType"];
history_content_type: "dataset" | "dataset_collection";
/**
* ID
* @description The encoded ID of this entity.
Expand Down Expand Up @@ -8881,7 +8863,7 @@ export interface operations {
parameters: {
/** @description Indicates what action should be performed on the Library. Currently only `set_permissions` is supported. */
query?: {
action?: components["schemas"]["LibraryFolderPermissionAction"];
action?: "set_permissions";
};
/** @description The user ID that will be used to effectively make this API call. Only admins and designated users can make API calls on behalf of other users. */
header?: {
Expand Down Expand Up @@ -10114,7 +10096,7 @@ export interface operations {
/** @description View to be passed to the serializer */
/** @description Comma-separated list of keys to be passed to the serializer */
query?: {
type?: components["schemas"]["HistoryContentType"];
type?: "dataset" | "dataset_collection";
view?: string;
keys?: string;
};
Expand Down Expand Up @@ -10581,7 +10563,7 @@ export interface operations {
/** @description View to be passed to the serializer */
/** @description Comma-separated list of keys to be passed to the serializer */
query?: {
type?: components["schemas"]["HistoryContentType"];
type?: "dataset" | "dataset_collection";
fuzzy_count?: number;
view?: string;
keys?: string;
Expand Down Expand Up @@ -10631,7 +10613,7 @@ export interface operations {
/** @description View to be passed to the serializer */
/** @description Comma-separated list of keys to be passed to the serializer */
query?: {
type?: components["schemas"]["HistoryContentType"];
type?: "dataset" | "dataset_collection";
view?: string;
keys?: string;
};
Expand Down Expand Up @@ -10698,7 +10680,7 @@ export interface operations {
/** @description View to be passed to the serializer */
/** @description Comma-separated list of keys to be passed to the serializer */
query?: {
type?: components["schemas"]["HistoryContentType"];
type?: "dataset" | "dataset_collection";
purge?: boolean;
recursive?: boolean;
stop_job?: boolean;
Expand Down Expand Up @@ -10888,7 +10870,7 @@ export interface operations {
/** @description The ID of the History. */
path: {
history_id: string;
type: components["schemas"]["HistoryContentType"];
type: "dataset" | "dataset_collection";
};
};
requestBody: {
Expand Down Expand Up @@ -10948,7 +10930,7 @@ export interface operations {
path: {
history_id: string;
id: string;
type: components["schemas"]["HistoryContentType"];
type: "dataset" | "dataset_collection";
};
};
responses: {
Expand Down Expand Up @@ -10992,7 +10974,7 @@ export interface operations {
path: {
history_id: string;
id: string;
type: components["schemas"]["HistoryContentType"];
type: "dataset" | "dataset_collection";
};
};
requestBody: {
Expand Down Expand Up @@ -11058,7 +11040,7 @@ export interface operations {
path: {
history_id: string;
id: string;
type: components["schemas"]["HistoryContentType"];
type: "dataset" | "dataset_collection";
};
};
requestBody?: {
Expand Down Expand Up @@ -11107,7 +11089,7 @@ export interface operations {
path: {
history_id: string;
id: string;
type: components["schemas"]["HistoryContentType"];
type: "dataset" | "dataset_collection";
};
};
responses: {
Expand Down Expand Up @@ -11140,7 +11122,7 @@ export interface operations {
path: {
history_id: string;
id: string;
type: components["schemas"]["HistoryContentType"];
type: "dataset" | "dataset_collection";
};
};
requestBody: {
Expand Down Expand Up @@ -11175,7 +11157,7 @@ export interface operations {
path: {
history_id: string;
id: string;
type: components["schemas"]["HistoryContentType"];
type: "dataset" | "dataset_collection";
};
};
requestBody: {
Expand Down Expand Up @@ -12036,7 +12018,7 @@ export interface operations {
history_id?: string;
workflow_id?: string;
invocation_id?: string;
order_by?: components["schemas"]["JobIndexSortByEnum"];
order_by?: "create_time" | "update_time";
search?: string;
limit?: number;
offset?: number;
Expand Down
12 changes: 7 additions & 5 deletions lib/galaxy/managers/histories.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
ExportObjectType,
HDABasicInfo,
ShareHistoryExtra,
ShareWithExtra,
SharingOptions,
)
from galaxy.security.validate_user_input import validate_preferred_object_store_id
from galaxy.structured_app import MinimalManagerApp
Expand Down Expand Up @@ -271,8 +273,8 @@ def queue_history_export(
return job

def get_sharing_extra_information(
self, trans, item, users: Set[model.User], errors: Set[str], option: Optional[sharable.SharingOptions] = None
) -> Optional[sharable.ShareWithExtra]:
self, trans, item, users: Set[model.User], errors: Set[str], option: Optional[SharingOptions] = None
) -> Optional[ShareWithExtra]:
"""Returns optional extra information about the datasets of the history that can be accessed by the users."""
extra = ShareHistoryExtra()
history = cast(model.History, item)
Expand All @@ -284,7 +286,7 @@ def get_sharing_extra_information(
owner_roles = owner.all_roles()
can_change_dict = {}
cannot_change_dict = {}
share_anyway = option is not None and option == sharable.SharingOptions.no_changes
share_anyway = option is not None and option == "no_changes"
datasets = history.activatable_datasets
total_dataset_count = len(datasets)
for user in users:
Expand All @@ -303,9 +305,9 @@ def get_sharing_extra_information(
and not hda.dataset.library_associations
)
if option and owner_can_manage_dataset:
if option == sharable.SharingOptions.make_accessible_to_shared:
if option == "make_accessible_to_shared":
trans.app.security_agent.privately_share_dataset(hda.dataset, users=[owner, user])
elif option == sharable.SharingOptions.make_public:
elif option == "make_public":
trans.app.security_agent.make_dataset_public(hda.dataset)
else:
hda_id = trans.security.encode_id(hda.id)
Expand Down
7 changes: 2 additions & 5 deletions lib/galaxy/managers/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@
text_column_filter,
)
from galaxy.model.scoped_session import galaxy_scoped_session
from galaxy.schema.schema import (
JobIndexQueryPayload,
JobIndexSortByEnum,
)
from galaxy.schema.schema import JobIndexQueryPayload
from galaxy.security.idencoding import IdEncodingHelper
from galaxy.structured_app import StructuredApp
from galaxy.util import (
Expand Down Expand Up @@ -200,7 +197,7 @@ def build_and_apply_filters(query, objects, filter_func):
columns.append(model.Job.job_runner_name)
query = query.filter(raw_text_column_filter(columns, term))

if payload.order_by == JobIndexSortByEnum.create_time:
if payload.order_by == "create_time":
order_by = model.Job.create_time.desc()
else:
order_by = model.Job.update_time.desc()
Expand Down
5 changes: 2 additions & 3 deletions lib/galaxy/managers/model_stores.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
ExportObjectRequestMetadata,
ExportObjectResultMetadata,
ExportObjectType,
HistoryContentType,
ShortTermStoreExportPayload,
WriteStoreToPayload,
)
Expand Down Expand Up @@ -134,7 +133,7 @@ def prepare_history_content_download(self, request: GenerateHistoryContentDownlo
with model.store.get_export_store_factory(self._app, model_store_format, export_files=export_files)(
short_term_storage_target.path
) as export_store:
if request.content_type == HistoryContentType.dataset:
if request.content_type == "dataset":
hda = self._sa_session.query(model.HistoryDatasetAssociation).get(request.content_id)
export_store.add_dataset(hda)
else:
Expand Down Expand Up @@ -196,7 +195,7 @@ def write_history_content_to(self, request: WriteHistoryContentTo):
with model.store.get_export_store_factory(
self._app, model_store_format, export_files=export_files, user_context=user_context
)(target_uri) as export_store:
if request.content_type == HistoryContentType.dataset:
if request.content_type == "dataset":
hda = self._sa_session.query(model.HistoryDatasetAssociation).get(request.content_id)
export_store.add_dataset(hda)
else:
Expand Down
2 changes: 0 additions & 2 deletions lib/galaxy/managers/sharable.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,5 @@ def create_item_slug(self, sa_session, item) -> bool:
"SharableModelFilters",
"SharableModelManager",
"SharableModelSerializer",
"SharingOptions",
"ShareWithExtra",
"SlugBuilder",
)
Loading