Ejemplo n.º 1
0
def main(*args, **kwargs):
    additional_functions = {}
    callbacks = FLAGS.f or []
    callbacks += FLAGS.f2 or []
    callbacks += FLAGS.f3 or []
    if callbacks:
        m = import_module('custom_api')
        for fn_name in callbacks:
            try:
                if '#' in fn_name:
                    fn_name = fn_name.split('#')[0]
                additional_functions[fn_name] = m.__dict__[fn_name]
            except KeyError:
                raise KeyError(
                    "Function [{}] couldn't be found in 'custom_api.py'".
                    format(fn_name))
    if FLAGS.mode == 'run':
        return Run.run(*args[0][1:], **additional_functions)
    if FLAGS.mode == 'eval':
        if FLAGS.checkpoint_dir:
            return EvalModelCheckpoint.evaluate(*args[0][1:])
        elif FLAGS.input_dir:
            return EvalDataDirectory.evaluate(*args[0][1:])
        print(("In mode 'eval', parse either '--checkpoint_dir' with '--model'"
               " or '--input_dir' to evaluate models, see details --helpfull"))
Ejemplo n.º 2
0
def main(*args, **kwargs):
  additional_functions = {}
  callbacks = []
  callbacks += FLAGS.f or []
  callbacks += FLAGS.f2 or []
  callbacks += FLAGS.f3 or []
  if callbacks:
    m = import_module('custom_api')
    for fn_name in callbacks:
      try:
        if '#' in fn_name:
          fn_name = fn_name.split('#')[0]
        additional_functions[fn_name] = m.__dict__[fn_name]
      except KeyError:
        raise KeyError(
          "Function [{}] couldn't be found in 'custom_api.py'".format(fn_name))
  return Run.run(*args[0][1:], **additional_functions)
Ejemplo n.º 3
0
def main(*args, **kwargs):
    additional_functions = {}
    if FLAGS.add_custom_callbacks:
        m = import_module('custom_api')
        for fn_name in FLAGS.add_custom_callbacks:
            try:
                additional_functions[fn_name] = m.__dict__[fn_name]
            except KeyError:
                raise KeyError(f"Function [{fn_name}] couldn't be found in 'custom_api.py'")
    if FLAGS.mode == 'run':
        return Run.run(**additional_functions)
    if FLAGS.mode == 'eval':
        if FLAGS.checkpoint_dir:
            return EvalModelCheckpoint.evaluate()
        elif FLAGS.input_dir:
            return EvalDataDirectory.evaluate()
        print(("In mode 'eval', parse either '--checkpoint_dir' with '--model'"
               " or '--input_dir' to evaluate models, see details --helpfull"))