Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _exec_action(self, action):
args_value = eval_expr(action['args'], pipeline=self.pipeline)
kwargs_value = eval_expr(action['kwargs'], pipeline=self.pipeline)
if action['name'] in ACTIONS:
method = getattr(self, ACTIONS[action['name']])
method(action)
else:
method = self.pipeline.get_method(action['name'])
if method is None:
raise ValueError("Unknown method: %s" % action['name'])
res = method(*args_value, **kwargs_value)
if isinstance(action['save_to'], NamedExpression):
action['save_to'].set(res, pipeline=self.pipeline)
elif isinstance(action['save_to'], np.ndarray):
action['save_to'][:] = res
def _call_function(self, job, iteration, experiment):
function = eval_expr(self.function, job=job, iteration=iteration, experiment=experiment)
if callable(function):
args = eval_expr(self.args, job=job, iteration=iteration, experiment=experiment)
kwargs = eval_expr(self.kwargs, job=job, iteration=iteration, experiment=experiment)
result = function(*args, **kwargs)
else:
result = function
self.put_result(iteration, result)
return result
def _call_function(self, job, iteration, experiment):
function = eval_expr(self.function, job=job, iteration=iteration, experiment=experiment)
if callable(function):
args = eval_expr(self.args, job=job, iteration=iteration, experiment=experiment)
kwargs = eval_expr(self.kwargs, job=job, iteration=iteration, experiment=experiment)
result = function(*args, **kwargs)
else:
result = function
self.put_result(iteration, result)
return result
def update_domain(self, path):
""" Update domain by `update_func`. If returns None, domain will not be updated. """
kwargs = eval_expr(self.update_kwargs, path=path)
return self.update_func(**kwargs)
def _eval_expr(self, expr, batch=None):
return eval_expr(expr, batch=batch, pipeline=self)
def _exec_action(self, action):
args_value = eval_expr(action['args'], pipeline=self.pipeline)
kwargs_value = eval_expr(action['kwargs'], pipeline=self.pipeline)
if action['name'] in ACTIONS:
method = getattr(self, ACTIONS[action['name']])
method(action)
else:
method = self.pipeline.get_method(action['name'])
if method is None:
raise ValueError("Unknown method: %s" % action['name'])
res = method(*args_value, **kwargs_value)
if isinstance(action['save_to'], NamedExpression):
action['save_to'].set(res, pipeline=self.pipeline)
elif isinstance(action['save_to'], np.ndarray):
action['save_to'][:] = res
def _call_function(self, job, iteration, experiment):
function = eval_expr(self.function, job=job, iteration=iteration, experiment=experiment)
if callable(function):
args = eval_expr(self.args, job=job, iteration=iteration, experiment=experiment)
kwargs = eval_expr(self.kwargs, job=job, iteration=iteration, experiment=experiment)
result = function(*args, **kwargs)
else:
result = function
self.put_result(iteration, result)
return result
def _eval_expr(self, expr, batch=None):
return eval_expr(expr, batch=batch, pipeline=self)
def eval_expr(self, expr, batch=None):
""" Evaluate all named expressions in a given data structure """
return eval_expr(expr, batch=batch)