folder-classifier 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- folder_classifier-0.1.0/PKG-INFO +13 -0
- folder_classifier-0.1.0/README.md +1 -0
- folder_classifier-0.1.0/folder_classifier/__init__.py +1 -0
- folder_classifier-0.1.0/folder_classifier/app.py +27 -0
- folder_classifier-0.1.0/folder_classifier/deploy.py +12 -0
- folder_classifier-0.1.0/folder_classifier/dto.py +50 -0
- folder_classifier-0.1.0/folder_classifier.egg-info/PKG-INFO +13 -0
- folder_classifier-0.1.0/folder_classifier.egg-info/SOURCES.txt +11 -0
- folder_classifier-0.1.0/folder_classifier.egg-info/dependency_links.txt +1 -0
- folder_classifier-0.1.0/folder_classifier.egg-info/top_level.txt +1 -0
- folder_classifier-0.1.0/pyproject.toml +3 -0
- folder_classifier-0.1.0/setup.cfg +21 -0
@@ -0,0 +1,13 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: folder-classifier
|
3
|
+
Version: 0.1.0
|
4
|
+
Summary: Deploy folder classifier API to a Ray cluster
|
5
|
+
Author: Crispin Almodovar
|
6
|
+
Author-email:
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
9
|
+
Classifier: Operating System :: OS Independent
|
10
|
+
Requires-Python: >=3.12
|
11
|
+
Description-Content-Type: text/markdown
|
12
|
+
|
13
|
+
# Folder classifier API
|
@@ -0,0 +1 @@
|
|
1
|
+
# Folder classifier API
|
@@ -0,0 +1 @@
|
|
1
|
+
from folder_classifier.deploy import build_app
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import logging
|
2
|
+
|
3
|
+
from fastapi import FastAPI
|
4
|
+
from ray import serve
|
5
|
+
|
6
|
+
from folder_classifier.dto import ModelConfig, FolderClassificationResponse, FolderClassificationRequest
|
7
|
+
|
8
|
+
web_api = FastAPI(title=f"Folder Classifier API")
|
9
|
+
|
10
|
+
|
11
|
+
@serve.deployment
|
12
|
+
@serve.ingress(web_api)
|
13
|
+
class FolderClassifierAPI:
|
14
|
+
def __init__(self, model_config: ModelConfig):
|
15
|
+
assert model_config, "model_config is required"
|
16
|
+
assert model_config.app_name and model_config.deployment, "Invalid ModelConfig values"
|
17
|
+
logging.basicConfig(level=logging.INFO)
|
18
|
+
self.logger = logging.getLogger(__name__)
|
19
|
+
self.logger.info(f"Initializing model: {model_config}")
|
20
|
+
#self.model_handle = serve.get_deployment_handle(app_name=model_config.app_name, deployment_name=model_config.deployment)
|
21
|
+
self.logger.info(f"Successfully initialized Folder Classifier API")
|
22
|
+
|
23
|
+
@web_api.post("/predict")
|
24
|
+
async def predict(self, request: FolderClassificationRequest) -> FolderClassificationResponse:
|
25
|
+
result = ("matter", 0.9) #await self.model_handle.remote(request)
|
26
|
+
self.logger.info(f"Received request: {request}")
|
27
|
+
return FolderClassificationResponse(category=result[0], confidence=result[1])
|
@@ -0,0 +1,12 @@
|
|
1
|
+
from ray.serve import Application
|
2
|
+
|
3
|
+
from folder_classifier.app import FolderClassifierAPI
|
4
|
+
from folder_classifier.dto import AppConfig
|
5
|
+
|
6
|
+
|
7
|
+
def build_app(args: AppConfig) -> Application:
|
8
|
+
assert args and args.model, "AppConfig model is required"
|
9
|
+
assert args.model.app_name and args.model.deployment, "Model's app_name and deployment are required"
|
10
|
+
|
11
|
+
app = FolderClassifierAPI.bind(args.model)
|
12
|
+
return app
|
@@ -0,0 +1,50 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
from textwrap import dedent
|
4
|
+
from typing import List, Union, Literal
|
5
|
+
|
6
|
+
from pydantic import BaseModel, Field, confloat
|
7
|
+
|
8
|
+
|
9
|
+
class ModelConfig(BaseModel):
|
10
|
+
app_name: str
|
11
|
+
deployment: str
|
12
|
+
|
13
|
+
|
14
|
+
class AppConfig(BaseModel):
|
15
|
+
model: ModelConfig
|
16
|
+
|
17
|
+
|
18
|
+
class File(BaseModel):
|
19
|
+
name: str
|
20
|
+
type: Literal["file"]
|
21
|
+
|
22
|
+
|
23
|
+
class Folder(BaseModel):
|
24
|
+
name: str
|
25
|
+
type: Literal["folder"]
|
26
|
+
# Discriminated union: 'type' field is used to select between File and Folder
|
27
|
+
items: List[Union[File, Folder]] = Field(default_factory=list)
|
28
|
+
model_config = {
|
29
|
+
"json_schema_extra": {
|
30
|
+
# Override the OpenAPI example to avoid the default 'string' entry
|
31
|
+
"example": dedent("""{
|
32
|
+
"name": "string",
|
33
|
+
"type": "folder",
|
34
|
+
"items": [
|
35
|
+
{
|
36
|
+
"name": "string",
|
37
|
+
"type": "file"
|
38
|
+
}
|
39
|
+
]
|
40
|
+
}""")
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
|
45
|
+
Folder.model_rebuild()
|
46
|
+
FolderClassificationRequest = Folder
|
47
|
+
|
48
|
+
class FolderClassificationResponse(BaseModel):
|
49
|
+
category: Literal["matter", "other"]
|
50
|
+
confidence: confloat(ge=0.0, le=1.0)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: folder-classifier
|
3
|
+
Version: 0.1.0
|
4
|
+
Summary: Deploy folder classifier API to a Ray cluster
|
5
|
+
Author: Crispin Almodovar
|
6
|
+
Author-email:
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
9
|
+
Classifier: Operating System :: OS Independent
|
10
|
+
Requires-Python: >=3.12
|
11
|
+
Description-Content-Type: text/markdown
|
12
|
+
|
13
|
+
# Folder classifier API
|
@@ -0,0 +1,11 @@
|
|
1
|
+
README.md
|
2
|
+
pyproject.toml
|
3
|
+
setup.cfg
|
4
|
+
folder_classifier/__init__.py
|
5
|
+
folder_classifier/app.py
|
6
|
+
folder_classifier/deploy.py
|
7
|
+
folder_classifier/dto.py
|
8
|
+
folder_classifier.egg-info/PKG-INFO
|
9
|
+
folder_classifier.egg-info/SOURCES.txt
|
10
|
+
folder_classifier.egg-info/dependency_links.txt
|
11
|
+
folder_classifier.egg-info/top_level.txt
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
folder_classifier
|
@@ -0,0 +1,21 @@
|
|
1
|
+
[metadata]
|
2
|
+
name = folder-classifier
|
3
|
+
version = 0.1.0
|
4
|
+
author = Crispin Almodovar
|
5
|
+
author_email =
|
6
|
+
description = Deploy folder classifier API to a Ray cluster
|
7
|
+
long_description = file: README.md
|
8
|
+
long_description_content_type = text/markdown
|
9
|
+
classifiers =
|
10
|
+
Programming Language :: Python :: 3
|
11
|
+
License :: OSI Approved :: MIT License
|
12
|
+
Operating System :: OS Independent
|
13
|
+
|
14
|
+
[options]
|
15
|
+
packages = find:
|
16
|
+
python_requires = >=3.12
|
17
|
+
|
18
|
+
[egg_info]
|
19
|
+
tag_build =
|
20
|
+
tag_date = 0
|
21
|
+
|