Skip to content

Commit

Permalink
Merge pull request #30 from snuhcs-course/ml/modify-stub-gen-path
Browse files Browse the repository at this point in the history
Ml/modify stub gen path & Add dockerfile for ml
  • Loading branch information
1personProfessor authored Nov 16, 2023
2 parents c24b202 + 88ca2e5 commit f7c81d7
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea
__pycache__
4 changes: 2 additions & 2 deletions idl/buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ plugins:
- plugin: buf.build/protocolbuffers/ruby
out: ../backend/gen
- plugin: buf.build/grpc/python:v1.59.2
out: ../ml/gen/
out: ../ml/
- plugin: buf.build/protocolbuffers/python
out: ../ml/gen/
out: ../ml/
16 changes: 16 additions & 0 deletions ml/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM python:3.11-slim

WORKDIR /app

RUN pip install poetry

COPY pyproject.toml poetry.lock ./

RUN poetry config virtualenvs.create false && \
poetry install --without dev

COPY . .

CMD python main.py


11 changes: 7 additions & 4 deletions ml/main.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import os
from concurrent import futures

import grpc

from gen.swpp.v1 import place_pb2
from gen.swpp.v1.place_pb2_grpc import PlaceServiceServicer, add_PlaceServiceServicer_to_server
from swpp.v1 import place_pb2
from swpp.v1.place_pb2_grpc import PlaceServiceServicer, add_PlaceServiceServicer_to_server


class PlaceService(PlaceServiceServicer):
Expand All @@ -17,9 +18,11 @@ def ListPlaces(self, request, context):


if __name__ == '__main__':
# Create Unary Server
port = os.getenv("PORT", "50051")

server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
add_PlaceServiceServicer_to_server(PlaceService(), server)
server.add_insecure_port('[::]:50051')
server.add_insecure_port(f"[::]:{port}")
server.start()
print(f"Server started on port {port}")
server.wait_for_termination()
File renamed without changes.
File renamed without changes.

0 comments on commit f7c81d7

Please sign in to comment.