Repository: bentoml/BentoML

Issue:
Error when doing model push, using yatai service with postgres
**Describe the bug**
<!--- A clear and concise description of what the bug is. -->
I was trying to push models to a yatai service configured with a postgresdb and S3 bucket. but when I run the command `bentoml push IrisClassifier:latest --yatai-url=127.0.0.1:50051` it throws the error
```
  File "/home/jjmachan/jjmachan/bentoml/BentoML/bentoml/cli/bento_management.py", line 311, in push
    yc.repository.push(bento, with_labels)
  File "/home/jjmachan/jjmachan/bentoml/BentoML/bentoml/yatai/client/bento_repository_api.py", line 101, in push
    return self.upload_from_dir(bento_bundle_path, labels=labels)
  File "/home/jjmachan/jjmachan/bentoml/BentoML/bentoml/yatai/client/bento_repository_api.py", line 161, in upload_from_dir
    get_bento_response = self.yatai_service.GetBento(
  File "/home/jjmachan/miniconda3/envs/bento-dev/lib/python3.8/site-packages/grpc/_interceptor.py", line 216, in __call__
    response, ignored_call = self._with_call(request,
  File "/home/jjmachan/miniconda3/envs/bento-dev/lib/python3.8/site-packages/grpc/_interceptor.py", line 257, in _with_call
    return call.result(), call
  File "/home/jjmachan/miniconda3/envs/bento-dev/lib/python3.8/site-packages/grpc/_channel.py", line 343, in result
    raise self
  File "/home/jjmachan/miniconda3/envs/bento-dev/lib/python3.8/site-packages/grpc/_interceptor.py", line 241, in continuation
    response, call = self._thunk(new_method).with_call(
  File "/home/jjmachan/miniconda3/envs/bento-dev/lib/python3.8/site-packages/grpc/_channel.py", line 957, in with_call
    return _end_unary_response_blocking(state, call, True, None)
  File "/home/jjmachan/miniconda3/envs/bento-dev/lib/python3.8/site-packages/grpc/_channel.py", line 849, in _end_unary_response_blocking
    raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
        status = StatusCode.UNKNOWN
        details = "Exception calling application: (psycopg2.errors.InvalidTextRepresentation) invalid input syntax for type integer: "IrisClassifier_20210615000954_1F6C6F"
LINE 3: WHERE locks.resource_id = 'IrisClassifier_20210615000954_1F6...
                                  ^

[SQL: SELECT locks.id AS locks_id, locks.resource_id AS locks_resource_id, locks.lock_status AS locks_lock_status, locks.locks_held AS locks_locks_held, locks.ttl AS locks_ttl
FROM locks
WHERE locks.resource_id = %(resource_id_1)s
 LIMIT %(param_1)s]
[parameters: {'resource_id_1': 'IrisClassifier_20210615000954_1F6C6F', 'param_1': 1}]
(Background on this error at: http://sqlalche.me/e/13/9h9h)"
        debug_error_string = "{"created":"@1623696080.407314868","description":"Error received from peer ipv4:127.0.0.1:50051","file":"src/core/lib/surface/call.cc","file_line":1066,"grpc_message":"Exception calling application: (psycopg2.errors.InvalidTextRepresentation) invalid input syntax for type integer: "IrisClassifier_20210615000954_1F6C6F"\nLINE 3: WHERE locks.resource_id = 'IrisClassifier_20210615000954_1F6...\n                                  ^\n\n[SQL: SELECT locks.id AS locks_id, locks.resource_id AS locks_resource_id, locks.lock_status AS locks_lock_status, locks.locks_held AS locks_locks_held, locks.ttl AS locks_ttl \nFROM locks \nWHERE locks.resource_id = %(resource_id_1)s \n LIMIT %(param_1)s]\n[parameters: {'resource_id_1': 'IrisClassifier_20210615000954_1F6C6F', 'param_1': 1}]\n(Background on this error at: http://sqlalche.me/e/13/9h9h)","grpc_status":2}"
>
```
this only happens in postgress and seems to be working for sqlit db. Also this is only on the code from the master repo. I tried using the yatai image and it works, and also tried the bentoml 0.12.1 version and works there too. But in the master branch this is failing.

**To Reproduce**
<!--
Steps to reproduce the issue:
1. Setup yatai service with postgress service. 
2. push a bentoml packed module via bentoml push IrisClassifier:latest --yatai-url=127.0.0.1:50051
3. throws this error 
-->
1. Setup yatai service with postgress service. 
2. push a bentoml packed module via bentoml push IrisClassifier:latest --yatai-url=127.0.0.1:50051
3. throws this error 


**Environment:**
 - OS: Arch Linux - all updated
 - Python Version: 3.8
 - BentoML Version: code from master branch


**Additional context**
<!-- Add any other context about the problem here. e.g. links to related discussion. -->



Discussion:
Thanks @jjmachan ! I will look into it
awesome! le me know if there is anything I can do to help too

Resolving patch:
diff --git a/bentoml/yatai/db/stores/lock.py b/bentoml/yatai/db/stores/lock.py
--- a/bentoml/yatai/db/stores/lock.py
+++ b/bentoml/yatai/db/stores/lock.py
@@ -1,7 +1,7 @@
 import datetime
 import enum
 
-from sqlalchemy import UniqueConstraint, Column, Integer, Enum, DateTime
+from sqlalchemy import UniqueConstraint, Column, Integer, Enum, DateTime, String
 from bentoml.exceptions import LockUnavailable
 from bentoml.yatai.db import Base
 
@@ -16,7 +16,7 @@ class Lock(Base):
     __tablename__ = 'locks'
     __table_args__ = tuple(UniqueConstraint('resource_id', name='_resource_id_uc',))
     id = Column(Integer, primary_key=True)
-    resource_id = Column(Integer, nullable=False, unique=True)
+    resource_id = Column(String, nullable=False, unique=True)
     lock_status = Column(Enum(LOCK_STATUS))
     locks_held = Column(Integer)
     ttl = Column(DateTime)
diff --git a/bentoml/yatai/migrations/versions/370a2bf2e594_update_lock_table_column.py b/bentoml/yatai/migrations/versions/370a2bf2e594_update_lock_table_column.py
new file mode 100644
--- /dev/null
+++ b/bentoml/yatai/migrations/versions/370a2bf2e594_update_lock_table_column.py
@@ -0,0 +1,33 @@
+"""update lock table column
+
+Revision ID: 370a2bf2e594
+Revises: af18f0b83286
+Create Date: 2021-06-15 13:41:18.015802
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '370a2bf2e594'
+down_revision = 'af18f0b83286'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+    # SQLite does not support making modifications to existing columns.
+    # Alembic "batch mode" is designed to overcome this limitation.
+    # https://alembic.sqlalchemy.org/en/latest/batch.html#batch-mode-with-autogenerate
+    with op.batch_alter_table('locks') as batch_op:
+        batch_op.alter_column(
+            column_name='resource_id', type_=sa.String, existing_type=sa.INTEGER
+        )
+
+
+def downgrade():
+    with op.batch_alter_table('locks') as batch_op:
+        batch_op.alter_column(
+            column_name='resource_id', type_=sa.INTEGER, existing_type=sa.String
+        )


Test patch: