def dpf(self): """ generates the 'dpf' distillates file 3 runs, 1 run for a each line in a uPMU """ inigen = IniGen() fields = algorithm_fields.algorithms['dpf'] output_uuid_map = {} # set up global parameters algorithm_path = fields['path'] enabled = "True" inigen.emit_global(algorithm_path, enabled) for i in xrange(1, 4): label = "DPF{0}".format(str(i)) lAng_label = 'L{0}ANG'.format(str(i)) cAng_label = 'C{0}ANG'.format(str(i)) distillate_label = get_distillate_label([lAng_label, cAng_label]) # header inigen.emit_run_header(label, CHUNKING, MINTIME, MAXTIME) # body dep_lAng_label = lAng_label dep_lAng_name = fields['deps'][0] dep_lAng_uuid = self.uuid_map[lAng_label] dep_cAng_label = cAng_label dep_cAng_name = fields['deps'][1] dep_cAng_uuid = self.uuid_map[cAng_label] deps = [[dep_lAng_label, dep_lAng_name, dep_lAng_uuid], [dep_cAng_label, dep_cAng_name, dep_cAng_uuid]] param_section_name = fields['params'][0] param_section_value = "Production/{0}/{1}/{2}".format( self.location, self.name, distillate_label) param_name_name = fields['params'][1] param_name_value = "DPF" params = [[param_section_name, param_section_value], [param_name_name, param_name_value]] outputs = fields['outputs'] emitted = inigen.emit_run_body(deps, params, outputs) output_uuid_map[label] = emitted[-2][-36:] filename = "{0}/DPF_{1}.ini".format(self.dirname, self.name) inigen.generate_file(filename) return output_uuid_map
def angle_difference(self): """ generates the 'angle_difference' distillates file 6 runs, one for each ANG stream Difference calculated relative to reference upmu """ inigen = IniGen() fields = algorithm_fields.algorithms['angle_difference'] output_uuid_map = {} # set up global parameters algorithm_path = fields['path'] enabled = "True" inigen.emit_global(algorithm_path, enabled) for label in self.uuid_map: if label == 'LSTATE' or 'MAG' in label: continue distillate_label = get_distillate_label([label]) # header inigen.emit_run_header(label, CHUNKING, MINTIME, MAXTIME) # body dep_ref_label = "{0} {1}".format(label, self.ref_name) dep_ref_name = fields['deps'][0] dep_ref_uuid = self.reference_uuid_map[label] dep_label = "{0} {1}".format(label, self.name) dep_name = fields['deps'][1] dep_uuid = self.uuid_map[label] deps = [[dep_ref_label, dep_ref_name, dep_ref_uuid], [dep_label, dep_name, dep_uuid]] param_section_name = fields['params'][0] param_section_value = "Production/{0}/{1}/{2}/{3}".format( self.location, self.ref_name, self.name, distillate_label) param_name_name = fields['params'][1] param_name_value = "ANGLE-DIFF" params = [[param_section_name, param_section_value], [param_name_name, param_name_value]] outputs = fields['outputs'] emitted = inigen.emit_run_body(deps, params, outputs) output_uuid_map[label] = emitted[-2][-36:] filename = "{0}/ANG-DIFF_{1}.ini".format(self.dirname, self.name) inigen.generate_file(filename) return output_uuid_map
def frequency(self): """ generates the 'frequency' distillates file 1 run, on L1ANG """ inigen = IniGen() fields = algorithm_fields.algorithms['frequency'] output_uuid_map = {} # set up global parameters algorithm_path = fields['path'] enabled = "True" inigen.emit_global(algorithm_path, enabled) for label in self.uuid_map: if label == 'LSTATE': distillate_label = label else: distillate_label = get_distillate_label([label]) if 'ANG' not in distillate_label: continue # header inigen.emit_run_header(label, CHUNKING, MINTIME, MAXTIME) # body dep_label = label dep_name = fields['deps'][0] dep_uuid = self.uuid_map[label] deps = [[dep_label, dep_name, dep_uuid]] param_section_name = fields['params'][0] param_section_value = "Production/{0}/{1}/{2}".format( self.location, self.name, distillate_label) param_name_name = fields['params'][1] param_name_value = "FREQ" params = [[param_section_name, param_section_value], [param_name_name, param_name_value]] outputs = fields['outputs'] emitted = inigen.emit_run_body(deps, params, outputs) output_uuid_map[label + "_1-SEC"] = emitted[-3][-36:] output_uuid_map[label + "_C37"] = emitted[-2][-36:] filename = "{0}/FREQ_{1}.ini".format(self.dirname, self.name) inigen.generate_file(filename) return output_uuid_map
def clean(self): """ generates the 'clean' distillates file 13 runs, one for each stream returns a mapping from original names to newly created clean uuids """ inigen = IniGen() fields = algorithm_fields.algorithms['clean'] # list of output uuids for cleaning distillate output_uuid_map = {} # set up global parameters algorithm_path = fields['path'] enabled = "True" inigen.emit_global(algorithm_path, enabled) for label in self.uuid_map: # header inigen.emit_run_header(label, CHUNKING, MINTIME, MAXTIME) # body dep_label = label dep_name = fields['deps'][0] dep_uuid = self.uuid_map[label] deps = [[dep_label, dep_name, dep_uuid]] param_section_name = fields['params'][0] param_section_value = "Clean/{0}".format(self.name_raw) param_name_name = fields['params'][1] param_name_value = label param_type_name = fields['params'][2] param_type_value = get_stream_type(label) params = [[param_section_name, param_section_value], [param_name_name, param_name_value], [param_type_name, param_type_value]] outputs = fields['outputs'] emitted = inigen.emit_run_body(deps, params, outputs) output_uuid_map[label] = emitted[-2][-36:] filename = "{0}/CLEAN_{1}.ini".format(self.dirname, self.name) inigen.generate_file(filename) return output_uuid_map
def angle_difference(self): """ generates the 'angle_difference' distillates file 6 runs, one for each ANG stream Difference calculated relative to reference upmu """ inigen = IniGen() fields = algorithm_fields.algorithms['angle_difference'] output_uuid_map = {} # set up global parameters algorithm_path = fields['path'] enabled = "True" inigen.emit_global(algorithm_path, enabled) for label in self.uuid_map: if label == 'LSTATE': distillate_label = label else: distillate_label = get_distillate_label([label]) # header inigen.emit_run_header(label, CHUNKING, MINTIME, MAXTIME) # body dep_ref_label = "{0} {1}".format(label, self.ref_name) dep_ref_name = fields['deps'][0] dep_ref_uuid = self.reference_uuid_map[label] dep_label = "{0} {1}".format(label, self.name) dep_name = fields['deps'][1] dep_uuid = self.uuid_map[label] deps = [[dep_ref_label, dep_ref_name, dep_ref_uuid], [dep_label, dep_name, dep_uuid]] param_section_name = fields['params'][0] param_section_value = "Production/{0}/{1}/{2}/{3}".format(self.location, self.ref_name, self.name, distillate_label) param_name_name = fields['params'][1] param_name_value = "ANGLE-DIFF" params = [[param_section_name, param_section_value], [param_name_name, param_name_value]] outputs = fields['outputs'] emitted = inigen.emit_run_body(deps, params, outputs) output_uuid_map[label] = emitted[-2][-36:] filename = "{0}/ANG-DIFF_{1}.ini".format(self.dirname, self.name) inigen.generate_file(filename) return output_uuid_map
def dpf(self): """ generates the 'dpf' distillates file 3 runs, 1 run for a each line in a uPMU """ inigen = IniGen() fields = algorithm_fields.algorithms['dpf'] output_uuid_map = {} # set up global parameters algorithm_path = fields['path'] enabled = "True" inigen.emit_global(algorithm_path, enabled) for i in xrange(1,4): label = "DPF{0}".format(str(i)) lAng_label = 'L{0}ANG'.format(str(i)) cAng_label = 'C{0}ANG'.format(str(i)) distillate_label = get_distillate_label([lAng_label, cAng_label]) # header inigen.emit_run_header(label, CHUNKING, MINTIME, MAXTIME) # body dep_lAng_label = lAng_label dep_lAng_name = fields['deps'][0] dep_lAng_uuid = self.uuid_map[lAng_label] dep_cAng_label = cAng_label dep_cAng_name = fields['deps'][1] dep_cAng_uuid = self.uuid_map[cAng_label] deps = [[dep_lAng_label, dep_lAng_name, dep_lAng_uuid], [dep_cAng_label, dep_cAng_name, dep_cAng_uuid]] param_section_name = fields['params'][0] param_section_value = "Production/{0}/{1}/{2}".format(self.location, self.name, distillate_label) param_name_name = fields['params'][1] param_name_value = "DPF" params = [[param_section_name, param_section_value], [param_name_name, param_name_value]] outputs = fields['outputs'] emitted = inigen.emit_run_body(deps, params, outputs) output_uuid_map[label] = emitted[-2][-36:] filename = "{0}/DPF_{1}.ini".format(self.dirname, self.name) inigen.generate_file(filename) return output_uuid_map
def frequency(self): """ generates the 'frequency' distillates file 1 run, on L1ANG """ inigen = IniGen() fields = algorithm_fields.algorithms['frequency'] output_uuid_map = {} # set up global parameters algorithm_path = fields['path'] enabled = "True" inigen.emit_global(algorithm_path, enabled) for label in self.uuid_map: if label == 'LSTATE': distillate_label = label else: distillate_label = get_distillate_label([label]) if 'ANG' not in distillate_label: continue # header inigen.emit_run_header(label, CHUNKING, MINTIME, MAXTIME) # body dep_label = label dep_name = fields['deps'][0] dep_uuid = self.uuid_map[label] deps = [[dep_label, dep_name, dep_uuid]] param_section_name = fields['params'][0] param_section_value = "Production/{0}/{1}/{2}".format(self.location, self.name, distillate_label) param_name_name = fields['params'][1] param_name_value = "FREQ" params = [[param_section_name, param_section_value], [param_name_name, param_name_value]] outputs = fields['outputs'] emitted = inigen.emit_run_body(deps, params, outputs) output_uuid_map[label+"_1-SEC"] = emitted[-3][-36:] output_uuid_map[label+"_C37"] = emitted[-2][-36:] filename = "{0}/FREQ_{1}.ini".format(self.dirname, self.name) inigen.generate_file(filename) return output_uuid_map
def sequence(self): """ generates the 'sequence' distillates file 1 run for a uPMU """ inigen = IniGen() fields = algorithm_fields.algorithms['sequence'] output_uuid_map = {} # set up global parameters algorithm_path = fields['path'] enabled = "True" inigen.emit_global(algorithm_path, enabled) label = "SEQ" for t in ['C', 'L']: run_label = label + '_' + t t1Mag_label = '{0}1MAG'.format(t) t2Mag_label = '{0}2MAG'.format(t) t3Mag_label = '{0}3MAG'.format(t) t1Ang_label = '{0}1ANG'.format(t) t2Ang_label = '{0}2ANG'.format(t) t3Ang_label = '{0}3ANG'.format(t) distillate_label = "{0}-ALL".format(t) # header inigen.emit_run_header(run_label, CHUNKING, MINTIME, MAXTIME) # body dep_1Mag_label = t1Mag_label dep_1Mag_name = fields['deps'][0] dep_1Mag_uuid = self.uuid_map[t1Mag_label] dep_2Mag_label = t2Mag_label dep_2Mag_name = fields['deps'][1] dep_2Mag_uuid = self.uuid_map[t2Mag_label] dep_3Mag_label = t3Mag_label dep_3Mag_name = fields['deps'][2] dep_3Mag_uuid = self.uuid_map[t3Mag_label] dep_1Ang_label = t1Ang_label dep_1Ang_name = fields['deps'][3] dep_1Ang_uuid = self.uuid_map[t1Ang_label] dep_2Ang_label = t2Ang_label dep_2Ang_name = fields['deps'][4] dep_2Ang_uuid = self.uuid_map[t2Ang_label] dep_3Ang_label = t3Ang_label dep_3Ang_name = fields['deps'][5] dep_3Ang_uuid = self.uuid_map[t3Ang_label] deps = [[dep_1Mag_label, dep_1Mag_name, dep_1Mag_uuid], [dep_2Mag_label, dep_2Mag_name, dep_2Mag_uuid], [dep_3Mag_label, dep_3Mag_name, dep_3Mag_uuid], [dep_1Ang_label, dep_1Ang_name, dep_1Ang_uuid], [dep_2Ang_label, dep_2Ang_name, dep_2Ang_uuid], [dep_3Ang_label, dep_3Ang_name, dep_3Ang_uuid]] param_section_name = fields['params'][0] param_section_value = "Production/{0}/{1}/{2}".format( self.location, self.name, distillate_label) param_name_name = fields['params'][1] param_name_value = "SEQ" params = [[param_section_name, param_section_value], [param_name_name, param_name_value]] outputs = fields['outputs'] emitted = inigen.emit_run_body(deps, params, outputs) output_uuid_map["ZER_{0}ANG".format(t)] = emitted[-9][-36:] output_uuid_map["ZER_{0}MAG".format(t)] = emitted[-8][-36:] output_uuid_map["POS_{0}ANG".format(t)] = emitted[-7][-36:] output_uuid_map["POS_{0}MAG".format(t)] = emitted[-6][-36:] output_uuid_map["NEG_{0}ANG".format(t)] = emitted[-5][-36:] output_uuid_map["NEG_{0}MAG".format(t)] = emitted[-4][-36:] output_uuid_map["UNB_{0}NEG".format(t)] = emitted[-3][-36:] output_uuid_map["UNB_{0}ZER".format(t)] = emitted[-2][-36:] filename = "{0}/SEQ_{1}.ini".format(self.dirname, self.name) inigen.generate_file(filename) return output_uuid_map
def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.inigen = IniGen() self.initUIGlobals()
class IniGenGui(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.inigen = IniGen() self.initUIGlobals() def initUIGlobals(self): """ This is the first part of the window to be rendered. After these have been set by the user and 'Emit Globals' has been clicked, the given algorithm can then specify how to generate the second part of the window. All fields are disabled for user input after globals have been emitted. Information in Global Parameters: Algorithm - name of the algorithm to use File Name - name of the output file to be generated Min Time - Minimum Time for distillers to run Max Time - Maximum Time for distillers to run Set Enabled: - checkbox to specify if the distiller should be enabled True or False """ self.parent.title("Ini Generator") Style().configure("TButton", padding=(0, 5, 0, 5), font='serif 10') # initialize row counter. This is incremented after each element added to grid row = 0 # initialize column counter. This is incremented after a column has been filled self.column = 0 # Globals: entries for info common to all runs label_globals = Label(self, text="Globals") label_globals.grid(row=row, column=self.column) row += 1 label_alg = Label(self, text="Algorithm") label_alg.grid(row=row, column=self.column, sticky=E + W) row += 1 self.cbox_alg = Combobox(self, values=algorithms.keys(), state='readonly') self.cbox_alg.current(0) self.cbox_alg.grid(row=row, column=self.column, sticky=E + W + S + N) row += 1 label_filename = Label(self, text="Output File Name") label_filename.grid(row=row, column=self.column, sticky=E + W) row += 1 self.entry_filename = Entry(self) self.entry_filename.grid(row=row, column=self.column, sticky=W + E) row += 1 label_mintime = Label(self, text="Min Time") label_mintime.grid(row=row, column=self.column, sticky=E + W) row += 1 self.entry_mintime = Entry(self) self.entry_mintime.grid(row=row, column=self.column, sticky=W + E) row += 1 label_maxtime = Label(self, text="Max Time") label_maxtime.grid(row=row, column=self.column, sticky=W + E) row += 1 self.entry_maxtime = Entry(self) self.entry_maxtime.grid(row=row, column=self.column, sticky=W + E) row += 1 self.enabled = IntVar() self.check_enabled = Checkbutton(self, text="set enabled", variable=self.enabled) self.check_enabled.grid(row=row, column=self.column, sticky=W + E) row += 1 # Control: buttons used to emmiting text and generating file self.button_emit_globals = Button(self, text="Emit Globals", command=self.emit_globals) self.button_emit_globals.grid(row=row, column=self.column, sticky=W + E) row += 1 button_addrun = Button(self, text="Add Run", command=self.emit_run) button_addrun.grid(row=row, column=self.column, sticky=W + E) row += 1 button_generate = Button(self, text="Generate File", command=self.generate_file) button_generate.grid(row=row, column=self.column, sticky=W + E) row += 1 self.column += 1 self.pack() def initUIRuns(self): """ Second part of gui to be rendered. This contains all the fields needed to emit a single run within a distiller file. Multiple runs can be added by clicking 'Add Run' multiple times. Information in Run Parameters: Run Name - header name for run Dependencies - description and uuid fields for each dependency in the algorithm Params - parameter fields for each parameter in the algorithm """ self.entry_run_name = None self.entries_dep_description = [] self.entries_dep_uuid = [] self.entries_param = [] row = 0 label_runs = Label(self, text="Runs") label_runs.grid(row=row, column=self.column) row += 1 label_run_name = Label(self, text="Run Name") label_run_name.grid(row=row, column=self.column, sticky=W + E) row += 1 self.entry_run_name = Entry(self) self.entry_run_name.grid(row=row, column=self.column, sticky=W + E) row += 1 algorithm = self.cbox_alg.get() settings = algorithms[algorithm] for dep in settings['deps']: if row >= 21: self.column += 1 row = 1 label_dep_description = Label(self, text="{0} (description)".format(dep)) label_dep_description.grid(row=row, column=self.column, sticky=W + E) row += 1 entry_dep_description = Entry(self) entry_dep_description.grid(row=row, column=self.column, sticky=W + E) row += 1 label_dep_uuid = Label(self, text="{0} (uuid)".format(dep)) label_dep_uuid.grid(row=row, column=self.column, sticky=W + E) row += 1 entry_dep_uuid = Entry(self) entry_dep_uuid.grid(row=row, column=self.column, sticky=W + E) row += 1 self.entries_dep_description.append(entry_dep_description) self.entries_dep_uuid.append(entry_dep_uuid) for param in settings['params']: if row >= 21: self.column += 1 row = 1 label_param = Label(self, text=param) label_param.grid(row=row, column=self.column, sticky=W + E) row += 1 entry_param = Entry(self) entry_param.grid(row=row, column=self.column, sticky=W + E) row += 1 self.entries_param.append(entry_param) row = 0 self.column += 1 self.text_file = Text(self) self.text_file.grid(row=row, column=self.column, rowspan=31, sticky=W + E + N + S, padx=5, pady=5) self.column += 1 scrollbar = Scrollbar(self, command=self.text_file.yview) self.text_file.config(yscrollcommand=scrollbar.set) scrollbar.grid(row=row, column=self.column, rowspan=31, sticky=N + S) self.pack() def emit_globals(self): self.algorithm = algorithms[self.cbox_alg.get()] path = self.algorithm['path'] if self.enabled.get(): enabled = 'True' else: enabled = 'False' lines = self.inigen.emit_global(path, enabled) self.mintime = self.entry_mintime.get() self.maxtime = self.entry_maxtime.get() self.cbox_alg.configure(state='disabled') self.entry_filename.configure(state='disabled') self.entry_mintime.configure(state='disabled') self.entry_maxtime.configure(state='disabled') self.check_enabled.configure(state='disabled') self.button_emit_globals.configure(state='disabled') self.initUIRuns() self.update_text(lines) def emit_run(self): label = self.entry_run_name.get() chunking = 'parallel' #hardcoded for now mintime = self.mintime maxtime = self.maxtime lines = self.inigen.emit_run_header(label, chunking, mintime, maxtime) self.update_text(lines) deps = [] for i in range(len(self.entries_dep_description)): deps.append([ self.entries_dep_description[i].get(), self.algorithm['deps'][i], self.entries_dep_uuid[i].get() ]) params = [] for i in range(len(self.entries_param)): params.append( [self.algorithm['params'][i], self.entries_param[i].get()]) outputs = self.algorithm['outputs'] lines = self.inigen.emit_run_body(deps, params, outputs) self.update_text(lines) def generate_file(self): self.inigen.generate_file(self.entry_filename.get()) self.quit() def update_text(self, lines): self.text_file.configure(state='normal') string = "\n".join(lines) self.text_file.insert(END, string) self.text_file.configure(state='disabled')
def sequence(self): """ generates the 'sequence' distillates file 1 run for a uPMU """ inigen = IniGen() fields = algorithm_fields.algorithms['sequence'] output_uuid_map = {} # set up global parameters algorithm_path = fields['path'] enabled = "True" inigen.emit_global(algorithm_path, enabled) label = "SEQ" for t in ['C','L']: run_label = label+'_'+t t1Mag_label = '{0}1MAG'.format(t) t2Mag_label = '{0}2MAG'.format(t) t3Mag_label = '{0}3MAG'.format(t) t1Ang_label = '{0}1ANG'.format(t) t2Ang_label = '{0}2ANG'.format(t) t3Ang_label = '{0}3ANG'.format(t) distillate_label = "{0}-ALL".format(t) # header inigen.emit_run_header(run_label, CHUNKING, MINTIME, MAXTIME) # body dep_1Mag_label = t1Mag_label dep_1Mag_name = fields['deps'][0] dep_1Mag_uuid = self.uuid_map[t1Mag_label] dep_2Mag_label = t2Mag_label dep_2Mag_name = fields['deps'][1] dep_2Mag_uuid = self.uuid_map[t2Mag_label] dep_3Mag_label = t3Mag_label dep_3Mag_name = fields['deps'][2] dep_3Mag_uuid = self.uuid_map[t3Mag_label] dep_1Ang_label = t1Ang_label dep_1Ang_name = fields['deps'][3] dep_1Ang_uuid = self.uuid_map[t1Ang_label] dep_2Ang_label = t2Ang_label dep_2Ang_name = fields['deps'][4] dep_2Ang_uuid = self.uuid_map[t2Ang_label] dep_3Ang_label = t3Ang_label dep_3Ang_name = fields['deps'][5] dep_3Ang_uuid = self.uuid_map[t3Ang_label] deps = [[dep_1Mag_label, dep_1Mag_name, dep_1Mag_uuid], [dep_2Mag_label, dep_2Mag_name, dep_2Mag_uuid], [dep_3Mag_label, dep_3Mag_name, dep_3Mag_uuid], [dep_1Ang_label, dep_1Ang_name, dep_1Ang_uuid], [dep_2Ang_label, dep_2Ang_name, dep_2Ang_uuid], [dep_3Ang_label, dep_3Ang_name, dep_3Ang_uuid]] param_section_name = fields['params'][0] param_section_value = "Production/{0}/{1}/{2}".format(self.location, self.name, distillate_label) param_name_name = fields['params'][1] param_name_value = "SEQ" params = [[param_section_name, param_section_value], [param_name_name, param_name_value]] outputs = fields['outputs'] emitted = inigen.emit_run_body(deps, params, outputs) output_uuid_map["ZER_{0}ANG".format(t)] = emitted[-9][-36:] output_uuid_map["ZER_{0}MAG".format(t)] = emitted[-8][-36:] output_uuid_map["POS_{0}ANG".format(t)] = emitted[-7][-36:] output_uuid_map["POS_{0}MAG".format(t)] = emitted[-6][-36:] output_uuid_map["NEG_{0}ANG".format(t)] = emitted[-5][-36:] output_uuid_map["NEG_{0}MAG".format(t)] = emitted[-4][-36:] output_uuid_map["UNB_{0}NEG".format(t)] = emitted[-3][-36:] output_uuid_map["UNB_{0}ZER".format(t)] = emitted[-2][-36:] filename = "{0}/SEQ_{1}.ini".format(self.dirname, self.name) inigen.generate_file(filename) return output_uuid_map
from algorithm_fields import algorithms from inigen import IniGen import re from uuid import UUID gen = IniGen() print "* * * Welcome to the config file generation UI * * *\n" print "- - - Global Settings - - - " prompt_text = 'Generated config file name: ' filename = raw_input(prompt_text) prompt_text = ['Algorithm:'] for alg in algorithms.keys(): prompt_text.append('\t- {0}'.format(alg)) prompt_text.append('-> ') prompt_text = "\n".join(prompt_text) while True: algorithm = raw_input(prompt_text) if algorithm not in algorithms.keys(): print "Invalid algorithm. Select one from the list" else: break prompt_text = 'Enabled (True or False): ' while True: enabled = raw_input(prompt_text) if enabled not in ['True', 'False']: print "Invalid boolean. Select 'True' or 'False'" else: break
class IniGenGui(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.inigen = IniGen() self.initUIGlobals() def initUIGlobals(self): """ This is the first part of the window to be rendered. After these have been set by the user and 'Emit Globals' has been clicked, the given algorithm can then specify how to generate the second part of the window. All fields are disabled for user input after globals have been emitted. Information in Global Parameters: Algorithm - name of the algorithm to use File Name - name of the output file to be generated Min Time - Minimum Time for distillers to run Max Time - Maximum Time for distillers to run Set Enabled: - checkbox to specify if the distiller should be enabled True or False """ self.parent.title("Ini Generator") Style().configure("TButton", padding=(0, 5, 0, 5), font='serif 10') # initialize row counter. This is incremented after each element added to grid row = 0 # initialize column counter. This is incremented after a column has been filled self.column = 0 # Globals: entries for info common to all runs label_globals = Label(self, text="Globals") label_globals.grid(row=row, column=self.column) row += 1 label_alg = Label(self, text="Algorithm") label_alg.grid(row=row, column=self.column, sticky=E+W) row += 1 self.cbox_alg = Combobox(self, values=algorithms.keys(), state='readonly') self.cbox_alg.current(0) self.cbox_alg.grid(row=row, column=self.column, sticky=E+W+S+N) row += 1 label_filename = Label(self, text="Output File Name") label_filename.grid(row=row, column=self.column, sticky=E+W) row += 1 self.entry_filename = Entry(self) self.entry_filename.grid(row=row, column=self.column, sticky=W+E) row += 1 label_mintime = Label(self, text="Min Time") label_mintime.grid(row=row, column=self.column, sticky=E+W) row += 1 self.entry_mintime = Entry(self) self.entry_mintime.grid(row=row, column=self.column, sticky=W+E) row += 1 label_maxtime = Label(self, text="Max Time") label_maxtime.grid(row=row, column=self.column, sticky=W+E) row += 1 self.entry_maxtime = Entry(self) self.entry_maxtime.grid(row=row, column=self.column, sticky=W+E) row += 1 self.enabled = IntVar() self.check_enabled = Checkbutton(self, text="set enabled", variable=self.enabled) self.check_enabled.grid(row=row, column=self.column, sticky=W+E) row += 1 # Control: buttons used to emmiting text and generating file self.button_emit_globals = Button(self, text="Emit Globals", command=self.emit_globals) self.button_emit_globals.grid(row=row, column=self.column, sticky=W+E) row += 1 button_addrun = Button(self, text="Add Run", command=self.emit_run) button_addrun.grid(row=row, column=self.column, sticky=W+E) row += 1 button_generate = Button(self, text="Generate File", command=self.generate_file) button_generate.grid(row=row, column=self.column, sticky=W+E) row += 1 self.column += 1 self.pack() def initUIRuns(self): """ Second part of gui to be rendered. This contains all the fields needed to emit a single run within a distiller file. Multiple runs can be added by clicking 'Add Run' multiple times. Information in Run Parameters: Run Name - header name for run Dependencies - description and uuid fields for each dependency in the algorithm Params - parameter fields for each parameter in the algorithm """ self.entry_run_name = None self.entries_dep_description = [] self.entries_dep_uuid = [] self.entries_param = [] row = 0 label_runs = Label(self, text="Runs") label_runs.grid(row=row, column=self.column) row += 1 label_run_name = Label(self, text="Run Name") label_run_name.grid(row=row, column=self.column, sticky=W+E) row += 1 self.entry_run_name = Entry(self) self.entry_run_name.grid(row=row, column=self.column, sticky=W+E) row += 1 algorithm = self.cbox_alg.get() settings = algorithms[algorithm] for dep in settings['deps']: if row >= 21: self.column += 1 row = 1 label_dep_description = Label(self, text="{0} (description)".format(dep)) label_dep_description.grid(row=row, column=self.column, sticky=W+E) row += 1 entry_dep_description = Entry(self) entry_dep_description.grid(row=row, column=self.column, sticky=W+E) row += 1 label_dep_uuid = Label(self, text="{0} (uuid)".format(dep)) label_dep_uuid.grid(row=row, column=self.column, sticky=W+E) row += 1 entry_dep_uuid = Entry(self) entry_dep_uuid.grid(row=row, column=self.column, sticky=W+E) row += 1 self.entries_dep_description.append(entry_dep_description) self.entries_dep_uuid.append(entry_dep_uuid) for param in settings['params']: if row >= 21: self.column += 1 row = 1 label_param = Label(self, text=param) label_param.grid(row=row, column=self.column, sticky=W+E) row += 1 entry_param = Entry(self) entry_param.grid(row=row, column=self.column, sticky=W+E) row += 1 self.entries_param.append(entry_param) row = 0 self.column += 1 self.text_file = Text(self) self.text_file.grid(row=row, column=self.column, rowspan=31, sticky=W+E+N+S, padx=5, pady=5) self.column += 1 scrollbar = Scrollbar(self, command=self.text_file.yview) self.text_file.config(yscrollcommand=scrollbar.set) scrollbar.grid(row=row, column=self.column, rowspan=31, sticky=N+S) self.pack() def emit_globals(self): self.algorithm = algorithms[self.cbox_alg.get()] path = self.algorithm['path'] if self.enabled.get(): enabled = 'True' else: enabled = 'False' lines = self.inigen.emit_global(path, enabled) self.mintime = self.entry_mintime.get() self.maxtime = self.entry_maxtime.get() self.cbox_alg.configure(state='disabled') self.entry_filename.configure(state='disabled') self.entry_mintime.configure(state='disabled') self.entry_maxtime.configure(state='disabled') self.check_enabled.configure(state='disabled') self.button_emit_globals.configure(state='disabled') self.initUIRuns() self.update_text(lines) def emit_run(self): label = self.entry_run_name.get() chunking = 'parallel' #hardcoded for now mintime = self.mintime maxtime = self.maxtime lines = self.inigen.emit_run_header(label, chunking, mintime, maxtime) self.update_text(lines) deps = [] for i in range(len(self.entries_dep_description)): deps.append([self.entries_dep_description[i].get(), self.algorithm['deps'][i], self.entries_dep_uuid[i].get()]) params = [] for i in range(len(self.entries_param)): params.append([self.algorithm['params'][i], self.entries_param[i].get()]) outputs = self.algorithm['outputs'] lines = self.inigen.emit_run_body(deps, params, outputs) self.update_text(lines) def generate_file(self): self.inigen.generate_file(self.entry_filename.get()) self.quit() def update_text(self, lines): self.text_file.configure(state='normal') string = "\n".join(lines) self.text_file.insert(END, string) self.text_file.configure(state='disabled')