From 77536c31532b56745104e08cbe2511493146fa60 Mon Sep 17 00:00:00 2001
From: MauricioGarciaS <47052044+MauricioGarciaS@users.noreply.github.com>
Date: Tue, 29 Nov 2022 11:17:59 +0100
Subject: [PATCH] clened recommendation files
---
.../{airflow-local => }/Dockerfile | 0
ee/recommendation/api.py | 42 -------------------
ee/recommendation/clean.sh | 1 +
.../{airflow-local => }/dags/training_dag.py | 0
.../{airflow-local => }/docker-compose.yaml | 0
.../{airflow-local => }/requirements.txt | 0
ee/recommendation/run.sh | 11 +++++
.../scripts/core/recommendation.py | 0
.../{airflow-local => }/scripts/task.py | 0
.../scripts/utils/ch_client.py | 0
.../scripts/utils/pg_client.py | 0
11 files changed, 12 insertions(+), 42 deletions(-)
rename ee/recommendation/{airflow-local => }/Dockerfile (100%)
delete mode 100644 ee/recommendation/api.py
create mode 100644 ee/recommendation/clean.sh
rename ee/recommendation/{airflow-local => }/dags/training_dag.py (100%)
rename ee/recommendation/{airflow-local => }/docker-compose.yaml (100%)
rename ee/recommendation/{airflow-local => }/requirements.txt (100%)
create mode 100644 ee/recommendation/run.sh
rename ee/recommendation/{airflow-local => }/scripts/core/recommendation.py (100%)
rename ee/recommendation/{airflow-local => }/scripts/task.py (100%)
rename ee/recommendation/{airflow-local => }/scripts/utils/ch_client.py (100%)
rename ee/recommendation/{airflow-local => }/scripts/utils/pg_client.py (100%)
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