Added SQLAlchemy
This commit is contained in:
parent
bee6ccf09c
commit
998658c148
@ -4,6 +4,7 @@ import sentry_sdk
|
||||
from sentry_sdk.integrations.flask import FlaskIntegration
|
||||
from flask import Flask
|
||||
|
||||
from model import db
|
||||
from utils import register_all_error_handlers, k8s
|
||||
|
||||
# import views
|
||||
@ -24,10 +25,14 @@ if Config.SENTRY_DSN:
|
||||
app = Flask(__name__)
|
||||
app.config.from_object(Config)
|
||||
|
||||
# init stuffs
|
||||
k8s.init_app(app)
|
||||
|
||||
register_all_error_handlers(app)
|
||||
|
||||
@app.before_first_request
|
||||
def init_db():
|
||||
db.create_all()
|
||||
|
||||
# register views
|
||||
for view in [JobView]:
|
||||
view.register(app, trailing_slash=False)
|
||||
|
@ -7,6 +7,9 @@ Configuration
|
||||
|
||||
|
||||
class Config:
|
||||
SQLALCHEMY_DATABASE_URI = os.environ.get("SQLALCHEMY_DATABASE_URI", "sqlite://")
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||
|
||||
SECRET_KEY = os.environ.get("SECRET_KEY", os.urandom(12))
|
||||
|
||||
SENTRY_DSN = os.environ.get("SENTRY_DSN")
|
||||
|
1
job_orchestrator_service/model/__init__.py
Normal file
1
job_orchestrator_service/model/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
from .db import db
|
3
job_orchestrator_service/model/db.py
Normal file
3
job_orchestrator_service/model/db.py
Normal file
@ -0,0 +1,3 @@
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
|
||||
db = SQLAlchemy()
|
@ -7,10 +7,29 @@ import uuid
|
||||
|
||||
|
||||
class ControlConfigurationSchema(Schema):
|
||||
pod_id = fields.UUID(required=False, missing=uuid.uuid4)
|
||||
robot_address = fields.Str(required=True)
|
||||
program_url = fields.Str(required=True)
|
||||
|
||||
class Meta:
|
||||
unknown = RAISE
|
||||
|
||||
|
||||
class ControlStatusConfigurationSchema(Schema):
|
||||
cluster_ip = fields.IP(required=False, dump_only=True)
|
||||
running = fields.Boolean(required=False, dump_only=True)
|
||||
|
||||
class Meta:
|
||||
unknown = RAISE
|
||||
|
||||
|
||||
class ControllerSchema(Schema):
|
||||
pod_id = fields.UUID(required=False, missing=uuid.uuid4)
|
||||
configuration = fields.Nested(ControlConfigurationSchema, many=False, required=True)
|
||||
status = fields.Nested(ControlStatusConfigurationSchema, required=False, dump_only=True)
|
||||
|
||||
class Meta:
|
||||
unknown = RAISE
|
||||
|
||||
|
||||
class JobSchema(Schema):
|
||||
id = fields.UUID(required=False, missing=uuid.uuid4)
|
||||
|
@ -5,4 +5,8 @@ Flask
|
||||
marshmallow
|
||||
Flask-Classful
|
||||
sentry-sdk
|
||||
kubernetes
|
||||
kubernetes
|
||||
sqlalchemy
|
||||
Flask-SQLAlchemy
|
||||
psycopg2
|
||||
mysqlclient
|
Loading…
Reference in New Issue
Block a user