def __call__(self,**kwargs): # guard against invalid settings not_allowed = set(kwargs.keys()) - self.all_vars if len(not_allowed)>0: self.error('unrecognized variables provided.\n You provided: '+str(list(not_allowed))+'\n Allowed variables are: '+str(list(vars))) #end if # extract settings based on keyword groups kw = Settings.kw_set(self.project_vars,kwargs) # project settings gamess_kw = Settings.kw_set(self.gamess_vars,kwargs) # gamess settings if len(kwargs)>0: self.error('some settings keywords have not been accounted for\nleftover keywords: {0}\nthis is a developer error'.format(sorted(kwargs.keys()))) #end if # transfer project variables to project base class for name,value in kw.iteritems(): Pobj.__dict__[name] = value #end for # process project manager settings if 'debug' in kw and kw.debug: Pobj.verbose = True #end if if 'mode' in kw: Pobj.set_mode(kw.mode) #end if # process machine settings if 'machine_info' in kw: machine_info = Pobj.machine_info del Pobj.machine_info if isinstance(machine_info,dict) or isinstance(machine_info,obj): for machine_name,minfo in machine_info.iteritems(): mname = machine_name.lower() if Machine.exists(mname): machine = Machine.get(mname) machine.incorporate_user_info(minfo) else: self.error('machine {0} is unknown\n cannot set machine_info'.format(machine_name)) #end if #end for else: self.error('machine_info must be a dict or obj\n you provided type '+machine_info.__class__.__name__) #end if #end if if 'machine' in kw: machine_name = kw.machine if not Machine.exists(machine_name): Pobj.class_error('machine {0} is unknown'.format(machine_name)) #end if Job.machine = machine_name ProjectManager.machine = Machine.get(machine_name) #del Pobj.machine if 'account' in kw: account = Pobj.account #del Pobj.account if not isinstance(account,str): self.error('account for {0} must be a string\n you provided: {1}'.format(machine_name,account)) #end if ProjectManager.machine.account = account #end if if 'machine_mode' in kw: machine_mode = kw.machine_mode if machine_mode in Machine.modes: machine_mode = Machine.modes[machine_mode] #end if if machine_mode==Machine.modes.interactive: if ProjectManager.machine==None: ProjectManager.class_error('no machine specified for interactive mode') #end if if not isinstance(ProjectManager.machine,Supercomputer): self.error('interactive mode is not supported for machine type '+ProjectManager.machine.__class__.__name__) #end if if not 'interactive_cores' in kw: self.error('interactive mode requested, but interactive_cores not set') #end if ProjectManager.machine = ProjectManager.machine.interactive_representation(Pobj.interactive_cores) del Pobj.interactive_cores #end if del Pobj.machine_mode #end if #end if # process simulation settings if 'local_directory' in kw: Pobj.file_locations.append(kw.local_directory) #end if if 'skip_submit' in kw: Pobj.skip_submission = Pobj.skip_submit del Pobj.skip_submit #end if if 'file_locations' in kw: fl = kw.file_locations if isinstance(fl,str): Pobj.file_locations.extend([fl]) else: Pobj.file_locations.extend(list(fl)) #end if #end if if not 'pseudo_dir' in kw: Pobj.pseudopotentials = Pseudopotentials() else: pseudo_dir = kw.pseudo_dir Pobj.file_locations.append(pseudo_dir) if not os.path.exists(pseudo_dir): self.error('pseudo_dir "{0}" does not exist'.format(pseudo_dir),trace=False) #end if files = os.listdir(pseudo_dir) ppfiles = [] for f in files: pf = os.path.join(pseudo_dir,f) if os.path.isfile(pf): ppfiles.append(pf) #end if #end for Pobj.pseudopotentials = Pseudopotentials(ppfiles) #end if # more simulation/project manager settings processing mode = Pobj.mode modes = Pobj.modes if mode==modes.stages: stages = Pobj.stages elif mode==modes.all: stages = list(Pobj.primary_modes) else: stages = [kw.mode] #end if allowed_stages = set(Pobj.primary_modes) if isinstance(stages,str): stages = [stages] #end if if len(stages)==0: stages = list(Pobj.primary_modes) #self.error('variable stages must be a list of primary modes.\n Options are '+str(list(allowed_stages))) elif 'all' in stages: stages = list(Pobj.primary_modes) else: forbidden = set(Pobj.stages)-allowed_stages if len(forbidden)>0: self.error('some stages provided are not primary stages.\n You provided '+str(list(forbidden))+'\n Options are '+str(list(allowed_stages))) #end if #end if Pobj.mode = modes.stages Pobj.stages = stages Pobj.stages_set = set(Pobj.stages) # process gamess settings Gamess.settings(**gamess_kw) return
def __call__(self,**kwargs): NexusCore.write_splash() self.log('Applying user settings') # guard against invalid settings not_allowed = set(kwargs.keys()) - Settings.allowed_vars if len(not_allowed)>0: self.error('unrecognized variables provided.\nYou provided: {0}\nAllowed variables are: {1}'.format(sorted(not_allowed),sorted(Settings.allowed_vars))) #end if # assign simple variables for name in Settings.core_assign_vars: if name in kwargs: nexus_core[name] = kwargs[name] #end if #end for # assign simple variables for name in Settings.noncore_assign_vars: if name in kwargs: nexus_noncore[name] = kwargs[name] #end if #end for # extract settings based on keyword groups kw = Settings.kw_set(Settings.nexus_vars ,kwargs) mach_kw = Settings.kw_set(Settings.machine_vars,kwargs) gamess_kw = Settings.kw_set(Settings.gamess_vars ,kwargs) if len(kwargs)>0: self.error('some settings keywords have not been accounted for\nleftover keywords: {0}\nthis is a developer error'.format(sorted(kwargs.keys()))) #end if # copy input settings self.transfer_from(mach_kw.copy()) self.transfer_from(gamess_kw.copy()) # process machine settings self.process_machine_settings(mach_kw) # process nexus core settings self.process_core_settings(kw) # process nexus noncore settings self.process_noncore_settings(kw) # transfer select core data to the global namespace nexus_core_noncore.transfer_from(nexus_core,nexus_core_noncore.keys()) nexus_noncore.set(**nexus_core_noncore.copy()) # prevent write to core namespace # copy final core and noncore settings self.transfer_from(nexus_core.copy()) self.transfer_from(nexus_noncore.copy()) # process gamess settings Gamess.settings(**gamess_kw) return
def __call__(self, **kwargs): kwargs = obj(**kwargs) # guard against invalid settings not_allowed = set(kwargs.keys()) - Settings.allowed_vars if len(not_allowed) > 0: self.error( 'unrecognized variables provided\nyou provided: {0}\nallowed variables are: {1}' .format(sorted(not_allowed), sorted(Settings.allowed_vars))) #end if # restore default core default settings restore_nexus_core_defaults() # process command line inputs, if any if 'command_line' in kwargs: nexus_core.command_line = kwargs.command_line #end if if nexus_core.command_line: self.process_command_line_settings(kwargs) #end if NexusCore.write_splash() # print version information try: from versions import versions if versions is not None: err, s, serr = versions.check(write=False, full=True) self.log(s) #end if except Exception: None #end try self.log('Applying user settings') # assign simple variables for name in Settings.core_assign_vars: if name in kwargs: nexus_core[name] = kwargs[name] #end if #end for # assign simple variables for name in Settings.noncore_assign_vars: if name in kwargs: nexus_noncore[name] = kwargs[name] #end if #end for # extract settings based on keyword groups kw = Settings.kw_set(Settings.nexus_vars, kwargs) mach_kw = Settings.kw_set(Settings.machine_vars, kwargs) gamess_kw = Settings.kw_set(Settings.gamess_vars, kwargs) pwscf_kw = Settings.kw_set(Settings.pwscf_vars, kwargs) qm_pkg_kw = Settings.kw_set(Settings.qm_package_vars, kwargs) if len(kwargs) > 0: self.error( 'some settings keywords have not been accounted for\nleftover keywords: {0}\nthis is a developer error' .format(sorted(kwargs.keys()))) #end if # copy input settings self.transfer_from(mach_kw.copy()) self.transfer_from(gamess_kw.copy()) self.transfer_from(pwscf_kw.copy()) # process machine settings self.process_machine_settings(mach_kw) # process nexus core settings self.process_core_settings(kw) # process nexus noncore settings self.process_noncore_settings(kw) # transfer select core data to the global namespace nexus_core_noncore.transfer_from(nexus_core, list(nexus_core_noncore.keys())) nexus_noncore.set( **nexus_core_noncore.copy()) # prevent write to core namespace # copy final core and noncore settings self.transfer_from(nexus_core.copy()) self.transfer_from(nexus_noncore.copy()) # process gamess settings Gamess.restore_default_settings() Gamess.settings(**gamess_kw) # process pwscf settings Pwscf.restore_default_settings() Pwscf.settings(**pwscf_kw) # process quantum package settings QuantumPackage.restore_default_settings() QuantumPackage.settings(**qm_pkg_kw) return
def __call__(self, **kwargs): NexusCore.write_splash() self.log('Applying user settings') # guard against invalid settings not_allowed = set(kwargs.keys()) - Settings.allowed_vars if len(not_allowed) > 0: self.error( 'unrecognized variables provided\nyou provided: {0}\nallowed variables are: {1}' .format(sorted(not_allowed), sorted(Settings.allowed_vars))) #end if # assign simple variables for name in Settings.core_assign_vars: if name in kwargs: nexus_core[name] = kwargs[name] #end if #end for # assign simple variables for name in Settings.noncore_assign_vars: if name in kwargs: nexus_noncore[name] = kwargs[name] #end if #end for # extract settings based on keyword groups kw = Settings.kw_set(Settings.nexus_vars, kwargs) mach_kw = Settings.kw_set(Settings.machine_vars, kwargs) gamess_kw = Settings.kw_set(Settings.gamess_vars, kwargs) pwscf_kw = Settings.kw_set(Settings.pwscf_vars, kwargs) if len(kwargs) > 0: self.error( 'some settings keywords have not been accounted for\nleftover keywords: {0}\nthis is a developer error' .format(sorted(kwargs.keys()))) #end if # copy input settings self.transfer_from(mach_kw.copy()) self.transfer_from(gamess_kw.copy()) self.transfer_from(pwscf_kw.copy()) # process machine settings self.process_machine_settings(mach_kw) # process nexus core settings self.process_core_settings(kw) # process nexus noncore settings self.process_noncore_settings(kw) # transfer select core data to the global namespace nexus_core_noncore.transfer_from(nexus_core, nexus_core_noncore.keys()) nexus_noncore.set( **nexus_core_noncore.copy()) # prevent write to core namespace # copy final core and noncore settings self.transfer_from(nexus_core.copy()) self.transfer_from(nexus_noncore.copy()) # process gamess settings Gamess.settings(**gamess_kw) # process pwscf settings Pwscf.settings(**pwscf_kw) return