Skip to content

Commit

Permalink
Add function for supporting files in library_contents
Browse files Browse the repository at this point in the history
  • Loading branch information
arash77 committed Oct 1, 2024
1 parent 5bf8e41 commit 49b0796
Show file tree
Hide file tree
Showing 6 changed files with 193 additions and 50 deletions.
119 changes: 91 additions & 28 deletions client/src/api/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3047,7 +3047,7 @@ export interface paths {
* @deprecated
* @description This endpoint is deprecated. Please use POST /api/folders/{folder_id} or POST /api/folders/{folder_id}/contents instead.
*/
post: operations["create_api_libraries__library_id__contents_post"];
post: operations["create_form_api_libraries__library_id__contents_post"];
delete?: never;
options?: never;
head?: never;
Expand Down Expand Up @@ -6079,6 +6079,70 @@ export interface components {
/** Name */
name?: unknown;
};
/** Body_create_form_api_libraries__library_id__contents_post */
Body_create_form_api_libraries__library_id__contents_post: {
/** Create Type */
create_type: unknown;
/**
* Dbkey
* @default ?
*/
dbkey: unknown;
/** Extended Metadata */
extended_metadata?: unknown;
/** File Type */
file_type?: unknown;
/** Files */
files?: string[] | null;
/**
* Filesystem Paths
* @default
*/
filesystem_paths: unknown;
/** Folder Id */
folder_id: unknown;
/** From Hda Id */
from_hda_id?: unknown;
/** From Hdca Id */
from_hdca_id?: unknown;
/**
* Ldda Message
* @default
*/
ldda_message: unknown;
/**
* Link Data Only
* @default copy_files
*/
link_data_only: unknown;
/**
* Roles
* @default
*/
roles: unknown;
/**
* Server Dir
* @default
*/
server_dir: unknown;
/**
* Tag Using Filenames
* @default false
*/
tag_using_filenames: unknown;
/**
* Tags
* @default []
*/
tags: unknown;
/**
* Upload Option
* @default upload_file
*/
upload_option: unknown;
/** Uuid */
uuid?: unknown;
};
/** Body_fetch_form_api_tools_fetch_post */
Body_fetch_form_api_tools_fetch_post: {
/** Files */
Expand Down Expand Up @@ -12876,7 +12940,7 @@ export interface components {
* if True, copy the elements into the collection
* @default false
*/
copy_elements: boolean | null;
copy_elements: boolean;
/** the type of item to create */
create_type: components["schemas"]["CreateType"];
/** list of dictionaries containing the element identifiers for the collection */
Expand All @@ -12896,29 +12960,29 @@ export interface components {
* if True, hide the source items in the collection
* @default false
*/
hide_source_items: boolean | null;
hide_source_items: boolean;
/**
* the new message attribute of the LDDA created
* @default
*/
ldda_message: string | null;
ldda_message: string;
/** the name of the collection */
name?: string | null;
/**
* create tags on datasets using the file's original name
* @default false
*/
tag_using_filenames: boolean | null;
tag_using_filenames: boolean;
/**
* create the given list of tags on datasets
* @default []
*/
tags: string[] | null;
tags: string[];
/**
* the method to use for uploading files
* @default upload_file
*/
upload_option: components["schemas"]["UploadOption"] | null;
upload_option: components["schemas"]["UploadOption"];
};
/** LibraryContentsCreateDatasetCollectionResponse */
LibraryContentsCreateDatasetCollectionResponse: components["schemas"]["LibraryContentsCreateDatasetResponse"][];
Expand Down Expand Up @@ -13004,7 +13068,7 @@ export interface components {
* if True, purge the library dataset
* @default false
*/
purge: boolean | null;
purge: boolean;
};
/** LibraryContentsDeleteResponse */
LibraryContentsDeleteResponse: {
Expand All @@ -13024,7 +13088,7 @@ export interface components {
* database key
* @default ?
*/
dbkey: string | unknown[] | null;
dbkey: string | unknown[];
/** sub-dictionary containing any extended metadata to associate with the item */
extended_metadata?: Record<string, never> | null;
/** file type */
Expand All @@ -13033,7 +13097,7 @@ export interface components {
* (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 | null;
filesystem_paths: string;
/**
* the encoded id of the parent folder of the new item
* @example 0123456789ABCDEF
Expand All @@ -13047,39 +13111,41 @@ export interface components {
* the new message attribute of the LDDA created
* @default
*/
ldda_message: string | null;
ldda_message: string;
/**
* (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"] | null;
link_data_only: components["schemas"]["LinkDataOnly"];
/**
* user selected roles
* @default
*/
roles: string | null;
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.
* @default
*/
server_dir: string | null;
server_dir: string;
/**
* create tags on datasets using the file's original name
* @default false
*/
tag_using_filenames: boolean | null;
tag_using_filenames: boolean;
/**
* create the given list of tags on datasets
* @default []
*/
tags: string[] | null;
tags: string[];
/**
* the method to use for uploading files
* @default upload_file
*/
upload_option: components["schemas"]["UploadOption"] | null;
upload_option: components["schemas"]["UploadOption"];
/** UUID of the dataset to upload */
uuid?: string | null;
} & {
[key: string]: unknown;
};
/** LibraryContentsFolderCreatePayload */
LibraryContentsFolderCreatePayload: {
Expand All @@ -13089,7 +13155,7 @@ export interface components {
* description of the folder to create
* @default
*/
description: string | null;
description: string;
/** sub-dictionary containing any extended metadata to associate with the item */
extended_metadata?: Record<string, never> | null;
/**
Expand All @@ -13105,27 +13171,27 @@ export interface components {
* the new message attribute of the LDDA created
* @default
*/
ldda_message: string | null;
ldda_message: string;
/**
* name of the folder to create
* @default
*/
name: string | null;
name: string;
/**
* create tags on datasets using the file's original name
* @default false
*/
tag_using_filenames: boolean | null;
tag_using_filenames: boolean;
/**
* create the given list of tags on datasets
* @default []
*/
tags: string[] | null;
tags: string[];
/**
* the method to use for uploading files
* @default upload_file
*/
upload_option: components["schemas"]["UploadOption"] | null;
upload_option: components["schemas"]["UploadOption"];
};
/** LibraryContentsIndexDatasetResponse */
LibraryContentsIndexDatasetResponse: {
Expand Down Expand Up @@ -27929,7 +27995,7 @@ export interface operations {
};
};
};
create_api_libraries__library_id__contents_post: {
create_form_api_libraries__library_id__contents_post: {
parameters: {
query?: never;
header?: {
Expand All @@ -27943,10 +28009,7 @@ export interface operations {
};
requestBody: {
content: {
"application/json":
| components["schemas"]["LibraryContentsFolderCreatePayload"]
| components["schemas"]["LibraryContentsFileCreatePayload"]
| components["schemas"]["LibraryContentsCollectionCreatePayload"];
"multipart/form-data": components["schemas"]["Body_create_form_api_libraries__library_id__contents_post"];
};
};
responses: {
Expand Down
2 changes: 2 additions & 0 deletions lib/galaxy/actions/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ def _upload_dataset(self, trans, folder_id: int, payload):
raise exceptions.InvalidFileFormatError("Invalid folder specified")
# Proceed with (mostly) regular upload processing if we're still errorless
if payload.upload_option == "upload_file":
for i, upload_dataset in enumerate(tool_params["files"]):
upload_dataset["file_data"] = payload.files[i]
tool_params = upload_common.persist_uploads(tool_params, trans)
uploaded_datasets = upload_common.get_uploaded_datasets(
trans, cntrller, tool_params, dataset_upload_inputs, library_bunch=library_bunch
Expand Down
Loading

0 comments on commit 49b0796

Please sign in to comment.