-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Extracted `database.models` and `api.router` to `engine` and `ltm`. - Add experiments migrations
- Loading branch information
Showing
16 changed files
with
778 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import uuid | ||
|
||
from sqlalchemy import ForeignKey | ||
from sqlalchemy.orm import Mapped, mapped_column | ||
from sqlalchemy.sql.functions import now | ||
from sqlalchemy.types import String | ||
|
||
from flou.database.models import Base | ||
from flou.database.utils import JSONType | ||
|
||
|
||
class Error(Base): | ||
__tablename__ = "engine_error" | ||
|
||
id: Mapped[uuid.UUID] = mapped_column(primary_key=True) | ||
ltm_id: Mapped[int] = mapped_column(ForeignKey("ltm_ltms.id")) | ||
reason: Mapped[str] = mapped_column(String(30), nullable=False) | ||
item: Mapped[dict] = mapped_column(JSONType(), nullable=False) | ||
retries: Mapped[list] = mapped_column(JSONType(), default=list, nullable=False) | ||
retrying: Mapped[bool] = mapped_column(default=True, nullable=False) | ||
success: Mapped[bool] = mapped_column(default=False, nullable=False) | ||
|
||
def __repr__(self): | ||
return f"Error(ltm_id={self.ltm_id!r})" | ||
|
||
def as_dict(self): | ||
return {c.name: getattr(self, c.name) for c in self.__table__.columns} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from fastapi import APIRouter | ||
|
||
|
||
from flou.conf import settings | ||
|
||
router = APIRouter() | ||
|
||
|
||
@router.get("/example") | ||
def read_example(): | ||
return { | ||
"message": "Hello, World!", | ||
"engine": settings.old_database.engine, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from datetime import datetime | ||
from typing import List | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
|
||
class LTM(BaseModel): | ||
id: int | ||
name: str | ||
fqn: str | ||
snapshots_count: int | ||
created_at: datetime | ||
updated_at: datetime | ||
|
||
|
||
class LTMCreation(BaseModel): | ||
fqn: str = Field(..., description="Fully qualified name of the LTM class") | ||
payload: dict = Field({}, description="Initial payload as a json object") | ||
playground: bool = Field( | ||
False, description="If true, the LTM will be created in the playground" | ||
) | ||
|
||
|
||
class Transition(BaseModel): | ||
transition: str = Field(..., description="The label of the transition to perform") | ||
namespace: str = Field(..., description="The namespace of the transition") | ||
params: list[dict] | None = Field( | ||
None, description="If a parameterized transition, it's parameters" | ||
) | ||
payload: dict | None = Field( | ||
None, description="Optional payload for the transition" | ||
) | ||
wait_until_transition: str | None = Field( | ||
None, | ||
description="Await return until this transition `namespace:label` executes", | ||
) | ||
|
||
|
||
class SnapshotIndex(BaseModel): | ||
index: int = Field(..., description="The index of the desired snapshot") | ||
|
||
|
||
class RollbackIndex(BaseModel): | ||
index: int = Field(..., description="The index of the desired rollback") | ||
|
||
|
||
class ErrorList(BaseModel): | ||
ids: List[str] = Field(..., description="The errors UUIDs to retry") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .ltm import LTM |
Oops, something went wrong.