Skip to content

Commit

Permalink
Apply suggestions: s/title/description in schema, don't do try/except…
Browse files Browse the repository at this point in the history
… in delete logic, rename type aliases for consistency
  • Loading branch information
arash77 committed Oct 1, 2024
1 parent 2a5790d commit 20bd8fb
Show file tree
Hide file tree
Showing 4 changed files with 152 additions and 114 deletions.
112 changes: 78 additions & 34 deletions client/src/api/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12942,49 +12942,64 @@ export interface components {
/** the type of collection to create */
collection_type: string;
/**
* if True, copy the elements into the collection
* Copy Elements
* @description if True, copy the elements into the collection
* @default false
*/
copy_elements: boolean;
/** the type of item to create */
/** @description the type of item to create */
create_type: components["schemas"]["CreateType"];
/** list of dictionaries containing the element identifiers for the collection */
element_identifiers: Record<string, never>[];
/** sub-dictionary containing any extended metadata to associate with the item */
/**
* Extended Metadata
* @description sub-dictionary containing any extended metadata to associate with the item
*/
extended_metadata?: Record<string, never> | null;
/**
* the encoded id of the parent folder of the new item
* Folder Id
* @description the encoded id of the parent folder of the new item
* @example 0123456789ABCDEF
*/
folder_id: string;
/** (only if create_type is 'file') the encoded id of an accessible HDA to copy into the library */
/**
* From Hda Id
* @description (only if create_type is 'file') the encoded id of an accessible HDA to copy into the library
*/
from_hda_id?: string | null;
/** (only if create_type is 'file') the encoded id of an accessible HDCA to copy into the library */
/**
* From Hdca Id
* @description (only if create_type is 'file') the encoded id of an accessible HDCA to copy into the library
*/
from_hdca_id?: string | null;
/**
* if True, hide the source items in the collection
* Hide Source Items
* @description if True, hide the source items in the collection
* @default false
*/
hide_source_items: boolean;
/**
* the new message attribute of the LDDA created
* Ldda Message
* @description the new message attribute of the LDDA created
* @default
*/
ldda_message: string;
/** the name of the collection */
name?: string | null;
/**
* create tags on datasets using the file's original name
* Tag Using Filenames
* @description create tags on datasets using the file's original name
* @default false
*/
tag_using_filenames: boolean;
/**
* create the given list of tags on datasets
* Tags
* @description create the given list of tags on datasets
* @default []
*/
tags: string[];
/**
* the method to use for uploading files
* @description the method to use for uploading files
* @default upload_file
*/
upload_option: components["schemas"]["UploadOption"];
Expand Down Expand Up @@ -13070,7 +13085,8 @@ export interface components {
/** LibraryContentsDeletePayload */
LibraryContentsDeletePayload: {
/**
* if True, purge the library dataset
* Purge
* @description if True, purge the library dataset
* @default false
*/
purge: boolean;
Expand All @@ -13087,38 +13103,50 @@ export interface components {
};
/** LibraryContentsFileCreatePayload */
LibraryContentsFileCreatePayload: {
/** the type of item to create */
/** @description the type of item to create */
create_type: components["schemas"]["CreateType"];
/**
* database key
* @default ?
*/
dbkey: string | unknown[];
/** sub-dictionary containing any extended metadata to associate with the item */
/**
* Extended Metadata
* @description sub-dictionary containing any extended metadata to associate with the item
*/
extended_metadata?: Record<string, never> | null;
/** file type */
file_type?: string | null;
/**
* (only if upload_option is 'upload_paths' and the user is an admin) file paths on the Galaxy server to upload to the library, one file per line
* Filesystem Paths
* @description (only if upload_option is 'upload_paths' and the user is an admin) file paths on the Galaxy server to upload to the library, one file per line
* @default
*/
filesystem_paths: string;
/**
* the encoded id of the parent folder of the new item
* Folder Id
* @description the encoded id of the parent folder of the new item
* @example 0123456789ABCDEF
*/
folder_id: string;
/** (only if create_type is 'file') the encoded id of an accessible HDA to copy into the library */
/**
* From Hda Id
* @description (only if create_type is 'file') the encoded id of an accessible HDA to copy into the library
*/
from_hda_id?: string | null;
/** (only if create_type is 'file') the encoded id of an accessible HDCA to copy into the library */
/**
* From Hdca Id
* @description (only if create_type is 'file') the encoded id of an accessible HDCA to copy into the library
*/
from_hdca_id?: string | null;
/**
* the new message attribute of the LDDA created
* Ldda Message
* @description the new message attribute of the LDDA created
* @default
*/
ldda_message: string;
/**
* (only when upload_option is 'upload_directory' or 'upload_paths').Setting to 'link_to_files' symlinks instead of copying the files
* @description (only when upload_option is 'upload_directory' or 'upload_paths').Setting to 'link_to_files' symlinks instead of copying the files
* @default copy_files
*/
link_data_only: components["schemas"]["LinkDataOnly"];
Expand All @@ -13128,27 +13156,30 @@ export interface components {
*/
roles: string;
/**
* (only if upload_option is 'upload_directory') relative path of the subdirectory of Galaxy ``library_import_dir`` (if admin) or ``user_library_import_dir`` (if non-admin) to upload. All and only the files (i.e. no subdirectories) contained in the specified directory will be uploaded.
* Server Dir
* @description (only if upload_option is 'upload_directory') relative path of the subdirectory of Galaxy ``library_import_dir`` (if admin) or ``user_library_import_dir`` (if non-admin) to upload. All and only the files (i.e. no subdirectories) contained in the specified directory will be uploaded.
* @default
*/
server_dir: string;
/**
* create tags on datasets using the file's original name
* Tag Using Filenames
* @description create tags on datasets using the file's original name
* @default false
*/
tag_using_filenames: boolean;
/**
* create the given list of tags on datasets
* Tags
* @description create the given list of tags on datasets
* @default []
*/
tags: string[];
/**
* list of dictionaries containing the uploaded file fields
* list of the uploaded files
* @default []
*/
upload_files: Record<string, never>[];
/**
* the method to use for uploading files
* @description the method to use for uploading files
* @default upload_file
*/
upload_option: components["schemas"]["UploadOption"];
Expand All @@ -13159,26 +13190,37 @@ export interface components {
};
/** LibraryContentsFolderCreatePayload */
LibraryContentsFolderCreatePayload: {
/** the type of item to create */
/** @description the type of item to create */
create_type: components["schemas"]["CreateType"];
/**
* description of the folder to create
* @default
*/
description: string;
/** sub-dictionary containing any extended metadata to associate with the item */
/**
* Extended Metadata
* @description sub-dictionary containing any extended metadata to associate with the item
*/
extended_metadata?: Record<string, never> | null;
/**
* the encoded id of the parent folder of the new item
* Folder Id
* @description the encoded id of the parent folder of the new item
* @example 0123456789ABCDEF
*/
folder_id: string;
/** (only if create_type is 'file') the encoded id of an accessible HDA to copy into the library */
/**
* From Hda Id
* @description (only if create_type is 'file') the encoded id of an accessible HDA to copy into the library
*/
from_hda_id?: string | null;
/** (only if create_type is 'file') the encoded id of an accessible HDCA to copy into the library */
/**
* From Hdca Id
* @description (only if create_type is 'file') the encoded id of an accessible HDCA to copy into the library
*/
from_hdca_id?: string | null;
/**
* the new message attribute of the LDDA created
* Ldda Message
* @description the new message attribute of the LDDA created
* @default
*/
ldda_message: string;
Expand All @@ -13188,17 +13230,19 @@ export interface components {
*/
name: string;
/**
* create tags on datasets using the file's original name
* Tag Using Filenames
* @description create tags on datasets using the file's original name
* @default false
*/
tag_using_filenames: boolean;
/**
* create the given list of tags on datasets
* Tags
* @description create the given list of tags on datasets
* @default []
*/
tags: string[];
/**
* the method to use for uploading files
* @description the method to use for uploading files
* @default upload_file
*/
upload_option: components["schemas"]["UploadOption"];
Expand Down
42 changes: 21 additions & 21 deletions lib/galaxy/schema/library_contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,39 +52,39 @@ class LinkDataOnly(str, Enum):
class LibraryContentsCreatePayload(Model):
create_type: CreateType = Field(
...,
title="the type of item to create",
description="the type of item to create",
)
upload_option: UploadOption = Field(
UploadOption.upload_file,
title="the method to use for uploading files",
description="the method to use for uploading files",
)
folder_id: LibraryFolderDatabaseIdField = Field(
...,
title="the encoded id of the parent folder of the new item",
description="the encoded id of the parent folder of the new item",
)
tag_using_filenames: bool = Field(
False,
title="create tags on datasets using the file's original name",
description="create tags on datasets using the file's original name",
)
tags: List[str] = Field(
[],
title="create the given list of tags on datasets",
description="create the given list of tags on datasets",
)
from_hda_id: Optional[DecodedDatabaseIdField] = Field(
None,
title="(only if create_type is 'file') the encoded id of an accessible HDA to copy into the library",
description="(only if create_type is 'file') the encoded id of an accessible HDA to copy into the library",
)
from_hdca_id: Optional[DecodedDatabaseIdField] = Field(
None,
title="(only if create_type is 'file') the encoded id of an accessible HDCA to copy into the library",
description="(only if create_type is 'file') the encoded id of an accessible HDCA to copy into the library",
)
ldda_message: str = Field(
"",
title="the new message attribute of the LDDA created",
description="the new message attribute of the LDDA created",
)
extended_metadata: Optional[Dict[str, Any]] = Field(
None,
title="sub-dictionary containing any extended metadata to associate with the item",
description="sub-dictionary containing any extended metadata to associate with the item",
)

@field_validator("tags", mode="before", check_fields=False)
Expand All @@ -110,20 +110,20 @@ class LibraryContentsFileCreatePayload(LibraryContentsCreatePayload):
)
server_dir: str = Field(
"",
title="(only if upload_option is 'upload_directory') relative path of the "
description="(only if upload_option is 'upload_directory') relative path of the "
"subdirectory of Galaxy ``library_import_dir`` (if admin) or "
"``user_library_import_dir`` (if non-admin) to upload. "
"All and only the files (i.e. no subdirectories) contained "
"in the specified directory will be uploaded.",
)
filesystem_paths: str = Field(
"",
title="(only if upload_option is 'upload_paths' and the user is an admin) "
description="(only if upload_option is 'upload_paths' and the user is an admin) "
"file paths on the Galaxy server to upload to the library, one file per line",
)
link_data_only: LinkDataOnly = Field(
LinkDataOnly.copy_files,
title="(only when upload_option is 'upload_directory' or 'upload_paths')."
description="(only when upload_option is 'upload_directory' or 'upload_paths')."
"Setting to 'link_to_files' symlinks instead of copying the files",
)
uuid: Optional[str] = Field(
Expand All @@ -132,7 +132,7 @@ class LibraryContentsFileCreatePayload(LibraryContentsCreatePayload):
)
upload_files: List[Dict[str, Any]] = Field(
[],
title="list of dictionaries containing the uploaded file fields",
title="list of the uploaded files",
)

# uploaded file fields
Expand Down Expand Up @@ -165,25 +165,25 @@ class LibraryContentsCollectionCreatePayload(LibraryContentsCreatePayload):
)
hide_source_items: bool = Field(
False,
title="if True, hide the source items in the collection",
description="if True, hide the source items in the collection",
)
copy_elements: bool = Field(
False,
title="if True, copy the elements into the collection",
description="if True, copy the elements into the collection",
)


class LibraryContentsUpdatePayload(Model):
converted_dataset_id: Optional[DecodedDatabaseIdField] = Field(
None,
title="the decoded id of the dataset that was created from the file",
title="the decoded id of the dataset",
)


class LibraryContentsDeletePayload(Model):
purge: bool = Field(
False,
title="if True, purge the library dataset",
description="if True, purge the library dataset",
)


Expand Down Expand Up @@ -310,18 +310,18 @@ class LibraryContentsPurgedResponse(LibraryContentsDeleteResponse):
purged: bool


LIBRARY_ID = Union[DecodedDatabaseIdField, LibraryFolderDatabaseIdField]
AnyLibraryId = Union[DecodedDatabaseIdField, LibraryFolderDatabaseIdField]

SHOW_RESPONSE = Union[
AnyLibraryContentsShowResponse = Union[
LibraryContentsShowFolderResponse,
LibraryContentsShowDatasetResponse,
]

CREATE_PAYLOAD = Union[
AnyLibraryContentsCreatePayload = Union[
LibraryContentsFolderCreatePayload, LibraryContentsFileCreatePayload, LibraryContentsCollectionCreatePayload
]

CREATE_RESPOSNSE = Union[
AnyLibraryContentsCreateResponse = Union[
LibraryContentsCreateFolderListResponse,
LibraryContentsCreateFileListResponse,
LibraryContentsCreateDatasetCollectionResponse,
Expand Down
Loading

0 comments on commit 20bd8fb

Please sign in to comment.