luismidv commited on
Commit
8eddf3d
·
1 Parent(s): b525680

New commit

Browse files
Files changed (4) hide show
  1. __pycache__/resultview.cpython-311.pyc +0 -0
  2. app.py +3 -2
  3. resultview.py +3 -1
  4. try.py +15 -4
__pycache__/resultview.cpython-311.pyc CHANGED
Binary files a/__pycache__/resultview.cpython-311.pyc and b/__pycache__/resultview.cpython-311.pyc differ
 
app.py CHANGED
@@ -7,10 +7,11 @@ app = FastAPI()
7
 
8
 
9
  @app.post("/predict/")
10
- async def predict(id:str = Query(..., description = "The ID for prediction")):
11
  try:
12
  print("Request received")
13
- tenant_json = rv.algo_start(int(id))
 
14
  return tenant_json
15
 
16
  except Exception as error:
 
7
 
8
 
9
  @app.post("/predict/")
10
+ async def predict(id:str):
11
  try:
12
  print("Request received")
13
+ tenant_list = rv.algo_start(int(1))
14
+ tenant_json = rv.json_convert(tenant_list)
15
  return tenant_json
16
 
17
  except Exception as error:
resultview.py CHANGED
@@ -54,10 +54,12 @@ def algo_start(id):
54
  #sm.data_checking(dataframe)
55
  similarity_matrix = sm.encoder_matrix(dataframe, min_range = 0, max_range=100)
56
  tenant_list = tenant_inference(similarity_matrix, id,original_dataframe)
57
- json_convert(tenant_list)
 
58
  #tenant_visualization(similarity_matrix, [20,40,50,18,15])
59
 
60
  def json_convert(tenant_list):
 
61
  #THE ALGO START FUNCTION COULD BE DOING THIS DIRECTLY, IS A POSSIBLE IMPROVEMENT IF THE WEB ISN'T WORKING FAST ENOUGH
62
 
63
  tenants_dict = {
 
54
  #sm.data_checking(dataframe)
55
  similarity_matrix = sm.encoder_matrix(dataframe, min_range = 0, max_range=100)
56
  tenant_list = tenant_inference(similarity_matrix, id,original_dataframe)
57
+ return tenant_list
58
+ #json_convert(tenant_list)
59
  #tenant_visualization(similarity_matrix, [20,40,50,18,15])
60
 
61
  def json_convert(tenant_list):
62
+ print("Entering json_convert")
63
  #THE ALGO START FUNCTION COULD BE DOING THIS DIRECTLY, IS A POSSIBLE IMPROVEMENT IF THE WEB ISN'T WORKING FAST ENOUGH
64
 
65
  tenants_dict = {
try.py CHANGED
@@ -2,11 +2,22 @@ import requests
2
  import resultview as rv
3
  import json
4
  import pandas as pd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- url = "https://luismidv-mlsystemtfg.hf.space/predict/"
7
- params = {"id": 1}
8
- response = requests.post(url, params)
9
- print(response)
10
 
11
 
12
 
 
2
  import resultview as rv
3
  import json
4
  import pandas as pd
5
+ from urllib.parse import urlencode
6
+
7
+ # url = "https://luismidv-mlsystemtfg.hf.space/predict/"
8
+ # params = {"id": str(1)}
9
+
10
+ # full_url = f"{url}?{urlencode(params)}"
11
+ # print(f"Final url {full_url}")
12
+
13
+ # response = requests.post(url, params = params)
14
+ # print(response)
15
+
16
+ tenant_list = rv.algo_start(1)
17
+ tenant_json = rv.json_convert(tenant_list)
18
+ print(tenant_json)
19
+
20
 
 
 
 
 
21
 
22
 
23