DavidD003 commited on
Commit
49646a9
1 Parent(s): 73c1c0e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -7
app.py CHANGED
@@ -5,6 +5,7 @@ import SchedBuilderClasses2 as cls
5
  #Just in case:
6
  import openpyxl as pyxl
7
  import pandas as pd
 
8
  import numpy as np
9
  from copy import deepcopy
10
 
@@ -14,7 +15,26 @@ def PrimeVisualTemplate(vTmplFl,FTrefFl,TempRefFl):
14
  primedTemplateName=tls.translate_Visual_Template(vTmplFl,FTrefFl,TempRefFl)
15
  return primedTemplateName,primedTemplateName,datetime.now(),datetime.now(),FTrefFl.name,TempRefFl.name #Return twice so as to send file to two interface entities (file holders), plus time stampers, return the refusal sheets to send to B
16
 
17
- def GenerateSchedule(schedWWF,xtraDays,wkHrs,DaysCrew,AssnFl,FTrefFl,TempRefFl,PollFl,stop=None,template=False):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  assnWWF=schedWWF
19
  if assnWWF=='Yes': assnWWF=True
20
  if assnWWF=='No': assnWWF=True
@@ -26,7 +46,7 @@ def GenerateSchedule(schedWWF,xtraDays,wkHrs,DaysCrew,AssnFl,FTrefFl,TempRefFl,P
26
  mySched.proofEligVol()
27
  mySched.proofEligVol()#i don't know man i found in testing sometimes it wasnt completing properly the first time around
28
  if template==True: #Case of template viewer
29
- flNm=sch.printToExcel()
30
  return flNm,datetime.now()
31
  sch=mySched.fillOutSched_v3(stop=stop) #Stop is not None when submitted from tab C
32
  flNm=sch.printToExcel()
@@ -51,6 +71,7 @@ with gr.Blocks() as demo:
51
  gr.Markdown("On this tab the inputs are used to generate a weekend schedule. The Template and refusal sheet files are carried over (with slightly garbled names) when generated using tab A. The schedule is considered 'primed' when the tables on the secondary sheets match what is indicated on the visual template. The other inputs on this sheet should be selected per the circumstances. For example. If Friday is part of the weekend to be scheduled, Select '32 hrs', 'Friday', and 'yes to WWF scheduling'. Normal non-long weekend will not assign OT to WWF, and be 40 hour weeks without Friday or Monday to be scheduled.")
52
  with gr.Row():
53
  B_fl_FTref=gr.File(label="Full Time Refusals Sheet")
 
54
  B_fl_Tref=gr.File(label="Temp Refusal Sheet")
55
  with gr.Row():
56
  with gr.Column():
@@ -76,18 +97,21 @@ with gr.Blocks() as demo:
76
  C_fl_T=gr.File(label="Generated Template")
77
  C_tx_Ttimestamp=gr.Textbox(label="File Change Timestamp - Generated Template",placeholder="Waiting for first run.")
78
  with gr.Tab("Force Stop Mid-Scheduling"):
79
- gr.Markdown("On this tab you can observe what a schedule looked like after making a specific number of assignments. Iteration number can be retrieved from the bottom of the verbose assignment list tab of a generated schedule.")
80
  with gr.Row():
81
  with gr.Column():
82
- C_tx_FS = gr.Textbox(label="Time Of Full Schedule Generation",placeholder="N/A")
83
- C_nm_PS = gr.Number(label="Limit Number for Total Assignments")
 
84
  with gr.Column():
85
  C_fl_PS=gr.File(label="Partially Complete Schedule")
 
86
  C_bt_PS = gr.Button("Partially Generate Schedule")
87
 
88
  #######################
89
  #Third Define the Interactions
90
  A_bt_PT.click(PrimeVisualTemplate,[A_fl_VT,A_fl_FTref,A_fl_Tref],[A_fl_PT,B_fl_PT,A_tx_PTtimestamp,B_tx_PTtimestamp,B_fl_FTref,B_fl_Tref])
91
  B_bt_MS.click(GenerateSchedule,[B_wwfOT,B_xtraDay,B_wkHrs,B_dayCrew,B_fl_PT,B_fl_FTref,B_fl_Tref,B_fl_Pl],[B_fl_FS,B_tx_FTtimestamp])
92
- #C_bt_MT.click(GenerateSchedule,[B_wwfOT,B_xtraDay,B_wkHrs,B_dayCrew,B_fl_PT,B_fl_FTref,B_fl_Tref,B_fl_Pl],[C_fl_T,C_tx_Ttimestamp])
93
- demo.launch()
 
 
5
  #Just in case:
6
  import openpyxl as pyxl
7
  import pandas as pd
8
+
9
  import numpy as np
10
  from copy import deepcopy
11
 
 
15
  primedTemplateName=tls.translate_Visual_Template(vTmplFl,FTrefFl,TempRefFl)
16
  return primedTemplateName,primedTemplateName,datetime.now(),datetime.now(),FTrefFl.name,TempRefFl.name #Return twice so as to send file to two interface entities (file holders), plus time stampers, return the refusal sheets to send to B
17
 
18
+ def GenerateSchedule(schedWWF,xtraDays,wkHrs,DaysCrew,AssnFl,FTrefFl,TempRefFl,PollFl,stop1=0,stop2=0,template=False):
19
+ stop=(stop1,stop2)
20
+ assnWWF=schedWWF
21
+ if assnWWF=='Yes': assnWWF=True
22
+ if assnWWF=='No': assnWWF=True
23
+ xtraDays=xtraDays
24
+ Acrew=DaysCrew
25
+ wkHrs=wkHrs
26
+ mySched=tls.preProcessData(Acrew,wkHrs,FTrefFl,TempRefFl,AssnFl,PollFl,assnWWF=assnWWF,xtraDays=xtraDays)
27
+ mySched.evalAssnList()
28
+ mySched.proofEligVol()
29
+ mySched.proofEligVol()#i don't know man i found in testing sometimes it wasnt completing properly the first time around
30
+ if template==True: #Case of template viewer
31
+ flNm=mySched.printToExcel()
32
+ return flNm,datetime.now()
33
+ sch=mySched.fillOutSched_v3(stop=stop) #Stop is not None when submitted from tab C
34
+ flNm=sch.printToExcel()
35
+ return flNm,datetime.now()
36
+
37
+ def GenerateSchedule1(schedWWF,xtraDays,wkHrs,DaysCrew,AssnFl,FTrefFl,TempRefFl,PollFl,stop=None,template=True):
38
  assnWWF=schedWWF
39
  if assnWWF=='Yes': assnWWF=True
40
  if assnWWF=='No': assnWWF=True
 
46
  mySched.proofEligVol()
47
  mySched.proofEligVol()#i don't know man i found in testing sometimes it wasnt completing properly the first time around
48
  if template==True: #Case of template viewer
49
+ flNm=mySched.printToExcel()
50
  return flNm,datetime.now()
51
  sch=mySched.fillOutSched_v3(stop=stop) #Stop is not None when submitted from tab C
52
  flNm=sch.printToExcel()
 
71
  gr.Markdown("On this tab the inputs are used to generate a weekend schedule. The Template and refusal sheet files are carried over (with slightly garbled names) when generated using tab A. The schedule is considered 'primed' when the tables on the secondary sheets match what is indicated on the visual template. The other inputs on this sheet should be selected per the circumstances. For example. If Friday is part of the weekend to be scheduled, Select '32 hrs', 'Friday', and 'yes to WWF scheduling'. Normal non-long weekend will not assign OT to WWF, and be 40 hour weeks without Friday or Monday to be scheduled.")
72
  with gr.Row():
73
  B_fl_FTref=gr.File(label="Full Time Refusals Sheet")
74
+
75
  B_fl_Tref=gr.File(label="Temp Refusal Sheet")
76
  with gr.Row():
77
  with gr.Column():
 
97
  C_fl_T=gr.File(label="Generated Template")
98
  C_tx_Ttimestamp=gr.Textbox(label="File Change Timestamp - Generated Template",placeholder="Waiting for first run.")
99
  with gr.Tab("Force Stop Mid-Scheduling"):
100
+ gr.Markdown("On this tab you can observe what a schedule looked like after making a specific number of assignments. Iteration number can be retrieved from the bottom of the verbose assignment list tab of a generated schedule. If the specified iteration and assignment number combination are not encountered, this function will simply re generate the entire schedule. This function only quits schedule building after the template. An assignment number within the template building portion will not be quit on, and it will proceed to build full schedule.")
101
  with gr.Row():
102
  with gr.Column():
103
+ with gr.Row():
104
+ C_nm_PS = gr.Number(label="Limit Number for Total Assignments")
105
+ C_nm_IN = gr.Number(label="Iteration Number To Stop On")
106
  with gr.Column():
107
  C_fl_PS=gr.File(label="Partially Complete Schedule")
108
+ C_tx_ts2 = gr.Textbox(label="Time Of Partial Schedule Generation",placeholder="N/A")
109
  C_bt_PS = gr.Button("Partially Generate Schedule")
110
 
111
  #######################
112
  #Third Define the Interactions
113
  A_bt_PT.click(PrimeVisualTemplate,[A_fl_VT,A_fl_FTref,A_fl_Tref],[A_fl_PT,B_fl_PT,A_tx_PTtimestamp,B_tx_PTtimestamp,B_fl_FTref,B_fl_Tref])
114
  B_bt_MS.click(GenerateSchedule,[B_wwfOT,B_xtraDay,B_wkHrs,B_dayCrew,B_fl_PT,B_fl_FTref,B_fl_Tref,B_fl_Pl],[B_fl_FS,B_tx_FTtimestamp])
115
+ C_bt_MT.click(GenerateSchedule1,[B_wwfOT,B_xtraDay,B_wkHrs,B_dayCrew,B_fl_PT,B_fl_FTref,B_fl_Tref,B_fl_Pl],[C_fl_T,C_tx_Ttimestamp])
116
+ C_bt_PS.click(GenerateSchedule,[B_wwfOT,B_xtraDay,B_wkHrs,B_dayCrew,B_fl_PT,B_fl_FTref,B_fl_Tref,B_fl_Pl,C_nm_IN,C_nm_PS],[C_fl_PS,C_tx_ts2])
117
+ demo.launch()