Exemple #1
0
 def wrapper(self, *args, **kwargs):
     # self is an instance of the class
     return Actuator(fn=f)(self,
                           *args,
                           _pypads_env=LoggerEnv(
                               parameter=dict(),
                               experiment_id=get_experiment_id(),
                               run_id=get_run_id()),
                           **kwargs)
Exemple #2
0
 def create_dummy_env(data=None) -> LoggerEnv:
     """
     Create a dummy environment to be used for programmatically called logging instead of hooks
     :param data:
     :return:
     """
     if data is None:
         data = {}
     return LoggerEnv(parameter=dict(),
                      experiment_id=get_experiment_id(),
                      run_id=get_run_id(),
                      data={
                          **data,
                          **{
                              "programmatic": True
                          }
                      })
Exemple #3
0
 def _add_hook(self, hook, config, callback, call: Call, mappings, data=None):
     # For every hook we defined on the given function in out mapping file execute it before running the code
     if not call.has_hook(hook):
         return self._get_env_setter(
             _pypads_env=InjectionLoggerEnv(mappings, hook, callback, call, config.parameters, get_experiment_id(),
                                            get_run_id(), data=data))
     else:
         logger.debug(
             f"{hook} defined hook with config {config} is tracked multiple times on {call}. Ignoring second hooking.")
         return None
Exemple #4
0
class RunObjectModel(BackendObjectModel):
    experiment: Optional[ExperimentReference] = Field(
        default_factory=lambda: get_reference(ExperimentModel())
        if get_experiment_id() is not None else None)
    run: Optional[RunReference] = Field(default_factory=lambda: get_reference(
        RunModel()) if get_run_id() is not None else None)
Exemple #5
0
 def __real_call__(self, *args, _pypads_env: LoggerEnv = None, **kwargs):
     logger.debug("Called on Import function " + str(self))
     _return = super().__real_call__(*args, _pypads_env=_pypads_env or LoggerEnv(parameter=dict(),
                                                                                 experiment_id=get_experiment_id(),
                                                                                 run_id=get_run_id(),
                                                                                 data={"category: ImportLogger"}),
                                     **kwargs)
     return _return