From 6a8df02257d39db3b7a22b1a6443cbec6390a893 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Fri, 16 Aug 2024 14:36:05 +0200 Subject: [PATCH 1/3] Add support for tags in LibraryPopulator.create_library_dataset() --- lib/galaxy_test/base/populators.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/galaxy_test/base/populators.py b/lib/galaxy_test/base/populators.py index fcf59fd12d1f..6d22891cc1c1 100644 --- a/lib/galaxy_test/base/populators.py +++ b/lib/galaxy_test/base/populators.py @@ -2687,6 +2687,7 @@ def create_dataset_request(self, library, **kwds): "upload_option": upload_option, "file_type": kwds.get("file_type", "auto"), "db_key": kwds.get("db_key", "?"), + "tags": kwds.get("tags", []), } if kwds.get("link_data"): create_data["link_data_only"] = "link_to_files" From 1155e7a41f5210b5cd703a32da8119d17adc370c Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Fri, 16 Aug 2024 14:36:53 +0200 Subject: [PATCH 2/3] Add test for uploading library file contents with tags --- lib/galaxy_test/api/test_tags.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/galaxy_test/api/test_tags.py b/lib/galaxy_test/api/test_tags.py index f8908968f3b8..776f95db147d 100644 --- a/lib/galaxy_test/api/test_tags.py +++ b/lib/galaxy_test/api/test_tags.py @@ -112,6 +112,11 @@ def _get_item(self, item_id: str): item = item_response.json() return item + def test_upload_file_contents_with_tags(self): + initial_tags = ["name:foobar", "barfoo"] + ld = self.library_populator.new_library_dataset(name=f"test-library-dataset-{uuid4()}", tags=initial_tags) + assert ld["tags"] == initial_tags + class TestPageTags(TagsApiTests): api_name = "pages" From f2db35cf768089eb75adc81c84f66836ed64c25b Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Fri, 16 Aug 2024 14:38:46 +0200 Subject: [PATCH 3/3] Fix tags parsing in __new_library_upload --- lib/galaxy/tools/actions/upload_common.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/galaxy/tools/actions/upload_common.py b/lib/galaxy/tools/actions/upload_common.py index d4b8bee24ff6..1d6d1b9a4c10 100644 --- a/lib/galaxy/tools/actions/upload_common.py +++ b/lib/galaxy/tools/actions/upload_common.py @@ -195,8 +195,9 @@ def __new_library_upload(trans, cntrller, uploaded_dataset, library_bunch, tag_h tag_handler.apply_item_tag(item=ldda, user=trans.user, name="name", value=tag_from_filename, flush=False) if tags_list := uploaded_dataset.get("tags", False): - for tag in tags_list: - tag_handler.apply_item_tag(item=ldda, user=trans.user, name="name", value=tag, flush=False) + new_tags = tag_handler.parse_tags_list(tags_list) + for tag in new_tags: + tag_handler.apply_item_tag(item=ldda, user=trans.user, name=tag[0], value=tag[1], flush=False) trans.sa_session.add(ldda) if state: