Source code for pychemia.evaluator

import os as _os
import shutil as _shutil
import subprocess as _subprocess
from abc import ABCMeta, abstractmethod, abstractproperty
from .function import FunctionEvaluator, FunctionObjectiveFunction
from .cluster import cluster_worker, cluster_evaluator, cluster_launcher
from .cluster_fireball import cluster_fb_evaluator, cluster_fb_launcher, cluster_fb_worker
from .direct_evaluator import DirectEvaluator
from .Fireball2PyChemiaDB import FireballCollector


[docs]def execute(basedir, command, script): """ Utility that copy a given script and execute the given command inside the directory :param basedir: (str) Basedir of the directory with script :param command: (str) Command to execute :param script: (str) Script to call inside basedir """ cwd = _os.getcwd() if not _os.path.isfile(basedir + '/' + _os.path.basename(script)): _shutil.copy(script, basedir) _os.chdir(basedir) print('Executing... ' + command + ' ' + script) _subprocess.call([command, script]) _os.chdir(cwd)
[docs]class Evaluator: __metaclass__ = ABCMeta def __init__(self): self.population = None @abstractmethod
[docs] def initialize(self, population): self.population = population
@abstractmethod
[docs] def run(self): pass
@abstractmethod
[docs] def stop(self): pass
@abstractproperty def is_running(self): pass