aimhubio / aim

Aim 💫 — An easy-to-use & supercharged open-source experiment tracker.
https://aimstack.io
Apache License 2.0
5.19k stars 319 forks source link

Run() sqlalchemy.exc.PendingRollbackError #3239

Open knightdby opened 3 days ago

knightdby commented 3 days ago

🐛 Bug

Error encountered when running Run() class instance with Python API.

To reproduce

Expected behavior

Environment

Additional context

sqlalchemy.exc.PendingRollbackError: This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (sqlite3.IntegrityError) UNIQUE constraint failed: run_tag.run_id, run_tag.tag_id [SQL: INSERT INTO run_tag (run_id, tag_id) VALUES (?, ?)] [parameters: (14, 7)] (Background on this error at: https://sqlalche.me/e/20/gkpj)

image
migranram commented 14 hours ago

I also have this problem. Just to add some information: I usually encounter this problem when there is already an open run logging to that AIM Server repo. Then if I try to start a new run (with another machine), or get access to a run from that Repo (like in the code below) I get this error.

Traceback (most recent call last):
  File "/home/miguel/dotfiles/tools/aim/list_runs.py", line 36, in <module>
    print(r.name)
  File "/home/miguel/miniconda3/envs/dl/lib/python3.9/site-packages/aim/sdk/run.py", line 124, in name
    return self.props.name
  File "/home/miguel/miniconda3/envs/dl/lib/python3.9/site-packages/aim/sdk/run.py", line 475, in props
    self._props = self.repo.request_props(self.hash, self.read_only)
  File "/home/miguel/miniconda3/envs/dl/lib/python3.9/site-packages/aim/sdk/repo.py", line 355, in request_props
    return StructuredRunProxy(self._client, hash_, read_only, created_at)
  File "/home/miguel/miniconda3/envs/dl/lib/python3.9/site-packages/aim/storage/structured/proxy.py", line 30, in __init__
    handler = self._rpc_client.get_resource_handler(self, self.resource_type, args=self.init_args)
  File "/home/miguel/miniconda3/envs/dl/lib/python3.9/site-packages/aim/ext/transport/client.py", line 204, in get_resource_handler
    raise_exception(response_json.get('exception'))
  File "/home/miguel/miniconda3/envs/dl/lib/python3.9/site-packages/aim/ext/transport/message_utils.py", line 70, in raise_exception
    raise exception(*args) if args else exception()
sqlalchemy.exc.PendingRollbackError: This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (sqlite3.IntegrityError) UNIQUE constraint failed: run_tag.run_id, run_tag.tag_id
[SQL: INSERT INTO run_tag (run_id, tag_id) VALUES (?, ?)]
[parameters: (267, 2)]
(Background on this error at: https://sqlalche.me/e/20/gkpj)