Skip to content

Commit

Permalink
making ml plugin a real plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyrannas committed Oct 30, 2024
1 parent 0865e86 commit fbb977d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
4 changes: 2 additions & 2 deletions panoptic_back/panoptic/core/db/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pypika import Table, PostgreSQLQuery, Order, functions

from panoptic.core.db.db_connection import DbConnection, db_lock
from panoptic.core.db.utils import auto_dict
from panoptic.core.db.utils import auto_dict, decode_if_json
from panoptic.models import Instance, Vector, VectorDescription, InstanceProperty, ImageProperty, \
InstancePropertyKey, ImagePropertyKey, PropertyType, PropertyMode
from panoptic.models import Tag, Property, Folder
Expand Down Expand Up @@ -544,7 +544,7 @@ async def get_project_param(self, key: str):
cursor = await self.conn.execute_query(query)
row = await cursor.fetchone()
if row:
return row[0]
return decode_if_json(row[0])
return None

async def set_project_param(self, key: str, value: str):
Expand Down
10 changes: 8 additions & 2 deletions panoptic_back/panoptic/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import webbrowser
from contextlib import asynccontextmanager

import uvicorn
from fastapi import FastAPI
Expand Down Expand Up @@ -48,8 +49,13 @@ def start():
if not os.environ.get('REMOTE'):
webbrowser.open(front_url)

@app.on_event("shutdown")
async def shutdown_event():
# @app.on_event("shutdown")
# async def shutdown_event():
# await panoptic.close()

@asynccontextmanager
async def lifespan(app: FastAPI):
yield
await panoptic.close()

uvicorn.run(app, host=HOST, port=PORT)
Expand Down
10 changes: 6 additions & 4 deletions panoptic_back/panoptic/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import numpy
from fastapi_camelcase import CamelModel
from pydantic import BaseModel
from pydantic import BaseModel, ConfigDict


# from pydantic.dataclasses import dataclass
Expand Down Expand Up @@ -196,6 +196,8 @@ class Parameters(BaseModel):


class Folder(BaseModel):
model_config = ConfigDict(coerce_numbers_to_str=True)

id: int | None = None
path: str
name: str
Expand Down Expand Up @@ -269,9 +271,9 @@ class ParamDescription(CamelModel):
class FunctionDescription(CamelModel):
id: str
name: str
label: str = None
description: str = None
params: List[ParamDescription] = []
label: str | None = None
description: str | None = None
params: List[ParamDescription] | None = []
hooks: list[str] = []


Expand Down
5 changes: 2 additions & 3 deletions panoptic_back/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ classifiers = [
dependencies = [
"aiofiles",
"aiosqlite",
"faiss-cpu",
"fastapi==0.99.1",
"fastapi-camelcase==1.0.5",
"fastapi",
"fastapi-camelcase",
"numpy",
"orjson",
"pandas",
Expand Down

0 comments on commit fbb977d

Please sign in to comment.