datacipen commited on
Commit
1a0c571
·
verified ·
1 Parent(s): b975450

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -64
app.py CHANGED
@@ -442,25 +442,25 @@ def connexion_France_Travail():
442
  client_secret=os.getenv('POLE_EMPLOI_CLIENT_SECRET'))
443
  return client
444
 
445
- #def API_France_Travail(romeListArray):
446
- # client = connexion_France_Travail()
447
- # todayDate = datetime.datetime.today()
448
- # month, year = (todayDate.month-1, todayDate.year) if todayDate.month != 1 else (12, todayDate.year-1)
449
- # start_dt = todayDate.replace(day=1, month=month, year=year)
450
- # end_dt = datetime.datetime.today()
451
- # results = []
452
- # for k in romeListArray:
453
- # if k[0:1] == ' ':
454
- # k = k[1:]
455
- # params = {"motsCles": k.replace('/', '').replace('-', '').replace(',', '').replace(' ', ','),'minCreationDate': dt_to_str_iso(start_dt),'maxCreationDate': dt_to_str_iso(end_dt),'range':'0-149'}
456
- # try:
457
- # search_on_big_data = client.search(params=params)
458
- # results += search_on_big_data["resultats"]
459
- # except:
460
- # print("Il n'y a pas d'offres d'emploi.")
461
- #
462
- # results_df = pd.DataFrame(results)
463
- # return results_df
464
 
465
  theme_toggle = dmc.Tooltip(
466
  dmc.ActionIcon(
@@ -632,7 +632,6 @@ app.layout = dmc.MantineProvider(
632
  [
633
  html.Div(
634
  children=[
635
- dcc.Store(id="store-emplois"),
636
  dmc.Container(
637
  children=[
638
  dmc.Grid(
@@ -831,30 +830,6 @@ def switch_theme(_, theme):
831
  )
832
  def drawer_demo(n_clicks):
833
  return True
834
-
835
- @callback(
836
- Output("store-emplois", "data"),
837
- Input(component_id='framework-multi-select', component_property='value'),
838
- )
839
- def API_France_Travail(romeListArray):
840
- client = connexion_France_Travail()
841
- todayDate = datetime.datetime.today()
842
- month, year = (todayDate.month-1, todayDate.year) if todayDate.month != 1 else (12, todayDate.year-1)
843
- start_dt = todayDate.replace(day=1, month=month, year=year)
844
- end_dt = datetime.datetime.today()
845
- results = []
846
- for k in romeListArray:
847
- if k[0:1] == ' ':
848
- k = k[1:]
849
- params = {"motsCles": k.replace('/', '').replace('-', '').replace(',', '').replace(' ', ','),'minCreationDate': dt_to_str_iso(start_dt),'maxCreationDate': dt_to_str_iso(end_dt),'range':'0-149'}
850
- try:
851
- search_on_big_data = client.search(params=params)
852
- results += search_on_big_data["resultats"]
853
- except:
854
- print("Il n'y a pas d'offres d'emploi.")
855
-
856
- results_df = pd.DataFrame(results)
857
- return results_df.to_dict('records')
858
 
859
  @callback(
860
  Output(component_id='figRepartition', component_property='figure'),
@@ -865,9 +840,8 @@ def API_France_Travail(romeListArray):
865
  Input(component_id='framework-multi-select', component_property='value'),
866
  Input('figEmplois', 'selectedData'),
867
  Input("mantine-provider", "forceColorScheme"),
868
- Input('store-emplois', 'data')
869
  )
870
- def create_repartition(array_value, selectedData, theme, data):
871
  if theme == "dark":
872
  template = "plotly_dark"
873
  paper_bgcolor = 'rgba(36, 36, 36, 1)'
@@ -877,8 +851,7 @@ def create_repartition(array_value, selectedData, theme, data):
877
  paper_bgcolor = 'rgba(255, 255, 255, 1)'
878
  plot_bgcolor = 'rgba(255, 255, 255, 1)'
879
 
880
- #df_FT = API_France_Travail(array_value)
881
- df_FT = pd.DataFrame(data)
882
 
883
  ######## localisation ########
884
  df = df_FT[['intitule','typeContratLibelle','experienceLibelle','lieuTravail','secteurActiviteLibelle']].copy()
@@ -1087,10 +1060,9 @@ def create_tableau(df, theme):
1087
  Input('figRepartition', 'selectedData'),
1088
  Input(component_id='framework-multi-select', component_property='value'),
1089
  Input("mantine-provider", "forceColorScheme"),
1090
- Input('store-emplois', 'data')
1091
  )
1092
 
1093
- def update_emploi(selectedData, array_value, theme, data):
1094
  options = []
1095
  if selectedData != None:
1096
  if type(selectedData['points'][0]['hovertext']) == str:
@@ -1100,8 +1072,7 @@ def update_emploi(selectedData, array_value, theme, data):
1100
  else:
1101
  options = ['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','2A','2B','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59','60','61','62','63','64','65','66','67','68','69','70','71','72','73','74','75','76','77','78','79','80','81','82','83','84','85','86','87','88','89','90','91','92','93','94','95','971','972','973','974']
1102
 
1103
- #df_FT = API_France_Travail(array_value)
1104
- df_FT = pd.DataFrame(data)
1105
  df = df_FT[['intitule','typeContratLibelle','experienceLibelle','lieuTravail']].copy()
1106
  df["lieuTravail"] = df["lieuTravail"].apply(lambda x: x['libelle']).apply(lambda x: x[0:3]).apply(lambda x: x.strip())
1107
  df.drop(df[df['lieuTravail'] == 'Fra'].index, inplace = True)
@@ -1118,10 +1089,9 @@ def update_emploi(selectedData, array_value, theme, data):
1118
  Input('figRepartition', 'selectedData'),
1119
  Input(component_id='framework-multi-select', component_property='value'),
1120
  Input("mantine-provider", "forceColorScheme"),
1121
- Input('store-emplois', 'data')
1122
  )
1123
 
1124
- def update_contrat(selectedData, array_value, theme, data):
1125
  options = []
1126
  if selectedData != None:
1127
  if type(selectedData['points'][0]['hovertext']) == str:
@@ -1131,8 +1101,7 @@ def update_contrat(selectedData, array_value, theme, data):
1131
  else:
1132
  options = ['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','2A','2B','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59','60','61','62','63','64','65','66','67','68','69','70','71','72','73','74','75','76','77','78','79','80','81','82','83','84','85','86','87','88','89','90','91','92','93','94','95','971','972','973','974']
1133
 
1134
- #df_FT = API_France_Travail(array_value)
1135
- df_FT = pd.DataFrame(data)
1136
  df = df_FT[['intitule','typeContratLibelle','experienceLibelle','lieuTravail']].copy()
1137
  df["lieuTravail"] = df["lieuTravail"].apply(lambda x: x['libelle']).apply(lambda x: x[0:3]).apply(lambda x: x.strip())
1138
  df.drop(df[df['lieuTravail'] == 'Fra'].index, inplace = True)
@@ -1150,10 +1119,9 @@ def update_contrat(selectedData, array_value, theme, data):
1150
  Input('figRepartition', 'selectedData'),
1151
  Input(component_id='framework-multi-select', component_property='value'),
1152
  Input("mantine-provider", "forceColorScheme"),
1153
- Input('store-emplois', 'data')
1154
  )
1155
 
1156
- def update_experience(selectedData, array_value, theme, data):
1157
  options = []
1158
  if selectedData != None:
1159
  if type(selectedData['points'][0]['hovertext']) == str:
@@ -1163,8 +1131,7 @@ def update_experience(selectedData, array_value, theme, data):
1163
  else:
1164
  options = ['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','2A','2B','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59','60','61','62','63','64','65','66','67','68','69','70','71','72','73','74','75','76','77','78','79','80','81','82','83','84','85','86','87','88','89','90','91','92','93','94','95','971','972','973','974']
1165
 
1166
- #df_FT = API_France_Travail(array_value)
1167
- df_FT = pd.DataFrame(data)
1168
  df = df_FT[['intitule','typeContratLibelle','experienceLibelle','lieuTravail']].copy()
1169
  df["lieuTravail"] = df["lieuTravail"].apply(lambda x: x['libelle']).apply(lambda x: x[0:3]).apply(lambda x: x.strip())
1170
  df.drop(df[df['lieuTravail'] == 'Fra'].index, inplace = True)
@@ -1367,17 +1334,15 @@ def clear_input(n_clicks, n_submit):
1367
  [Input("submit", "n_clicks"), Input("user-input", "n_submit")],
1368
  [State("user-input", "value"), State("store-conversation", "data")],
1369
  Input(component_id='framework-multi-select', component_property='value'),
1370
- Input('store-emplois', 'data')
1371
  )
1372
- def run_chatbot(n_clicks, n_submit, user_input, chat_history, array_value, data):
1373
  if n_clicks == 0 and n_submit is None:
1374
  return "", None
1375
 
1376
  if user_input is None or user_input == "":
1377
  return chat_history, None
1378
 
1379
- #df_FT = API_France_Travail(array_value)
1380
- df_FT = pd.DataFrame(data)
1381
 
1382
  df_FT_Select = df_FT[['intitule','typeContratLibelle','experienceLibelle','competences','description','qualitesProfessionnelles','salaire','lieuTravail','formations']].copy()
1383
  list_FT = df_FT_Select.values.tolist()
 
442
  client_secret=os.getenv('POLE_EMPLOI_CLIENT_SECRET'))
443
  return client
444
 
445
+ def API_France_Travail(romeListArray):
446
+ client = connexion_France_Travail()
447
+ todayDate = datetime.datetime.today()
448
+ month, year = (todayDate.month-1, todayDate.year) if todayDate.month != 1 else (12, todayDate.year-1)
449
+ start_dt = todayDate.replace(day=1, month=month, year=year)
450
+ end_dt = datetime.datetime.today()
451
+ results = []
452
+ for k in romeListArray:
453
+ if k[0:1] == ' ':
454
+ k = k[1:]
455
+ params = {"motsCles": k.replace('/', '').replace('-', '').replace(',', '').replace(' ', ','),'minCreationDate': dt_to_str_iso(start_dt),'maxCreationDate': dt_to_str_iso(end_dt),'range':'0-149'}
456
+ try:
457
+ search_on_big_data = client.search(params=params)
458
+ results += search_on_big_data["resultats"]
459
+ except:
460
+ print("Il n'y a pas d'offres d'emploi.")
461
+
462
+ results_df = pd.DataFrame(results)
463
+ return results_df
464
 
465
  theme_toggle = dmc.Tooltip(
466
  dmc.ActionIcon(
 
632
  [
633
  html.Div(
634
  children=[
 
635
  dmc.Container(
636
  children=[
637
  dmc.Grid(
 
830
  )
831
  def drawer_demo(n_clicks):
832
  return True
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
833
 
834
  @callback(
835
  Output(component_id='figRepartition', component_property='figure'),
 
840
  Input(component_id='framework-multi-select', component_property='value'),
841
  Input('figEmplois', 'selectedData'),
842
  Input("mantine-provider", "forceColorScheme"),
 
843
  )
844
+ def create_repartition(array_value, selectedData, theme):
845
  if theme == "dark":
846
  template = "plotly_dark"
847
  paper_bgcolor = 'rgba(36, 36, 36, 1)'
 
851
  paper_bgcolor = 'rgba(255, 255, 255, 1)'
852
  plot_bgcolor = 'rgba(255, 255, 255, 1)'
853
 
854
+ df_FT = API_France_Travail(array_value)
 
855
 
856
  ######## localisation ########
857
  df = df_FT[['intitule','typeContratLibelle','experienceLibelle','lieuTravail','secteurActiviteLibelle']].copy()
 
1060
  Input('figRepartition', 'selectedData'),
1061
  Input(component_id='framework-multi-select', component_property='value'),
1062
  Input("mantine-provider", "forceColorScheme"),
 
1063
  )
1064
 
1065
+ def update_emploi(selectedData, array_value, theme):
1066
  options = []
1067
  if selectedData != None:
1068
  if type(selectedData['points'][0]['hovertext']) == str:
 
1072
  else:
1073
  options = ['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','2A','2B','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59','60','61','62','63','64','65','66','67','68','69','70','71','72','73','74','75','76','77','78','79','80','81','82','83','84','85','86','87','88','89','90','91','92','93','94','95','971','972','973','974']
1074
 
1075
+ df_FT = API_France_Travail(array_value)
 
1076
  df = df_FT[['intitule','typeContratLibelle','experienceLibelle','lieuTravail']].copy()
1077
  df["lieuTravail"] = df["lieuTravail"].apply(lambda x: x['libelle']).apply(lambda x: x[0:3]).apply(lambda x: x.strip())
1078
  df.drop(df[df['lieuTravail'] == 'Fra'].index, inplace = True)
 
1089
  Input('figRepartition', 'selectedData'),
1090
  Input(component_id='framework-multi-select', component_property='value'),
1091
  Input("mantine-provider", "forceColorScheme"),
 
1092
  )
1093
 
1094
+ def update_contrat(selectedData, array_value, theme):
1095
  options = []
1096
  if selectedData != None:
1097
  if type(selectedData['points'][0]['hovertext']) == str:
 
1101
  else:
1102
  options = ['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','2A','2B','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59','60','61','62','63','64','65','66','67','68','69','70','71','72','73','74','75','76','77','78','79','80','81','82','83','84','85','86','87','88','89','90','91','92','93','94','95','971','972','973','974']
1103
 
1104
+ df_FT = API_France_Travail(array_value)
 
1105
  df = df_FT[['intitule','typeContratLibelle','experienceLibelle','lieuTravail']].copy()
1106
  df["lieuTravail"] = df["lieuTravail"].apply(lambda x: x['libelle']).apply(lambda x: x[0:3]).apply(lambda x: x.strip())
1107
  df.drop(df[df['lieuTravail'] == 'Fra'].index, inplace = True)
 
1119
  Input('figRepartition', 'selectedData'),
1120
  Input(component_id='framework-multi-select', component_property='value'),
1121
  Input("mantine-provider", "forceColorScheme"),
 
1122
  )
1123
 
1124
+ def update_experience(selectedData, array_value, theme):
1125
  options = []
1126
  if selectedData != None:
1127
  if type(selectedData['points'][0]['hovertext']) == str:
 
1131
  else:
1132
  options = ['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','2A','2B','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59','60','61','62','63','64','65','66','67','68','69','70','71','72','73','74','75','76','77','78','79','80','81','82','83','84','85','86','87','88','89','90','91','92','93','94','95','971','972','973','974']
1133
 
1134
+ df_FT = API_France_Travail(array_value)
 
1135
  df = df_FT[['intitule','typeContratLibelle','experienceLibelle','lieuTravail']].copy()
1136
  df["lieuTravail"] = df["lieuTravail"].apply(lambda x: x['libelle']).apply(lambda x: x[0:3]).apply(lambda x: x.strip())
1137
  df.drop(df[df['lieuTravail'] == 'Fra'].index, inplace = True)
 
1334
  [Input("submit", "n_clicks"), Input("user-input", "n_submit")],
1335
  [State("user-input", "value"), State("store-conversation", "data")],
1336
  Input(component_id='framework-multi-select', component_property='value'),
 
1337
  )
1338
+ def run_chatbot(n_clicks, n_submit, user_input, chat_history, array_value):
1339
  if n_clicks == 0 and n_submit is None:
1340
  return "", None
1341
 
1342
  if user_input is None or user_input == "":
1343
  return chat_history, None
1344
 
1345
+ df_FT = API_France_Travail(array_value)
 
1346
 
1347
  df_FT_Select = df_FT[['intitule','typeContratLibelle','experienceLibelle','competences','description','qualitesProfessionnelles','salaire','lieuTravail','formations']].copy()
1348
  list_FT = df_FT_Select.values.tolist()