From d14bae73f72cd454ef41bb1815cf1dfc9256db5d Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Wed, 7 Feb 2018 10:46:39 +0100 Subject: [PATCH] Flush once per tag Not sure this is the right thing to do (maybe there is a better way to get an ID?), but it avoids ``` IntegrityError: (psycopg2.IntegrityError) duplicate key value violates unique constraint "tag_name_key" DETAIL: Key (name)=(group) already exists. [SQL: 'INSERT INTO tag (type, parent_id, name) VALUES (%(type)s, %(parent_id)s, %(name)s) RETURNING tag.id'] [parameters: {'parent_id': None, 'type': 0, 'name': u'group'}] galaxy.tools.execute WARNING 2018-02-06 15:22:38,808 [p:2122,w:1,m:0] [uWSGIWorker1Core1] There was a failure executing a job for tool [__TAG_FROM_FILE__] - Error executing tool: (psycopg2.IntegrityError) duplicate key value violates unique constraint "tag_name_key" ``` --- lib/galaxy/managers/tags.py | 2 ++ lib/galaxy/tools/tag_collection_from_file.xml | 8 ++++---- test-data/new_tags_1.txt | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/galaxy/managers/tags.py b/lib/galaxy/managers/tags.py index b3d3b0743f9..8e37c13ed57 100644 --- a/lib/galaxy/managers/tags.py +++ b/lib/galaxy/managers/tags.py @@ -169,6 +169,8 @@ class TagManager(object): item_tag_assoc.user_tname = name item_tag_assoc.user_value = value item_tag_assoc.value = lc_value + # Need to flush to get an ID. We need an ID to apply multiple tags with the same tname to an object. + self.sa_session.flush() return item_tag_assoc def apply_item_tags(self, user, item, tags_str): diff --git a/lib/galaxy/tools/tag_collection_from_file.xml b/lib/galaxy/tools/tag_collection_from_file.xml index 3666a386c41..36b2935a7b7 100644 --- a/lib/galaxy/tools/tag_collection_from_file.xml +++ b/lib/galaxy/tools/tag_collection_from_file.xml @@ -34,13 +34,13 @@ - + - + @@ -63,13 +63,13 @@ - + - + diff --git a/test-data/new_tags_1.txt b/test-data/new_tags_1.txt index 2296bf5f7a7..91caa6c4fae 100644 --- a/test-data/new_tags_1.txt +++ b/test-data/new_tags_1.txt @@ -1,2 +1,2 @@ -forward orientation:forward alias:r1 -reverse orientation:reverse alias:r2 +forward orientation:forward alias:r1 alias:f +reverse orientation:reverse alias:r2 alias:r