diff --git a/ee/recommendation/airflow-local/Dockerfile b/ee/recommendation/Dockerfile similarity index 100% rename from ee/recommendation/airflow-local/Dockerfile rename to ee/recommendation/Dockerfile diff --git a/ee/recommendation/api.py b/ee/recommendation/api.py deleted file mode 100644 index f9d3e05bf..000000000 --- a/ee/recommendation/api.py +++ /dev/null @@ -1,42 +0,0 @@ -import logging -from apscheduler.schedulers.asyncio import AsyncIOScheduler -from fastapi import FastAPI -# from fastapi_utils.tasks import repeat_every -from utils import events_queue -from utils import pg_client -from utils import schemas_ee - -app = FastAPI() -app.schedule = AsyncIOScheduler() - -@app.get('/') -def home(): - return '

This is a title

' - - -@app.get('/value/{value}') -@app.put('/value/{value}') -def number(value: int): - logging.info(f'> {value} as input. Testing queue with pg') - d = {'timestamp': 23786, 'action': 'action', 'source': 'source', 'category': 'cat', 'data': {}} - events = schemas_ee.SignalsSchema - event = events.parse_obj(d) - events_queue.global_queue.put((value, 0, event)) - - -@app.on_event("startup") -async def startup(): - await pg_client.init() - await events_queue.init(test=False) - app.schedule.start() - - -@app.schedule.scheduled_job("interval", seconds=60*1) -def clean_up(): - events_queue.global_queue.force_flush() - - -@app.on_event("shutdown") -async def shutdown(): - await events_queue.terminate() - await pg_client.terminate() diff --git a/ee/recommendation/clean.sh b/ee/recommendation/clean.sh new file mode 100644 index 000000000..857c8d63d --- /dev/null +++ b/ee/recommendation/clean.sh @@ -0,0 +1 @@ +docker-compose down --volumes --rmi all diff --git a/ee/recommendation/airflow-local/dags/training_dag.py b/ee/recommendation/dags/training_dag.py similarity index 100% rename from ee/recommendation/airflow-local/dags/training_dag.py rename to ee/recommendation/dags/training_dag.py diff --git a/ee/recommendation/airflow-local/docker-compose.yaml b/ee/recommendation/docker-compose.yaml similarity index 100% rename from ee/recommendation/airflow-local/docker-compose.yaml rename to ee/recommendation/docker-compose.yaml diff --git a/ee/recommendation/airflow-local/requirements.txt b/ee/recommendation/requirements.txt similarity index 100% rename from ee/recommendation/airflow-local/requirements.txt rename to ee/recommendation/requirements.txt diff --git a/ee/recommendation/run.sh b/ee/recommendation/run.sh new file mode 100644 index 000000000..0a703bca4 --- /dev/null +++ b/ee/recommendation/run.sh @@ -0,0 +1,11 @@ +echo 'Setting up required modules..' +mkdir scripts +mkdir plugins +mkdir logs +mkdir scripts/utils +cp ../../api/chalicelib/utils/pg_client.py scripts/utils +cp ../api/chalicelib/utils/ch_client.py scripts/utils +echo 'Building containers...' +docker-compose up airflow-init +echo 'Running containers...' +docker-compose up diff --git a/ee/recommendation/airflow-local/scripts/core/recommendation.py b/ee/recommendation/scripts/core/recommendation.py similarity index 100% rename from ee/recommendation/airflow-local/scripts/core/recommendation.py rename to ee/recommendation/scripts/core/recommendation.py diff --git a/ee/recommendation/airflow-local/scripts/task.py b/ee/recommendation/scripts/task.py similarity index 100% rename from ee/recommendation/airflow-local/scripts/task.py rename to ee/recommendation/scripts/task.py diff --git a/ee/recommendation/airflow-local/scripts/utils/ch_client.py b/ee/recommendation/scripts/utils/ch_client.py similarity index 100% rename from ee/recommendation/airflow-local/scripts/utils/ch_client.py rename to ee/recommendation/scripts/utils/ch_client.py diff --git a/ee/recommendation/airflow-local/scripts/utils/pg_client.py b/ee/recommendation/scripts/utils/pg_client.py similarity index 100% rename from ee/recommendation/airflow-local/scripts/utils/pg_client.py rename to ee/recommendation/scripts/utils/pg_client.py