def main(): argparser = ArgumentParser(description='Bundle SIS term data.') argparser.allow_abbrev = False argparser.add_argument( 'term_or_year', type=int, nargs='*', help='Terms (or entire years) for which to request data from the SIS') argparser.add_argument( '-w', metavar='WORKERS', type=int, default=cpu_count(), dest='workers', help='The number of operations to perform in parallel') argparser.add_argument('--legacy', action='store_true', help="Use legacy mode (you don't need this)") argparser.add_argument('--out-dir', nargs='?', action='store', default=COURSE_DATA, help='Where to put info.json and terms/') argparser.add_argument('--format', action='append', nargs='?', choices=['json', 'csv', 'xml'], help='Change the output filetype') args = argparser.parse_args() args.format = ['json'] if not args.format else args.format run(args)
def main(): argparser = ArgumentParser(description='Bundle SIS term data.') argparser.allow_abbrev = False argparser.add_argument('term_or_year', type=int, nargs='*', help='Terms (or entire years) for which to request data from the SIS') argparser.add_argument('-w', metavar='WORKERS', type=int, default=cpu_count(), dest='workers', help='The number of operations to perform in parallel') argparser.add_argument('--legacy', action='store_true', help="Use legacy mode (you don't need this)") argparser.add_argument('--out-dir', nargs='?', action='store', default=COURSE_DATA, help='Where to put info.json and terms/') argparser.add_argument('--format', action='append', nargs='?', choices=['json', 'csv', 'xml'], help='Change the output filetype') args = argparser.parse_args() args.format = ['json'] if not args.format else args.format run(args)
def main(): argparser = ArgumentParser(description='Fetch term data from the SIS.') argparser.allow_abbrev = False argparser.add_argument( 'term_or_year', type=int, nargs='*', help='Terms (or entire years) for which to request data from the SIS.') argparser.add_argument( '--workers', '-w', type=int, default=cpu_count(), help='Control the number of operations to perform in parallel') argparser.add_argument('--force-terms', action='store_true', help='Force reloading of all specified terms.') argparser.add_argument( '--force-details', action='store_true', help='Force reloading of course details from all specified terms.') argparser.add_argument('--dry-run', '-d', action='store_true', help='Only print output; don\'t write files.') argparser.add_argument( '--ignore-revision-keys', metavar='PROP', nargs='+', default=[], help='Prevent storing revisions within property $PROP.') argparser.add_argument('--no-revisions', action='store_true', help='Do not check for revisions at all.') argparser.add_argument( '--quiet', '-q', action='store_true', help='Silence logging; mostly used when looking for data.') args = argparser.parse_args() run(args)
def main(): argparser = ArgumentParser(description='Fetch term data from the SIS.') argparser.allow_abbrev = False argparser.add_argument('term_or_year', type=int, nargs='*', help='Terms (or entire years) for which to request data from the SIS.') argparser.add_argument('--workers', '-w', type=int, default=cpu_count(), help='Control the number of operations to perform in parallel') argparser.add_argument('--force-terms', action='store_true', help='Force reloading of all specified terms.') argparser.add_argument('--force-details', action='store_true', help='Force reloading of course details from all specified terms.') argparser.add_argument('--dry-run', '-d', action='store_true', help='Only print output; don\'t write files.') argparser.add_argument('--ignore-revision-keys', metavar='PROP', nargs='+', default=[], help='Prevent storing revisions within property $PROP.') argparser.add_argument('--no-revisions', action='store_true', help='Do not check for revisions at all.') argparser.add_argument('--quiet', '-q', action='store_true', help='Silence logging; mostly used when looking for data.') args = argparser.parse_args() run(args)
def config_create_tables_parser(subparser: argparse.ArgumentParser): subparser.allow_abbrev = False subparser.set_defaults(func=handle_create_tables) subparser.usage = 'pyton %(prog)s create-table' subparser.description = 'Create the database tables based on the vendor provider configured in config.py'
def config_kraken_socket_parser(subparser: argparse.ArgumentParser): subparser.allow_abbrev = False subparser.set_defaults(func=handle_kraken_websocket) subparser.usage = 'pyton %(prog)s kraken' subparser.description = 'Subscribe to kraken websocket and launches the alert system'
def config_buda_exchange_parser(subparser: argparse.ArgumentParser): subparser.allow_abbrev = False subparser.set_defaults(func=handle_buda) subparser.usage = 'python %(prog)s buda {btc, eth, ltc, eth}' subparser.description = 'Recover data from Buda.com, transforms it into ohlc and stores it in a csv file' subparser.add_argument('market', choices=['btc', 'eth', 'ltc', 'bch'])
def config_crypto_compare_parser(subparser: argparse.ArgumentParser): subparser.allow_abbrev = False subparser.set_defaults(func=handle_crypto_compare) subparser.usage = 'python %(prog)s cryptoCompare {btc, eth, ltc, eth}' subparser.description = 'Recovers data from cryptocompare.com and stores it in a csv file' subparser.add_argument('market', choices=['btc', 'eth', 'ltc', 'bch'])
action='store_true', help='Only print output; don\'t write files.') argparser.add_argument('--no-revisions', '-n', action='store_false', help='Prevent searching for revisions of courses.') argparser.add_argument('--ignore-revisions', metavar='PROP', nargs='+', default=[], help='Prevent storing revisions within property $PROP.') argparser.add_argument('--quiet', '-q', action='store_true', help='Silence logging; mostly used when looking for data.') argparser.add_argument('--output-type', action='store', default='json', choices=['json', 'csv'], help='Change the output filetype.') argparser.add_argument('--output-dir', action='store', default='build/', help='Choose an output directory.') argparser.allow_abbrev = False args = argparser.parse_args() if args.output_dir[-1] != '/': args.output_dir += '/' main(args)
def run() -> None: """ Run the tool parsing the commandline arguments """ print(f"JoSIM Tools {__version__}") parser = ArgumentParser(description="Circuit tools built on JoSIM") parser.add_argument("configuration", type=str) parser.add_help = True parser.allow_abbrev = True args = parser.parse_args() configuration = toml_load(args.configuration) try: schema_validate(instance=configuration, schema=SCHEMA_CONFIG) except SchemaValidationError as error: print("ERROR: configuration file validation failed") print(" reason: {}".format(error.message)) exit(-1) mode = configuration["mode"] if mode == "verify": verify_configuration = VerifyConfiguration.from_dict( configuration["verify"]) verifier = Verifier(verify_configuration) output = verifier.verify() if output: print("SUCCESS") else: print("FAILURE") if output.failure_time is not None: print(" TIME : {}".format(output.failure_time)) if output.failure_point is not None: print(" POINT : {}".format(output.failure_point)) elif mode == "margin": verify_configuration = VerifyConfiguration.from_dict( configuration["verify"]) margin_configuration = MarginAnalysisConfiguration.from_dict( configuration.get("margin", {})) margin_parameters: Dict[str, MarginParameterConfiguration] = {} for key, item in configuration["parameters"].items(): margin_parameters[key] = MarginParameterConfiguration.from_dict( item) margin_analysis = MarginAnalysis(verify_configuration, margin_configuration) num_threads = min(2 * len(margin_parameters), cpu_count()) margin_analysis_parameters: Dict[str, float] = {} for key, item in margin_parameters.items(): margin_analysis_parameters[key] = item.nominal result = margin_analysis.analyse(margin_analysis_parameters, num_threads) print_margin_analysis_result( result, left_size=margin_configuration.min_search, right_size=margin_configuration.max_search, ) elif mode == "yield": verify_configuration = VerifyConfiguration.from_dict( configuration["verify"]) yield_configuration = YieldAnalysisConfiguration.from_dict( configuration["yield"]) yield_parameters: Dict[str, YieldParameterConfiguration] = {} for key, item in configuration["parameters"].items(): yield_parameters[key] = YieldParameterConfiguration.from_dict(item) num_samples = yield_configuration.num_samples num_threads = min(num_samples, cpu_count()) yield_analysis = YieldAnalysis(verify_configuration, yield_parameters) yield_analysis.sample(num_samples, num_threads) print("Yield: {} / {} = {:.1f} %".format( yield_analysis.num_success(), yield_analysis.num_total(), yield_analysis.percentage() * 100, )) elif mode == "optimize": verify_configuration = VerifyConfiguration.from_dict( configuration["verify"]) margin_configuration = MarginAnalysisConfiguration.from_dict( configuration.get("margin", {})) optimize_configuration = OptimizeConfiguration.from_dict( configuration["optimize"]) optimize_parameters: Dict[str, OptimizerParameterConfiguration] = {} for key, item in configuration["parameters"].items(): optimize_parameters[ key] = OptimizerParameterConfiguration.from_dict(item) optimizer = Optimizer( verify_configuration, margin_configuration, optimize_configuration, optimize_parameters, ) optimization_parameters: Dict[str, float] = {} for key, item in optimize_parameters.items(): optimization_parameters[key] = item.nominal point = optimizer.optimize(optimization_parameters) output_file = optimize_configuration.output if output_file is not None: optimizer.margin_analysis_.verifier_.simulator_.write_file_with_updated_parameters( output_file, point) else: assert False, "INTERNAL ERROR: UNREACHABLE CODE"
type=str, default='localhost', help="Bind to this specific host") parser.add_argument("-port", type=int, default=5555, help="Port to bind to (default 5555)") parser.add_argument("-no-admin", dest="noadmin", action='store_true', help="Disable administration panel") parser.add_argument("-pidfile", help="PIDFile to lock against", default="libsrv.pid") parser.allow_abbrev = False args = parser.parse_args() HOST = environ.get('SERVER_HOST', args.host) try: PORT = int(environ.get('SERVER_PORT', args.port)) except ValueError: PORT = args.port # We're going to get our default and overlay configurations. # This is being supplied by the command line app.config["configfiles"] = [args.baseconfig, args.localconfig] app.config["localConfigPath"] = args.localconfig app.config["baseConfigPath"] = args.baseconfig