def set_environment(verbose=False): hostname = platform.node() env_file = path(__file__).parent.joinpath("environments").joinpath("env_vars.yml") if not env_file.exists(): if verbose: print "env_vars file not found." return else: envs = yaml.load(env_file.open()) resolve_env_vars(envs) for k, v in envs.iteritems(): original_values = os.environ.get(k, "").split(":") if v: values = v else: values = [] combined_values = [v for v in values + original_values if v] os.environ[k] = ":".join(combined_values) if verbose: print "ENV:: ", k, " = ", os.environ[k]
def __init__(self, out_path, exe_path, params, time=10080, priority=1, connection=None, verbose=False, test=False, env='BaseTrial.yml'): self._connection = None if connection: self.connection = connection self.test = test self.verbose = verbose self.out_path = out_path self.exe_path = exe_path self.id_ = None self.priority = priority self.time = time if isinstance(params, dict): params = sorted(list(params.iteritems())) self.params = sorted(params) if verbose: print self.params sha1 = hashlib.sha1(str((self.exe_path, self.params))) self.hash_path = path(sha1.hexdigest()) env_file = path('./environments') / path(env) self.wrap_path = path('./') if env_file.isfile(): env = yaml.load(open(env_file)) self.env = env resolve_env_vars(env) if self.verbose: print 'outpath before sub ', self.out_path self.out_path = resolve(env, self.out_path) self.wrap_path = resolve(env, Trial.MANAGER) self.python_path = resolve(env, Trial.WORK) / 'local/bin/python' elif verbose: print 'No Enviroment path found' if self.verbose: print 'exe path, out path, ', self.exe_path, self.out_path