"Frames to process.") # gflags.DEFINE_float( # "hantman_weight_decay", 0.0001, "Weight decay value.") gflags.DEFINE_float("learning_rate", 0.001, "Learning rate.") gflags.DEFINE_integer("hantman_mini_batch", 256, "Mini batch size for training.") # needed to limit how much to process during eval. important for speed purposes. gflags.DEFINE_integer("seq_len", 1500, "Sequence length.") gflags.MarkFlagAsRequired("out_dir") gflags.MarkFlagAsRequired("train_file") gflags.MarkFlagAsRequired("test_file") # gflags.DEFINE_boolean("help", False, "Help") gflags.ADOPT_module_key_flags(arg_parsing) gflags.ADOPT_module_key_flags(flags.cuda_flags) g_label_names = ["lift", "hand", "grab", "supinate", "mouth", "chew"] def _setup_opts(argv): """Parse inputs.""" FLAGS = gflags.FLAGS opts = arg_parsing.setup_opts(argv, FLAGS) # this is dumb... passing in negative numbers to DEFINE_multi_int doesn't # seem to work well. So frames will be a string and split off of spaces. opts["flags"].frames = [ int(frame_num) for frame_num in opts["flags"].frames.split(' ') ]
# See the License for the specific language governing permissions and # limitations under the License. """ADB debugging binary. Call it similar to how you call android's adb. Takes either --serial or --port_path to connect to a device. """ import os import sys import gflags import adb_commands import common_cli gflags.ADOPT_module_key_flags(common_cli) gflags.DEFINE_multistring('rsa_key_path', '~/.android/adbkey', 'RSA key(s) to use') gflags.DEFINE_integer( 'auth_timeout_s', 60, 'Seconds to wait for the dialog to be accepted when using ' 'authenticated ADB.') FLAGS = gflags.FLAGS def GetRSAKwargs(): if FLAGS.rsa_key_path: return { 'rsa_keys': [ adb_commands.M2CryptoSigner(os.path.expanduser(path))
"""Analyze the output directory for a network.""" from __future__ import print_function, division import gflags import helpers.post_processing as post_processing import helpers.arg_parsing as arg_parsing import sys gflags.ADOPT_module_key_flags(arg_parsing) gflags.DEFINE_string("input_dir", None, "Input directory path.") # gflags.DEFINE_boolean("help", False, "Help") gflags.ADOPT_module_key_flags(post_processing) gflags.MarkFlagAsRequired("input_dir") if __name__ == "__main__": FLAGS = gflags.FLAGS FLAGS(sys.argv) if FLAGS.help is True: print(FLAGS) exit() print(FLAGS.input_dir) labels = ['lift', 'hand', 'grab', 'supinate', 'mouth', 'chew'] label_dicts = post_processing.process_outputs(FLAGS.input_dir, "", labels) mean_f = 0 for i in range(len(label_dicts)): tp = float(len(label_dicts[i]['dists'])) fp = float(label_dicts[i]['fp']) fn = float(label_dicts[i]['fn'])
'Whether to check javascript in html files.') flags.DEFINE_boolean('summary', False, 'Whether to show an error count summary.') flags.DEFINE_list( 'additional_extensions', None, 'List of additional file ' 'extensions (not js) that should be treated as ' 'JavaScript files.') flags.DEFINE_boolean( 'multiprocess', platform.system() is 'Linux' and bool(multiprocessing), 'Whether to attempt parallelized linting using the ' 'multiprocessing module. Enabled by default on Linux ' 'if the multiprocessing module is present (Python 2.6+). ' 'Otherwise disabled by default. ' 'Disabling may make debugging easier.') flags.ADOPT_module_key_flags(fileflags) flags.ADOPT_module_key_flags(runner) GJSLINT_ONLY_FLAGS = [ '--unix_mode', '--beep', '--nobeep', '--time', '--check_html', '--summary', '--quiet' ] def _MultiprocessCheckPaths(paths): """Run _CheckPath over mutltiple processes. Tokenization, passes, and checks are expensive operations. Running in a single process, they can only run on one CPU/core. Instead, shard out linting over all CPUs with multiprocessing to parallelize.
"""Helper to create more permanent train/test splits.""" import sys import os import numpy import h5py import gflags import helpers.arg_parsing as arg_parsing import helpers.paths as paths import helpers.git_helper as git_helper import helpers.hantman_mouse as hantman_mouse gflags.ADOPT_module_key_flags(arg_parsing) gflags.DEFINE_string("data", None, "Data to split into train/test") gflags.DEFINE_string("name", None, "Name of the split to use") gflags.DEFINE_boolean("prune", True, "Prune weird videos...") gflags.DEFINE_boolean("one_day", False, "One day of videos") gflags.DEFINE_boolean("one_mouse", False, "One mouse of videos") gflags.DEFINE_string("test_mouse", "M173", "Test mouse for cross validation splits.") gflags.DEFINE_string("test_date", "", "Test date for cross validation splits.") gflags.DEFINE_integer("split_type", None, "Train/Test/Val split type.") gflags.MarkFlagAsRequired("data") gflags.MarkFlagAsRequired("name") gflags.MarkFlagAsRequired("split_type") def create_train_test(opts): """Create the training and testing splits.""" # first setup the output space. The output space will be in the same folder # as the original data.hdf file, but with different names and a seperate
def DeclareExtraKeyFlags(flag_values=FLAGS): """Declares some extra key flags.""" gflags.ADOPT_module_key_flags(module_bar, flag_values=flag_values)
def DeclareExtraKeyFlags(): """Declares some extra key flags.""" flags.ADOPT_module_key_flags(module_bar)
gflags.DEFINE_float("learning_rate", 0.001, "Learning rate.") gflags.DEFINE_integer( "hantman_mini_batch", 256, "Mini batch size for training.") gflags.DEFINE_integer("hantman_seq_length", 1500, "Sequence length.") gflags.DEFINE_boolean("normalize", False, "Normalize data.") gflags.MarkFlagAsRequired("out_dir") gflags.MarkFlagAsRequired("train_file") gflags.MarkFlagAsRequired("test_file") gflags.MarkFlagAsRequired("val_file") gflags.MarkFlagAsRequired("feat_keys") # gflags.DEFINE_boolean("help", False, "Help") gflags.ADOPT_module_key_flags(arg_parsing) gflags.ADOPT_module_key_flags(hantman_hungarian) gflags.ADOPT_module_key_flags(flags.lstm_flags) gflags.ADOPT_module_key_flags(flags.cuda_flags) g_label_names = [ "lift", "hand", "grab", "suppinate", "mouth", "chew" ] def _setup_opts(argv): """Parse inputs.""" FLAGS = gflags.FLAGS opts = arg_parsing.setup_opts(argv, FLAGS)
except NotImplementedError: # google_appengine only provides TemporaryFile return None flags.DEFINE_string( 'database_filename', _SingletonDatabasePath(), 'Path of the save file, currently a serialized protobuf (see ' 'https://developers.google.com/protocol-buffers/docs/overview) ' 'of type pyatdl.ToDoList. If this file\'s ' 'directory does not exist, it will be created. If the file does not exist, ' 'it will be created.') flags.DEFINE_string( 'pyatdl_prompt', 'immaculater> ', 'During interactive use, what text do you want to appear as the command line prompt (like bash\'s $PS1)?' ) flags.ADOPT_module_key_flags(state) flags.ADOPT_module_key_flags(uicmd) class Error(Exception): """Base class for this module's exceptions.""" class NoCommandByThatNameExistsError(Error): """No such command found.""" class BadArgsForCommandError(Error): """Invalid arguments given."""
def parse_args(argv=sys.argv): flags = gflags.FLAGS flags.UseGnuGetOpt() # allow mixing of commands and options gflags.DEFINE_bool("help", None, "Show this help") gflags.DEFINE_bool("helpshort", None, "Show command help only") gflags.DEFINE_bool("version", False, "Show the version and exit") gflags.DEFINE_string("client_id", __API_CLIENT_ID__, "API client_id") gflags.DEFINE_string("client_secret", __API_CLIENT_SECRET__, "API client_secret") gflags.DEFINE_string( "config_folder", None, "Optional directory to load/store all configuration " "information") gflags.DEFINE_bool( "includeRc", False, "Whether to include ~/.gcalclirc when using config_folder") gflags.DEFINE_multistring("calendar", [], "Which calendars to use") gflags.DEFINE_multistring( "default_calendar", [], "Optional default calendar to use if no --calendar " "options are given") gflags.DEFINE_bool("military", False, "Use 24 hour display") # Single --detail that allows you to specify what parts you want gflags.DEFINE_multistring( "details", [], "Which parts to display, can be: " "'all', 'calendar', 'location', 'length', " "'reminders', 'description', 'longurl', 'shorturl', " "'url', 'attendees', 'email'") # old style flags for backwards compatibility gflags.DEFINE_bool("detail_all", False, "Display all details") gflags.DEFINE_bool("detail_calendar", False, "Display calendar name") gflags.DEFINE_bool("detail_location", False, "Display event location") gflags.DEFINE_bool("detail_attendees", False, "Display event attendees") gflags.DEFINE_bool("detail_attachments", False, "Display event attachments") gflags.DEFINE_bool("detail_length", False, "Display length of event") gflags.DEFINE_bool("detail_reminders", False, "Display reminders") gflags.DEFINE_bool("detail_description", False, "Display description") gflags.DEFINE_bool("detail_email", False, "Display creator email") gflags.DEFINE_integer("detail_description_width", 80, "Set description width") gflags.DEFINE_enum("detail_url", None, ["long", "short"], "Set URL output") gflags.DEFINE_bool("tsv", False, "Use Tab Separated Value output") gflags.DEFINE_bool("started", True, "Show events that have started") gflags.DEFINE_bool("declined", True, "Show events that have been declined") gflags.DEFINE_integer("width", 10, "Set output width", short_name="w") gflags.DEFINE_bool("monday", False, "Start the week on Monday") gflags.DEFINE_bool("color", True, "Enable/Disable all color output") gflags.DEFINE_bool("lineart", True, "Enable/Disable line art") gflags.DEFINE_bool("conky", False, "Use Conky color codes") gflags.DEFINE_string("color_owner", "cyan", "Color for owned calendars") gflags.DEFINE_string("color_writer", "green", "Color for writable calendars") gflags.DEFINE_string("color_reader", "magenta", "Color for read-only calendars") gflags.DEFINE_string("color_freebusy", "default", "Color for free/busy calendars") gflags.DEFINE_string("color_date", "yellow", "Color for the date") gflags.DEFINE_string("color_now_marker", "brightred", "Color for the now marker") gflags.DEFINE_string("color_border", "white", "Color of line borders") gflags.DEFINE_string("locale", None, "System locale") gflags.DEFINE_multistring( "reminder", [], "Reminders in the form 'TIME METH' or 'TIME'. TIME " "is a number which may be followed by an optional " "'w', 'd', 'h', or 'm' (meaning weeks, days, hours, " "minutes) and default to minutes. METH is a string " "'popup', 'email', or 'sms' and defaults to popup.") gflags.DEFINE_string("title", None, "Event title") gflags.DEFINE_multistring("who", [], "Event attendees") gflags.DEFINE_string("where", None, "Event location") gflags.DEFINE_string("when", None, "Event time") gflags.DEFINE_integer( "duration", None, "Event duration in minutes or days if --allday is given.") gflags.DEFINE_string("description", None, "Event description") gflags.DEFINE_bool( "allday", False, "If --allday is given, the event will be an all-day event " "(possibly multi-day if --duration is greater than 1). The " "time part of the --when will be ignored.") gflags.DEFINE_bool("prompt", True, "Prompt for missing data when adding events") gflags.DEFINE_bool( "default_reminders", True, "If no --reminder is given, use the defaults. If this is " "false, do not create any reminders.") gflags.DEFINE_bool("iamaexpert", False, "Probably not") gflags.DEFINE_bool("refresh", False, "Delete and refresh cached data") gflags.DEFINE_bool("cache", True, "Execute command without using cache") gflags.DEFINE_bool("verbose", False, "Be verbose on imports", short_name="v") gflags.DEFINE_bool("dump", False, "Print events and don't import", short_name="d") gflags.DEFINE_bool("use_reminders", False, "Honour the remind time when running remind command") gflags.RegisterValidator( "details", lambda value: all(x in [ "all", "calendar", "location", "length", "reminders", "description", "longurl", "shorturl", "url", "attendees", "attachments", "email" ] for x in value)) gflags.RegisterValidator( "reminder", lambda value: all(gcal.parse_reminder(x) for x in value)) gflags.RegisterValidator("color_owner", lambda value: get_color(value) is not None) gflags.RegisterValidator("color_writer", lambda value: get_color(value) is not None) gflags.RegisterValidator("color_reader", lambda value: get_color(value) is not None) gflags.RegisterValidator("color_freebusy", lambda value: get_color(value) is not None) gflags.RegisterValidator("color_date", lambda value: get_color(value) is not None) gflags.RegisterValidator("color_now_marker", lambda value: get_color(value) is not None) gflags.RegisterValidator("color_border", lambda value: get_color(value) is not None) gflags.ADOPT_module_key_flags(gflags) try: if os.path.exists(os.path.expanduser('~/.gcalclirc')): # We want .gcalclirc to be sourced before any other --flagfile # params since we may be told to use a specific config folder, we # need to store generated argv in temp variable tmpArgv = [argv[0], "--flagfile=~/.gcalclirc"] + argv[1:] else: tmpArgv = argv args = flags(tmpArgv) except gflags.FlagsError as e: print_err_msg(str(e)) usage(flags.MainModuleHelp) sys.exit(1) if flags.config_folder: if not os.path.exists(os.path.expanduser(flags.config_folder)): os.makedirs(os.path.expanduser(flags.config_folder)) if os.path.exists( os.path.expanduser("%s/gcalclirc" % flags.config_folder)): if not flags.includeRc: tmpArgv = argv + [ "--flagfile=%s/gcalclirc" % flags.config_folder, ] else: tmpArgv += [ "--flagfile=%s/gcalclirc" % flags.config_folder, ] flags.Reset() args = flags(tmpArgv) return args, flags
from gcutil_lib import route_cmds from gcutil_lib import snapshot_cmds from gcutil_lib import target_instance_cmds from gcutil_lib import target_pool_cmds from gcutil_lib import version_checker from gcutil_lib import whoami from gcutil_lib import zone_cmds FLAGS = flags.FLAGS # This utility will often be run in a VM and the local web server # behavior can be annoying there. FLAGS.SetDefault('auth_local_webserver', False) # Ensure that the help will show global flags from command_base. flags.ADOPT_module_key_flags(command_base) def main(unused_argv): # The real work is performed by the appcommands.Run() method, which # first invokes this method, and then runs the specified command. # Set up early logging configuration format_string = '%(levelname)s: %(message)s' logging.basicConfig(stream=sys.stderr, format=format_string) # Next, register all the commands. address_cmds.AddCommands() basic_cmds.AddCommands() disk_cmds.AddCommands() disk_type_cmds.AddCommands()
#!/usr/bin/env python """Adopts all flags from libfoo and one flag from libbar.""" import gflags from gflags.examples import libbar # pylint: disable=unused-import from gflags.examples import libfoo gflags.DEFINE_integer('num_iterations', 0, 'Number of iterations.') # Declare that all flags that are key for libfoo are # key for this module too. gflags.ADOPT_module_key_flags(libfoo) # Declare that the flag --bar_gfs_path (defined in libbar) is key # for this module. gflags.DECLARE_key_flag('bar_gfs_path')
from closure_linter import errors from closure_linter import javascriptstatetracker from closure_linter import javascripttokenizer from closure_linter.common import error from closure_linter.common import htmlutil from closure_linter.common import tokens flags.DEFINE_list('limited_doc_files', ['dummy.js', 'externs.js'], 'List of files with relaxed documentation checks. Will not ' 'report errors for missing documentation, some missing ' 'descriptions, or methods whose @return tags don\'t have a ' 'matching return statement.') flags.DEFINE_boolean('error_trace', False, 'Whether to show error exceptions.') flags.ADOPT_module_key_flags(checker) flags.ADOPT_module_key_flags(ecmalintrules) flags.ADOPT_module_key_flags(error_check) def _GetLastNonWhiteSpaceToken(start_token): """Get the last non-whitespace token in a token stream.""" ret_token = None whitespace_tokens = frozenset([ tokens.TokenType.WHITESPACE, tokens.TokenType.BLANK_LINE]) for t in start_token: if t.type not in whitespace_tokens: ret_token = t return ret_token
"""This module checks if there any undefined gflags used in input python module(s).""" #!/usr/bin/env python import importlib import re import sys import tokenize import traceback import gflags from util.base import log gflags.ADOPT_module_key_flags(log) GFLAGS_PREFIX = "FLAGS." GFLAGS_PREFIX_FULL = "gflags.FLAGS." PY_OPERATORS_DELIMITERS = "+-*/%@<>&|^~=!()[]{},:.;" GFLAG_NAME_REGEX = re.compile(r"(.*)(FLAGS\.)([a-zA-Z_]\w*)(.*)") UNDEFINED_GFLAG_FOUND = False def tokenize_manually(source, module): """Tokenizes the python source code file manually and looks for gflags used in the file and checks if they are undefined. Arguments: source: file object of the python source code file module: name of the python module in source """ global UNDEFINED_GFLAG_FOUND
import train_eval as train import helpers.post_processing as post_processing # import models.hantman_hungarian as hantman_hungarian from models import hantman_hungarian import flags.lstm_flags import flags.cuda_flags import torch import os # from helpers.RunningStats import RunningStats # from scipy import signal gflags.DEFINE_integer("seq_len", 1500, "Sequence length.") gflags.DEFINE_string("loss", "mse", "Loss to use for training.") gflags.DEFINE_string("model", "", "model to load.") gflags.ADOPT_module_key_flags(helpers.videosampler) gflags.ADOPT_module_key_flags(hantman_hungarian) gflags.ADOPT_module_key_flags(flags.lstm_flags) gflags.ADOPT_module_key_flags(arg_parsing) gflags.ADOPT_module_key_flags(flags.cuda_flags) gflags.ADOPT_module_key_flags(train) def _setup_opts(argv): """Parse inputs.""" FLAGS = gflags.FLAGS opts = arg_parsing.setup_opts(argv, FLAGS) # setup the feature key list. The hdf5 sampler expects each feature key # to be a list of sub fields. Allowing the hdf5 sampler to traverse