Beispiel #1
0
class JobConfigField:
    ConfigField = load_json_ordered('jobconfigfield.json')

    def __init__(self):
        pass

    def config_to_field(self, config):
        field = gui.field.load(self.ConfigField)
        children = field.children
        children[0].value = config['typename']
        children[1].value = config.get('cmd', '')
        jobconfig = config.get('config', '')
        if type(jobconfig) is str:
            children[2].value = jobconfig
        else:
            children[2] = gui.field.CompositeField('batch')
            for batchconfig in jobconfig:
                curfield = self.config_to_field(batchconfig)
                curfield.parent = children[2]
        children[3].value = config.get('argv', [])
        children[4].value = config.get('wd', '.')
        return field

    def field_to_config(self, field):
        pass
Beispiel #2
0
 def open_configfile(self, configfile):
     configfile = path.fullfile(configfile)
     if not os.path.isfile(configfile):
         print('cannot open file {}'.format(configfile))
         return
     self.configfile_path = configfile
     configdict = load_json_ordered(configfile)
     self.load_configdict(configdict)
Beispiel #3
0
 def cb_menu_Open(self):
     resname = tktools.askopenfilename()
     if resname:
         configdict = load_json_ordered(resname)
         self.rootfield = self.connector.config_to_field(configdict)
         self.mainfieldwidget = self.rootfield.build_widget(self.mainframe)
         self.set_mainwidget(self.mainfieldwidget)
         self.mainfieldwidget.pack()
Beispiel #4
0
class OneJobConnector(gui.configfield.DefaultSimpleConnector):
    """Connector for one job."""
    JobConfigField = load_json_ordered(
        os.path.join(ThisDir, 'jobconfigfield.json'))

    def __init__(self):
        """Init the onejob connector."""
        super().__init__(self.JobConfigField)
Beispiel #5
0
def test_load_save(jobfile):
    jconf = load_json_ordered(jobfile)
    print(jconf)
    j = run_jobconf(jconf)

    outd = job.dump(j)
    print(outd)
    run_jobconf(outd)
    save_json_ordered('saved_' + jobfile, outd)
Beispiel #6
0
class ParaConfigFieldConnector(gui.configfield.DefaultSimpleConnector):
    """Parallel config field connector, for configpara in GUI."""
    # the config field dict
    ParaConfigField = load_json_ordered(
        os.path.join(ThisDir, 'paraconfigfield.json'))

    def __init__(self):
        """Init the connector using config dict."""
        super().__init__(self.ParaConfigField)
Beispiel #7
0
 def open_configfile(self, configfile):
     configfile = path.fullfile(configfile)
     if not os.path.isfile(configfile):
         print('cannot open file {}'.format(configfile))
         return
     self.configfile_path = configfile
     configdict = load_json_ordered(configfile)
     self.rootfield = self.connector.config_to_field(configdict)
     self.mainfieldwidget = self.rootfield.build_widget(self.mainframe)
     self.set_mainwidget(self.mainfieldwidget)
     self.mainfieldwidget.pack()
Beispiel #8
0
class BatchJobConfigField:
    JobConfigField = load_json_ordered('jobconfigfield.json')

    def __init__(self):
        pass

    def config_to_field(self, config):
        assert config['typename'] == 'BatchJob'
        jobconfigs = config.get('config')
        rootfield = gui.field.CompositeField('Batch')
        for jobconfig in jobconfigs:
            field = gui.field.create(self.JobConfigField, rootfield)
            field.name = jobconfig['name']
            children = field.children
            children[0].value = jobconfig['typename']
            children[1].value = jobconfig.get('cmd', '')
            subconfig = jobconfig.get('config', '')
            print(subconfig)
            if type(subconfig) is not str:
                raise Exception('Nested BatchJob GUI not supported')
            children[2].value = subconfig
            children[3].value = jobconfig.get('argv', [])
            children[4].value = jobconfig.get('wd', '.')
        return rootfield
Beispiel #9
0
        rootfield = gui.field.CompositeField('Batch')
        for jobconfig in jobconfigs:
            field = gui.field.create(self.JobConfigField, rootfield)
            field.name = jobconfig['name']
            children = field.children
            children[0].value = jobconfig['typename']
            children[1].value = jobconfig.get('cmd', '')
            subconfig = jobconfig.get('config', '')
            print(subconfig)
            if type(subconfig) is not str:
                raise Exception('Nested BatchJob GUI not supported')
            children[2].value = subconfig
            children[3].value = jobconfig.get('argv', [])
            children[4].value = jobconfig.get('wd', '.')
        return rootfield


if __name__ == '__main__':
    connector = BatchJobConfigField()
    #jobconfigfile = 'config_job.json'
    jobconfigfile = 'config_alljob.json'

    config = load_json_ordered(jobconfigfile)
    field = connector.config_to_field(config)
    # modify field
    root = tk.Tk()
    w = field.build_widget(root)
    w.pack()

    configout = connector.field_to_config(field)
Beispiel #10
0
def load_json_nonraise(jfile):
    """Load json with out exception. Return None if failed to load."""
    if os.path.isfile(jfile):
        return load_json_ordered(jfile)
    return None
Beispiel #11
0
def create_by_files(mainconfigfile, dataconfigfile):
	"""Create exporter by config files."""
	mainconfig = load_json_ordered(mainconfigfile)
	dataconfig = load_json_ordered(dataconfigfile)
	return MRIScanProcExporter(mainconfig, dataconfig)
Beispiel #12
0
def check_modal(modal, mainconfigfile):
	mainconfig = load_json_ordered(mainconfigfile)
	if modal not in mainconfig['input_folders'].keys():
		raise Exception('modal %s not valid (%s)' % (modal, list(mainconfig['input_folders'].keys())))
Beispiel #13
0
 def cb_run(self):
     paraconf = self.fpara.value
     pathconf = self.fpath.value
     os.environ['MMDPS_PROJECTPATH'] = pathconf
     j = para.load(load_json_ordered(paraconf))
     j.run()
Beispiel #14
0
def runjob_with_file(configfile, folder=None):
    currentJob = create_from_dict(load_json_ordered(configfile))
    runjob(currentJob, folder)