forked from tejones/retailstoreofthefuture
-
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
80 changed files
with
36,715 additions
and
6,892 deletions.
There are no files selected for viewing
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.
Binary file not shown.
Binary file not shown.
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
Empty file.
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,46 @@ | ||
from fastapi.testclient import TestClient | ||
import pytest | ||
|
||
from app.main import app | ||
|
||
|
||
@pytest.fixture(scope='session') | ||
def client(): | ||
return TestClient(app) | ||
|
||
|
||
def test_healthcheck(client): | ||
response = client.get('/healthcheck') | ||
assert response.status_code == 200 | ||
assert response.text == 'OK' | ||
|
||
|
||
def test_score_coupon(client): | ||
body = { | ||
'customer': { | ||
'customer_id': '25', | ||
'gender': 'F', | ||
'age': 35, | ||
'mean_buy_price': 15.22, | ||
'total_coupons_used': 2009, | ||
'mean_discount_received': 12.17, | ||
'unique_products_bought': 2113, | ||
'unique_products_bought_with_coupons': 924, | ||
'total_items_bought': 5841 | ||
}, | ||
'coupons': [ | ||
{'coupon_id': '116', 'coupon_type': 'department', 'department': 'Boys', 'discount': 64, | ||
'how_many_products_required': 1, 'product_mean_price': 11.53 , 'products_available': 609}, | ||
{'coupon_id': '203', 'coupon_type': 'buy_all', 'department': 'Boys', 'discount': 65, | ||
'how_many_products_required': 4, 'product_mean_price': 7.85, 'products_available': 4}, | ||
{'coupon_id': '207', 'coupon_type': 'buy_all', 'department': 'Boys', 'discount': 69, | ||
'how_many_products_required': 5, 'product_mean_price': 66.62, 'products_available': 5} | ||
] | ||
} | ||
response = client.post('/score', json=body) | ||
assert response.ok, response.text | ||
expected_coupons = [c['coupon_id'] for c in body['coupons']] | ||
response_coupons = [c['coupon_id'] for c in response.json()] | ||
assert all([ec in response_coupons for ec in expected_coupons]) | ||
response_predictions = [i['prediction'] for i in response.json()] | ||
assert response_predictions == sorted(response_predictions, reverse=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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
fastapi==0.63.0 | ||
pandas==1.1.5 | ||
pytest==6.2.3 | ||
requests==2.25.1 | ||
scikit-learn==0.24.1 | ||
uvicorn[standard]==0.13.4 |
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,16 +1,19 @@ | ||
export ENTRY_EVENT_TOPIC_NAME='ENTRY_EVENTS' | ||
export FOCUS_EVENT_TOPIC_NAME='FOCUS_EVENTS' | ||
export COUPON_PREDICTION_TOPIC_NAME='PREDICTION_RESULTS' | ||
export MQTT_HOST='localhost' | ||
export MQTT_PORT='1883' | ||
|
||
export GROUP_ID=grupa1 | ||
export ENTRY_EVENT_TOPIC_NAME='customer/enter' | ||
export FOCUS_EVENT_TOPIC_NAME='customer/focus' | ||
export COUPON_PREDICTION_TOPIC_NAME='customer/prediction' | ||
|
||
export COUPON_SCORER_URL='http://127.0.0.1:8001/score' | ||
export COUPON_SCORER_URL='http://127.0.0.1:8002/score' | ||
|
||
export TESTING_NO_KAFKA=false | ||
export TESTING_NO_MQTT=false | ||
export TESTING_NO_POSTGRES=false | ||
export TESTING_NO_SCORING_SERVICE=false | ||
|
||
export DB_NAME='recommendation_cache' | ||
export DB_NAME='cache_db' | ||
export DB_USER='postgres' | ||
export DB_PASSWORD='root' | ||
export DB_HOST='127.0.0.1' | ||
export DB_PASSWORD='postgres' | ||
export DB_HOST='localhost' | ||
export DB_PORT='5432' |
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,4 +1 @@ | ||
import logging | ||
|
||
logger = logging.getLogger(__name__) | ||
logger.addHandler(logging.NullHandler()) | ||
from app.config.log_config import logger |
Oops, something went wrong.