Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] Resolve tag addition issue from parallel runs #3247

Open
wants to merge 1 commit into
base: release/3.25.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 3.25.2
- Fix aggregated metrics' computations (mihran113)
- Fix tag addition issue from parallel runs (mihran113)

## 3.25.1 Nov 6, 2024
- Fix corruption marking on empty index db (mihran113)
Expand Down
25 changes: 18 additions & 7 deletions aim/storage/structured/sql_engine/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,25 @@ def tags(self) -> List[str]:
return [tag.name for tag in self.tags_obj]

def add_tag(self, value: str) -> None:
def unsafe_add_tag():
if value is None:
tag = None
else:
tag = session.query(TagModel).filter(TagModel.name == value).first()
if not tag:
tag = TagModel(value)
session.add(tag)
self._model.tags.append(tag)
session.add(self._model)

session = self._session
tag = session.query(TagModel).filter(TagModel.name == value).first()
if not tag:
tag = TagModel(value)
session.add(tag)
self._model.tags.append(tag)
session.add(self._model)
session_commit_or_flush(session)
unsafe_add_tag()
try:
session_commit_or_flush(session)
except IntegrityError:
session.rollback()
unsafe_add_tag()
session_commit_or_flush(session)

def remove_tag(self, tag_name: str) -> bool:
session = self._session
Expand Down
Loading