Skip to content

Commit 9b7ff60

Browse files
pakelleyhakan458
and
hakan458
authored
Fix utils import in tasks.process_file (#91)
Co-authored-by: hakan458 <[email protected]>
1 parent 22ca6fd commit 9b7ff60

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

docker-compose.yml

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ services:
3232
condition: service_healthy
3333
environment:
3434
- REDIS_URL=redis://redis:6379/0
35+
- KAFKA_BOOTSTRAP_SERVERS=kafka:9093
3536
command:
3637
["poetry", "run", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
3738
worker:
@@ -47,6 +48,7 @@ services:
4748
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
4849
- AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN}
4950
- MODULE_NAME=process_file.app
51+
- KAFKA_BOOTSTRAP_SERVERS=kafka:9093
5052
command:
5153
'sh -c "cd tasks && poetry run celery -A $$MODULE_NAME worker --loglevel=info"'
5254
redis:

server/utils.py

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import logging
2+
3+
from enum import Enum
4+
from pydantic_settings import BaseSettings, SettingsConfigDict
5+
from typing import List, Union
6+
7+
logger = logging.getLogger(__name__)
8+
9+
10+
class Settings(BaseSettings):
11+
"""
12+
Can hardcode settings here, read from env file, or pass as env vars
13+
https://docs.pydantic.dev/latest/concepts/pydantic_settings/#field-value-priority
14+
"""
15+
16+
kafka_bootstrap_servers: Union[str, List[str]]
17+
18+
model_config = SettingsConfigDict(
19+
env_file=".env",
20+
)
21+
22+
23+
def dummy_handler(batch):
24+
"""
25+
Dummy handler to test streaming output flow
26+
Can delete once we have a real handler
27+
"""
28+
29+
logger.info(f"\n\nHandler received batch: {batch}\n\n")
30+
31+
32+
class ResultHandler(Enum):
33+
DUMMY = dummy_handler
34+
35+
36+
def get_input_topic(job_id: str):
37+
return f"adala-input-{job_id}"
38+
39+
40+
def get_output_topic(job_id: str):
41+
return f"adala-output-{job_id}"

0 commit comments

Comments
 (0)