-
Notifications
You must be signed in to change notification settings - Fork 0
176 lines (164 loc) · 8.87 KB
/
validate-recipes.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
name: Commit date to master
on: push
jobs:
build_summary:
runs-on: ubuntu-latest
steps:
# Checkout the branch
- name: checkout
uses: actions/checkout@v2 # use either @v2-beta or @master. Eventually there will be a @v2 tag.
- name: setup python
uses: actions/setup-python@v2
- name: build summary
uses: jannekem/run-python-script-action@v1
with:
script: |
import os
os.chdir("Recipes")
import glob
#import numpy as np
def unroll_forloop(results):
results2 = []
endline =0
for i in range(len(results)):
if "FOR " in results[i]:
forCount = int(results[i].split()[1])
startLine = i+1
for repeats in range(forCount):
for nextLine in range(len(results)-i):
if "ENDFOR" in results[startLine+nextLine]:
endline = startLine+nextLine+1
break
else:
results2.append(results[startLine+nextLine])
else:
if i < endline:
pass
else:
results2.append(results[i])
return results2
def read_script(scriptname,parent,tab,state,darks,flat,summary,md,warning,childextension=".rcp"):
#print(f"{scriptname},{parent},{tab},{state},{darks},{flat},{summary},{md},{warning}")
script = open(scriptname,"r")
results = script.readlines()
script.close()
results2 = unroll_forloop(results)
summary.write(f" {tab*6*'-'} > {scriptname.split('#')[0]}\n")
runTime = 0
color = "black"
md.write("read_Script write")
if "_FW" not in scriptname and "setup" not in scriptname and "cbk" not in scriptname and "menu" not in scriptname:
if state['shut'] == "in":
color = "red"
if state['shut'] == "out" and state['calib'] =='out' and state['diffuser'] == "in":
color = "blue"
if state['shut'] == "out" and state['calib'] =='out' and state['diffuser'] == "out":
#print(state)
color = "green"
if color == "red":
md.write("📙 ")
if color == "black":
md.write("📕 ")
if color == "blue":
md.write("📘 ")
if color == "green":
md.write("📗 ")
md.write(f"<details><summary>{scriptname}</summary><blockquote><pre>")
tab = tab +1
for child in results2:
filename =child.split('#')[0].strip()
child=child.strip().lower()
if len(child.strip()) > 0 and child.strip()[0] != "#" and not child.startswith("date") and not child.startswith("author") and not child.startswith("description"):
if childextension in child.split('#')[0]:
try:
runTime += read_script(filename,parent+","+child.split('#')[0],tab,state,darks,flats,summary,md,warning)
# runTime = runTime+runTime2
#md.write(f"read_script out {runTime}")
except FileNotFoundError:
warning.write(f"{parent} tried to call *{filename}* which does not exist\n")
else:
#print(f"{state} {darks} {flat} {parent} {child}")
color = "black"
if "gain" in child:
state['gain'] = "low" if "low" in child else "high"
if "shut" in child:
state['shut'] = "in" if "in" in child else "out"
if "exposure" in child:
state['exposure'] = child.split(" ")[1]
#print(state)
if "cover" in child:
state['cover'] = "in" if "in" in child else "out"
if "occ" in child:
state['occ'] = "in" if "in" in child else "out"
if "calib" in child:
state['calib'] = "in" if "in" in child else "out"
if "diffuser" in child:
state['diffuser'] = "in" if "in" in child else "out"
if "data" in child:
#print(child)
data,cam,cont,wave,sums = child.split()
runTime += 300+int(state['exposure'])*4*int(sums)
if state['shut'] == "in":
color = "red"
if state['exposure']+state['gain']+sums not in darks:
darks.append(state['exposure']+state['gain']+sums)
if state['shut'] == "out" and state['calib'] =='out' and state['diffuser'] == "in":
color = "blue"
if state['gain']+sums+cam+cont+wave not in flats:
flats.append(state['gain']+sums+cam+cont+wave)
if state['shut'] == "out" and state['calib'] =='out' and state['diffuser'] == "out":
#print(state)
color = "green"
if state['exposure']+state['gain']+sums not in darks:
warning.write(f"{parent} {child} missing dark for {state['exposure']+state['gain']+sums}\n")
if state['gain']+sums+cam+cont+wave not in flats:
warning.write(f"{parent} {child} missing flat for {state['gain']+sums+cam+cont+wave}\n")
summary.write(f"{tab*6*'-'}> {child.split('#')[0]}\n")
rcpName = child.split('#')[0]
if "_FW" not in rcpName and "setup" not in rcpName and "cbk" not in rcpName and "menu" not in rcpName:
md.write(f"rcpname {rcpName}")
if color == "red":
md.write("📙 ")
if color == "black":
md.write("📕 ")
if color == "blue":
md.write("📘 ")
if color == "green":
md.write("📗 ")
md.write(f" {child.split('#')[0]} \n")
pass
script.close()
if "rcp" in childextension:
md.write(f"The above code block covers:{runTime/1000/60:.2f} minutes of camera integration + hardware moves and overhead")
md.write("</pre></blockquote></details>")
return runTime
menus = glob.glob("*.menu")
state = {}
darks = []
flats = []
warning = open('warnings.txt',"w")
for menu in menus:
state = {'exposure':"80",'shut':"",'calib':"",'occ':"",'diffuser':"",'gain':"high"}
darks = []
flats = []
md = open(menu.split(".menu")[0]+".md","w")
summary = open(menu.split(".menu")[0]+".summary","w")
quick_menu = open(menu,"r")
qmenu = quick_menu.readlines()
quick_menu.close()
if "NOWARNING" not in "".join(qmenu):
read_script(menu,menu,0,state,darks,flats,summary,md,warning,".cbk")
md.close()
summary.close()
warning.close()
- name: setup git config
run: |
# setup the username and email. I tend to use 'GitHub Actions Bot' with no email by default
git config user.name "GitHub Actions Bot"
git config user.email "<>"
- name: commit
run: |
# Stage the file, commit and push
git add .
git commit -m "Menu files re-summarized" --allow-empty
git push origin main