Update app.py
Browse files
app.py
CHANGED
@@ -7,45 +7,7 @@ import numpy as np
|
|
7 |
from copy import deepcopy
|
8 |
#######################
|
9 |
#First define the functions
|
10 |
-
def PrimeVisualTemplate(inp,dummyInp1,dummyInp2):
|
11 |
-
#In real program, all inp files are used in transforming the 'main' input sheet.
|
12 |
-
#After transformation ('priming'), the primed sheet is sent to the 'primed file' container on both tab A and B. And the other sheets that are required for the transformation are also passed along to sheet B
|
13 |
-
#In this dummy program, the main sheet simply has a new sheet added to the workbook
|
14 |
-
#and then the same files are transferred to the same destinations
|
15 |
-
wb = pyxl.load_workbook(filename = 'init.xlsx')
|
16 |
-
ws2 = wb.create_sheet(title="PrimeSheet")
|
17 |
-
PrimedFlNm='primed.xlsx'
|
18 |
-
wb.save(filename = PrimedFlNm)
|
19 |
-
return PrimedFlNm,PrimedFlNm,datetime.now(),datetime.now(),dummyInp1.name,dummyInp2.name
|
20 |
|
21 |
-
def GenerateSchedule(schedWWF,xtraDays,wkHrs,DaysCrew,AssnFl,FTrefFl,TempRefFl,PollFl,stop1=0,stop2=0,template=False):
|
22 |
-
#In the real program, this function is called on tab B and C. Tab B is the main call wherein the schedule is being built
|
23 |
-
#The Tab C call allows for forcing stop mid-schedule build to observe the process in progress
|
24 |
-
#In this dummy program, the function simply generates an array of numbers in the 'PrimeSheet' previously generated
|
25 |
-
#When called from tab C, can stop this enumeration of values by specifying the two indices at which to cancel
|
26 |
-
#The only input used is the 'Primed Template' from previously and the stop condition.
|
27 |
-
stop=(stop1,stop2)
|
28 |
-
wb = pyxl.load_workbook(filename = AssnFl)
|
29 |
-
ws=wb['PrimeSheet']
|
30 |
-
for r in range(1,11):
|
31 |
-
for c in range(1,11):
|
32 |
-
if c==stop1 and r==stop2:
|
33 |
-
flNm='Generated,'+str(c)+','+str(r)+'.xlsx'
|
34 |
-
wb.save(filename = flNm)
|
35 |
-
return flNm, datetime.now()
|
36 |
-
ws.cell(row=r,column=c).value=c*r
|
37 |
-
flNm='Generated.xlsx'
|
38 |
-
wb.save(filename = flNm)
|
39 |
-
return flNm,datetime.now()
|
40 |
-
|
41 |
-
def GenerateSchedule1(schedWWF,xtraDays,wkHrs,DaysCrew,AssnFl,FTrefFl,TempRefFl,PollFl,stop=None,template=True):
|
42 |
-
#In the real program, this function is used to perform a slightly different function, taking all the inputs from tab B
|
43 |
-
#In the dummy program, this simply generates a new sheet indicating it was run
|
44 |
-
wb = pyxl.load_workbook(filename = AssnFl)
|
45 |
-
ws2 = wb.create_sheet(title="Option-C")
|
46 |
-
PrimedFlNm='opt-C.xlsx'
|
47 |
-
wb.save(filename = PrimedFlNm)
|
48 |
-
return PrimedFlNm,datetime.now()
|
49 |
|
50 |
|
51 |
#######################
|
@@ -105,8 +67,8 @@ with gr.Blocks() as demo:
|
|
105 |
|
106 |
#######################
|
107 |
#Third Define the Interactions
|
108 |
-
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])
|
109 |
-
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])
|
110 |
-
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])
|
111 |
-
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])
|
112 |
demo.launch()
|
|
|
7 |
from copy import deepcopy
|
8 |
#######################
|
9 |
#First define the functions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
|
13 |
#######################
|
|
|
67 |
|
68 |
#######################
|
69 |
#Third Define the Interactions
|
70 |
+
#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])
|
71 |
+
#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])
|
72 |
+
#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])
|
73 |
+
#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])
|
74 |
demo.launch()
|