Skip to content

Commit

Permalink
Merge pull request #18714 from davelopez/fix_library_upload_with_tags
Browse files Browse the repository at this point in the history
Fix library upload with tags
  • Loading branch information
bgruening authored Aug 18, 2024
2 parents 19bc932 + f2db35c commit 6432629
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/galaxy/tools/actions/upload_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions lib/galaxy_test/api/test_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions lib/galaxy_test/base/populators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 6432629

Please sign in to comment.