-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
7,539 additions
and
65 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +0,0 @@ | ||
from . import db_operations | ||
from . import model_predict | ||
|
||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from celery import Celery | ||
def make_celery(app_name=__name__): | ||
redis_uri = 'redis://127.0.0.1:6379/0' | ||
return Celery(app_name, backend=redis_uri, broker=redis_uri) | ||
celery = make_celery() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
def init_celery(celery, app): | ||
celery.conf.update(app.config) | ||
TaskBase = celery.Task | ||
|
||
class ContextTask(TaskBase): | ||
def __call__(self, *args, **kwargs): | ||
with app.app_context(): | ||
return TaskBase.__call__(self, *args, **kwargs) | ||
|
||
celery.Task = ContextTask |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from flask import Flask | ||
|
||
from app.celery_utils import init_celery | ||
|
||
|
||
def create_app(app_name, **kwargs): | ||
app = Flask(app_name) | ||
if kwargs.get("celery"): | ||
init_celery(kwargs.get("celery"), app) | ||
from app.routes import bp | ||
app.register_blueprint(bp) | ||
print("Reached") | ||
return app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import time | ||
|
||
from Preprocessing_Scripts.RFM_calculation import RFM_Analysis | ||
from app import celery | ||
from db_operations.elasticsearch_oper import Elastic_Sales_Connect | ||
|
||
|
||
@celery.task(bind=True) | ||
def rfm_analysis(self): | ||
self.update_state(state='PROGRESS', meta={'status': 'Collecting Sales Data'}) | ||
es = Elastic_Sales_Connect() # setup a elasticsearch connection | ||
sales_data = [hit["_source"] for hit in es.elastic_get_sales_data()] | ||
self.update_state(state='PROGRESS', meta={'status': 'Processing Customer Segmentation'}) | ||
rfm_data = RFM_Analysis(sales_data) | ||
time.sleep(40) | ||
data = rfm_data.rfm_calc() | ||
self.update_state(state='PROGRESS', meta={'status': 'Refreshing Customer Index'}) | ||
es.ingest_es_rmf_data(data) | ||
return {'status': 'Customer List Ingestion completed!'} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from app import celery | ||
from app.factory import create_app | ||
from app.celery_utils import init_celery | ||
import app | ||
|
||
app = create_app('sales_analysis', celery=app.celery) | ||
init_celery(celery, app) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import configparser | ||
config = configparser.ConfigParser() | ||
configFilePath = 'elastic_config.ini' | ||
config.read(configFilePath) | ||
|
||
class Elastic_Index_Config: | ||
@staticmethod | ||
def get_sales_index(): | ||
return config['ELASTICSEARCH']['sales_data_index'] | ||
|
||
@staticmethod | ||
def get_sales_forecast_index(): | ||
return config['ELASTICSEARCH']['forecast_index'] | ||
|
||
@staticmethod | ||
def get_sales_rfm_index(): | ||
return config['ELASTICSEARCH']['rfm_index'] | ||
|
||
@staticmethod | ||
def get_business_unit_key(): | ||
return config['ELASTICSEARCH']['business_unit'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from app import factory | ||
import app | ||
if __name__ == "__main__": | ||
app = factory.create_app("sales_analysis", celery=app.celery) | ||
app.run(debug=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
venv/lib/python3.6/site-packages/redis-3.4.1.dist-info/INSTALLER
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pip |
22 changes: 22 additions & 0 deletions
22
venv/lib/python3.6/site-packages/redis-3.4.1.dist-info/LICENSE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Copyright (c) 2012 Andy McCurdy | ||
|
||
Permission is hereby granted, free of charge, to any person | ||
obtaining a copy of this software and associated documentation | ||
files (the "Software"), to deal in the Software without | ||
restriction, including without limitation the rights to use, | ||
copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the | ||
Software is furnished to do so, subject to the following | ||
conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. |
Oops, something went wrong.