def run_and_print_log(workflow, highlight=None): """Run workflow on multi-threaded worker cached with Sqlite3. :param workflow: workflow to evaluate. :param highlight: highlight these lines. """ from noodles.run.threading.sqlite3 import run_parallel from noodles import serial import io import logging log = io.StringIO() log_handler = logging.StreamHandler(log) formatter = logging.Formatter('%(asctime)s - %(message)s') log_handler.setFormatter(formatter) logger = logging.getLogger('noodles') logger.setLevel(logging.INFO) logger.handlers = [log_handler] result = run_parallel(workflow, n_threads=4, registry=serial.base, db_file='tutorial.db', always_cache=True, echo_log=False) display_text(log.getvalue(), highlight or [], split_at=40) return result
def call_default(wf, n_processes=1): """ Run locally using several threads. Caching can be turned off by specifying cache=None """ return run_parallel( wf, n_threads=n_processes, registry=registry, db_file='cache.db', always_cache=True, echo_log=False)
def call_default(wf, n_processes, always_cache): """ Run locally using several threads. Caching can be turned off by specifying cache=None """ return run_parallel(wf, n_threads=n_processes, registry=registry, db_file='cache.db', always_cache=always_cache, echo_log=False)
def _multi_ligand_job(mol: Molecule, psf: PSFContainer, settings: QmSettings, workdir: str, db_file: str, **kwargs: Any) -> CP2KMM_Result: """Helper function for :func:`multi_ligand_job`.""" # Run MATCH on all unique ligands lig_dict = _lig_from_psf(mol, psf) ff: str = kwargs.pop('forcefield', 'top_all36_cgenff_new') rtf_list, prm = _run_match(lig_dict.values(), forcefield=ff) # Update the .psf file with all MATCH results initial_charge = psf.charge.sum() for id_range, rtf_file in zip(lig_dict.keys(), rtf_list): overlay_rtf_file(psf, rtf_file, id_range) # Update the charge _constrain_charge(psf, settings, initial_charge) # Fill in all missing core/ligand lennard-jones parameters with those from UFF # TODO: Connect this with the newly improved Auto-FOX 0.8 parameter guessing schemes prm_to_df(settings) if settings.get('lennard_jones') is not None: _fill_uff(psf, settings['lennard_jones']) elif settings.get('lennard-jones') is not None: _fill_uff(psf, settings['lennard-jones']) # Write the new .prm and .psf files and update the CP2K settings prm_name = join(workdir, 'mol.prm') psf_name = join(workdir, 'mol.psf') prm.write(prm_name) psf.write(psf_name) settings.prm = prm_name settings.psf = psf_name # Run the actual CP2K job with SET_CONFIG_STDOUT: job = cp2k_mm(mol=mol, settings=settings, **kwargs) return run_parallel(job, db_file=db_file, n_threads=1, always_cache=True, registry=registry, echo_log=False)
def call_default(wf: PromisedObject, n_processes: int, always_cache: bool) -> Result: """Run locally using several threads. Caching can be turned off by specifying ``cache=None``. """ # In case 'default_jobmanager' is not set (for some reason) try: workdir = plams.config.get('default_jobmanager').workdir except AttributeError as ex: raise plams.PlamsError( "Failed to initialize the PLAMS jobmanager") from ex db_file = join(workdir, 'cache.db') return run_parallel(wf, n_threads=n_processes, registry=registry, db_file=db_file, always_cache=always_cache, echo_log=False)
def run(wf): result = run_parallel( wf, n_threads=2, registry=registry, db_file=':memory:', always_cache=False) return result