Construct all necessary functions and call run_loop.

  Args:
    flags_obj: Object containing user specified flags.
192831
def run_census(flags_obj, ctx):
  
  train_file = os.path.join(flags_obj.data_dir, census_dataset.TRAINING_FILE)
  test_file = os.path.join(flags_obj.data_dir, census_dataset.EVAL_FILE)

  # Train and evaluate the model every `flags.epochs_between_evals` epochs.
  def train_input_fn():
    return census_dataset.input_fn(
        train_file, flags_obj.epochs_between_evals, True, flags_obj.batch_size)

  def eval_input_fn():
    return census_dataset.input_fn(test_file, 1, False, flags_obj.batch_size)

  tensors_to_log = {
      'average_loss': '{loss_prefix}head/truediv',
      'loss': '{loss_prefix}head/weighted_loss/Sum'
  }

  # Removing run_loop, since we can only invoke train_and_evaluate once
  model_helpers.apply_clean(flags.FLAGS)
  model = build_estimator(
      model_dir=flags_obj.model_dir, model_type=flags_obj.model_type,
      model_column_fn=census_dataset.build_model_columns,
      inter_op=flags_obj.inter_op_parallelism_threads,
      intra_op=flags_obj.intra_op_parallelism_threads,
      ctx=ctx)

  loss_prefix = LOSS_PREFIX.get(flags_obj.model_type, '')
  tensors_to_log = {k: v.format(loss_prefix=loss_prefix)
                    for k, v in tensors_to_log.items()}
  train_hooks = hooks_helper.get_train_hooks(
      flags_obj.hooks, model_dir=flags_obj.model_dir,
      batch_size=flags_obj.batch_size, tensors_to_log=tensors_to_log)

  # Note: this will only be invoked once, so `--epochs_between_evals` is now effectively `--train_epochs`
  # and evaluation will only execute once.
  train_spec = tf.estimator.TrainSpec(input_fn=train_input_fn, hooks=train_hooks)
  eval_spec = tf.estimator.EvalSpec(input_fn=eval_input_fn)
  tf.estimator.train_and_evaluate(model, train_spec, eval_spec)
1181298
def run_recursively_with_fixture(monitor, *flags, &block)
      fixture do |f|
        run_recursively(monitor, f, *flags, &block)
      end
    end
868889
def restrict_flags(declarer, *flags)
      copy = restrict(declarer)
      copy.qualify(*flags)
      copy
    end
96405
def add_flag(var, flag):
    
    if var:
        var = flag + " " + str(var)
    else:
        var = ""
    return var
310369
def runserver(**config_kwargs):
    
    # force a full reload in sub processes so they load an updated version of code, this must be called only once
    set_start_method('spawn')

    config = Config(**config_kwargs)
    config.import_app_factory()
    loop = asyncio.get_event_loop()

    loop.run_until_complete(check_port_open(config.main_port, loop))

    aux_app = create_auxiliary_app(
        static_path=config.static_path_str,
        static_url=config.static_url,
        livereload=config.livereload,
    )

    main_manager = AppTask(config, loop)
    aux_app.on_startup.append(main_manager.start)
    aux_app.on_shutdown.append(main_manager.close)

    if config.static_path:
        static_manager = LiveReloadTask(config.static_path, loop)
        logger.debug('starting livereload to watch %s', config.static_path_str)
        aux_app.on_startup.append(static_manager.start)
        aux_app.on_shutdown.append(static_manager.close)

    url = 'http://{0.host}:{0.aux_port}'.format(config)
    logger.info('Starting aux server at %s ◆', url)

    if config.static_path:
        rel_path = config.static_path.relative_to(os.getcwd())
        logger.info('serving static files from ./%s/ at %s%s', rel_path, url, config.static_url)

    return aux_app, config.aux_port, loop, AuxAccessLogger
1004835
def add_flag(self, flag):
        
        super(Entry, self).add_flag(flag)
        self._changed_attrs.add('flags')
752468
function (flags, callback, args, ms) {
        var status = {},
            sealed;

        // ensure that the callback times out after a while
        callback = backpack.timeback(callback, ms, null, function () {
            sealed = true;
        });

        return function (err, flag, value) {
            if (sealed) { return; } // do  not proceed of it is sealed
            status[flag] = value;

            if (err) { // on error we directly call the callback and seal subsequent calls
                sealed = true;
                status = null;
                callback.call(status, err);

                return;
            }

            // if any flag is not defined, we exit. when all flags hold a value, we know that the end callback has to be
            // executed.
            for (var i = 0, ii = flags.length; i < ii; i++) {
                if (!status.hasOwnProperty(flags[i])) { return; }
            }

            sealed = true;
            status = null;
            callback.apply(status, args);
        };
    }
707765
def get_flags(self, user=None, status=None):
        
        filter_kwargs = {}
        update_filter_dict(filter_kwargs, user, status)
        return self.flags.filter(**filter_kwargs).all()
766427
def __add_flag (rule_or_module, variable_name, condition, values):
    
    assert isinstance(rule_or_module, basestring)
    assert isinstance(variable_name, basestring)
    assert is_iterable_typed(condition, property_set.PropertySet)
    assert is_iterable(values) and all(
        isinstance(v, (basestring, type(None))) for v in values)
    f = Flag(variable_name, values, condition, rule_or_module)

    # Grab the name of the module
    m = __re_first_segment.match (rule_or_module)
    assert m
    module = m.group(1)

    __module_flags.setdefault(module, []).append(f)
    __flags.setdefault(rule_or_module, []).append(f)
87453
def flag_arg(key, desc, opts = {}, &block)
            self << ArgParser::FlagArgument.new(key, desc, opts, &block)
        end
1234752
function run () {
  if (argv.file) {
    const models = require(argv.file)
    return validate(models)
  }

  const json = argv.model || argv.references
  if (json) {
    return validate(JSON.parse(json))
  }

  printUsage()
  process.exit(1)
}
149583
def __argv_flag_dec(func, default=False, quiet=QUIET, indent=False):
    
    from utool import util_decor
    flagname = meta_util_six.get_funcname(func)
    if flagname.find('no') == 0:
        flagname = flagname[2:]

    flags = (
        '--' + flagname.replace('_', '-'),
        '--' + flagname,
    )

    @util_decor.ignores_exc_tb(outer_wrapper=False)
    def GaurdWrapper(*args, **kwargs):
        from utool import util_print
        # FIXME: the --print-all is a hack
        default_ = kwargs.pop('default', default)
        alias_flags = kwargs.pop('alias_flags', [])
        is_flagged = (get_argflag(flags, default_) or
                      get_argflag('--print-all') or
                      any([get_argflag(_) for _ in alias_flags]))
        if flagname in kwargs:
            is_flagged = kwargs.pop(flagname)
        if is_flagged:
            func_label = flags[0].replace('--', '').replace('print-', '')
            # print('')
            print('\n+ --- ' + func_label + ' ___')
            use_indent = indent is not False
            if indent is True:
                indent_ = '[%s]' % func_label
            else:
                indent_ = indent
            with util_print.Indenter(indent_, enabled=use_indent):
                ret = func(*args, **kwargs)
            print('L ___ ' + func_label + '___\n')
            return ret
        else:
            PRINT_DISABLED_FLAGDEC = not get_argflag(
                '--noinform', help_='does not print disabled flag decorators')
            if not quiet and PRINT_DISABLED_FLAGDEC:
                #print('\n~~~ %s ~~~' % flag)
                print('~~~ %s ~~~' % flags[0])
    meta_util_six.set_funcname(GaurdWrapper, meta_util_six.get_funcname(func))
    return GaurdWrapper
302482
def flags_as_args():
  """"""
  if hasattr(FLAGS, "flag_values_dict"):
    args_dict = FLAGS.flag_values_dict()
  else:
    args_dict = dict(FLAGS.__dict__["__flags"])
  del args_dict["cloud_mlengine"]
  # Configured later
  del args_dict["t2t_usr_dir"]
  args_dict.pop("h", None)
  args_dict.pop("helpfull", None)
  args_dict.pop("helpshort", None)
  args_dict.pop("help", None)
  args = []
  for name, val in args_dict.items():
    if val is None:
      continue
    if name.startswith("autotune"):
      continue
    args.extend(["--%s=%s" % (name, str(val))])
  return args
916643
def _set_flags(self, **flags):
        '''
        
        '''
        self._flags = enum.IntEnum('_flags', flags)
        self.__dict__.update(self._flags.__members__)
        self._patch_flag_doc()
1044226
def load_flag_values(self, flags=None):
    
    if flags is None:
      flags = self._flags
    for keyval in flags.config_value:
      k, v = keyval.split('=', 1)
      v = self._modules['yaml'].load(v) if isinstance(v, str) else v

      # Force any command line keys and values that are bytes to unicode.
      k = k.decode() if isinstance(k, bytes) else k
      v = v.decode() if isinstance(v, bytes) else v

      self._flag_values.setdefault(k, v)
697280
def set_flags(self):
        
        offset = self.template['flagoffset']//8

        # comm keys provided?
        self.tpl_buff = bytes_transform(self.tpl_buff, offset+1, offset+2, lambda x: self.set_flag_bit(x))
1056377
def append_flag_values(self, flag_values):
    
    for flag_name, flag in six.iteritems(flag_values._flags()):  # pylint: disable=protected-access
      # Each flags with short_name appears here twice (once under its
      # normal name, and again with its short name).  To prevent
      # problems (DuplicateFlagError) with double flag registration, we
      # perform a check to make sure that the entry we're looking at is
      # for its normal name.
      if flag_name == flag.name:
        try:
          self[flag_name] = flag
        except _exceptions.DuplicateFlagError:
          raise _exceptions.DuplicateFlagError.from_flag(
              flag_name, self, other_flag_values=flag_values)