Skip to content

Commit

Permalink
import only to-be initialized components
Browse files Browse the repository at this point in the history
  • Loading branch information
prabhuomkar committed Aug 22, 2023
1 parent 3dd4b1e commit f9228cd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion worker/.pylintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[MASTER]
ignore=tests
ignore-patterns=.*_pb2.py,.*_grpc.py,.*.txt,.*file,.*.toml,.*.xml,.*.md
disable=too-few-public-methods,logging-fstring-interpolation,broad-except
disable=too-few-public-methods,logging-fstring-interpolation,broad-except,import-outside-toplevel
extension-pkg-allow-list=ngtpy
[FORMAT]
max-line-length=120
2 changes: 1 addition & 1 deletion worker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM python:3.10-slim
RUN apt update && \
apt install --no-install-recommends -y build-essential \
curl gcc libssl-dev python3-opencv libmagickwand-dev libimage-exiftool-perl exiftool libraw-dev && \
curl gcc libssl-dev python3-opencv ffmpeg libmagickwand-dev libimage-exiftool-perl exiftool libraw-dev && \
apt clean && rm -rf /var/lib/apt/lists/*
ADD requirements.txt /requirements.txt
RUN pip3 install --no-cache-dir -r requirements.txt
Expand Down
9 changes: 7 additions & 2 deletions worker/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from google.protobuf.empty_pb2 import Empty # pylint: disable=no-name-in-module
from prometheus_client import start_http_server

from src.components import Component, Metadata, Places, Classification, OCR, Faces, Finalize
from src.components import Component, Finalize
from src.providers.search import init_search, PyTorchModule
from src.protos.api_pb2_grpc import APIStub
from src.protos.worker_pb2 import MediaItemProcessResponse, GenerateEmbeddingResponse # pylint: disable=no-name-in-module
Expand Down Expand Up @@ -69,7 +69,7 @@ async def run_pending() -> None:
schedule.run_pending()
await asyncio.sleep(1)

async def serve() -> None:
async def serve() -> None: # pylint: disable=too-many-locals
"""Main serve function"""
# start metrics
start_http_server(int(os.getenv('SMRITI_METRICS_PORT', '5002')))
Expand Down Expand Up @@ -98,14 +98,19 @@ async def serve() -> None:
if 'params' in item:
item['params'] = json.loads(item['params'])
if item['name'] == 'metadata':
from src.components import Metadata
components.append(Metadata(api_stub=api_stub, params=item['params']))
elif item['name'] == 'places':
from src.components import Places
components.append(Places(api_stub=api_stub, source=item['source']))
elif item['name'] == 'classification':
from src.components import Classification
components.append(Classification(api_stub=api_stub, source=item['source'], params=item['params']))
elif item['name'] == 'ocr':
from src.components import OCR
components.append(OCR(api_stub=api_stub, source=item['source'], params=item['params']))
elif item['name'] == 'faces':
from src.components import Faces
components.append(Faces(api_stub=api_stub, source=item['source'], params=item['params']))
elif item['name'] == 'search':
search_model = init_search(name=item['source'], params=item['params'])
Expand Down

0 comments on commit f9228cd

Please sign in to comment.