def fn(x: float): with open("/home/jacek/temp.id", "r") as f: TASK_ID = f.read() golem.init(**{"task_id": TASK_ID, **params}) @golem.remote def f(x): return (x - 3) * (x - 2) * (x - 1) * x * (x + 1) * (x + 2) * (x + 3) return golem.get(f.remote(x))
def run_test(class_): golem_remote.init(class_=class_) secret_sauce = "Secret" @golem_remote.remote def func(arg1, arg2, kwarg1="abc", kwarg2="def"): print(f"Running func: {arg1} {arg2} {kwarg1} {kwarg2}") return (arg1 + arg2, kwarg1 + kwarg2, secret_sauce) res_id1 = func.remote(1, 2, kwarg1="abcd") res1 = golem_remote.get(res_id1) self.assertEqual(res1, (1 + 2, "abcd" + "def", secret_sauce))
from hyperopt import fmin, hp from hyperopt.mongoexp import MongoTrials import golem_remote as golem trials = MongoTrials('mongo://localhost:27017/foo_db/jobs', exp_key=str(uuid4())) N = 50 NUM_WORKERS = 4 params = dict(class_=golem.GolemClient, timeout=3000, number_of_subtasks=N, clear_db=False) TASK_ID = golem.init(**params) with open("/home/jacek/temp.id", "w") as f: # for some reason, hyperopt doesn't serialize closures f.write(TASK_ID) def fn(x: float): with open("/home/jacek/temp.id", "r") as f: TASK_ID = f.read() golem.init(**{"task_id": TASK_ID, **params}) @golem.remote def f(x): return (x - 3) * (x - 2) * (x - 1) * x * (x + 1) * (x + 2) * (x + 3)
# or allow auto closing of files after this many max_subtasks: Optional[int] = 10 # these should be detected from environment # but if not detected properly, this option allows to overwrite it needed_packages: Optional[List[str]] = ["tqdm=4.25.0"] ############## # golem init # ############## golem.init( host=host, port=port, user=user, passwd=passwd, timeout=timeout, input_files=input_files, needed_packages=needed_packages ) # golem.init() # this should be possible as well ####################### # function definition # ####################### # per-function timeout; if not set, defaults to golem.DEFAULT_SUBTASK_TIMEOUT func_timeout: Optional[int] = 30