Changes in / [aee8dfb:259b116] in sasmodels
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/model_test.py
r00afc15 r00afc15 45 45 from __future__ import print_function 46 46 47 import argparse48 47 import sys 49 48 import unittest … … 475 474 476 475 477 def main( ):476 def main(*models): 478 477 # type: (*str) -> int 479 478 """ … … 489 488 test_args = {} 490 489 491 parser = argparse.ArgumentParser(description="Test SasModels Models") 492 parser.add_argument("-v", "--verbose", action="store_const", 493 default=1, const=2, help="Use verbose output") 494 parser.add_argument("engine", metavar="[engine]", 495 help="Engines on which to run the test. " 496 "Valid values are opencl, dll, and opencl_and_dll. " 497 "Defaults to opencl_and_dll if no value is given") 498 parser.add_argument("models", nargs="*", 499 help='The names of the models to be tested. ' 500 'If the first model is "all", then all except the ' 501 'remaining models will be tested.') 502 args, models = parser.parse_known_args() 503 504 if args.engine == "opencl": 490 if models and models[0] == '-v': 491 verbosity = 2 492 models = models[1:] 493 else: 494 verbosity = 1 495 if models and models[0] == 'opencl': 505 496 if not use_opencl(): 506 497 print("opencl is not available") 507 498 return 1 508 499 loaders = ['opencl'] 509 elif args.engine == "dll": 510 loaders = ["dll"] 511 elif args.engine == "cuda": 500 models = models[1:] 501 elif models and models[0] == 'cuda': 512 502 if not use_cuda(): 513 503 print("cuda is not available") 514 504 return 1 515 505 loaders = ['cuda'] 506 models = models[1:] 507 elif models and models[0] == 'dll': 508 # TODO: test if compiler is available? 509 loaders = ['dll'] 510 models = models[1:] 516 511 else: 517 # Default to running both engines518 512 loaders = ['dll'] 519 513 if use_opencl(): … … 521 515 if use_cuda(): 522 516 loaders.append('cuda') 523 args.models.insert(0, args.engine) 524 525 runner = TestRunner(verbosity=args.verbose, **test_args) 526 result = runner.run(make_suite(loaders, args.models)) 517 if not models: 518 print("""\ 519 usage: 520 python -m sasmodels.model_test [-v] [opencl|cuda|dll] model1 model2 ... 521 522 If -v is included on the command line, then use verbose output. 523 524 If no platform is specified, then models will be tested with dll, and 525 if available, OpenCL and CUDA; the compute target is ignored for pure python models. 526 527 If model1 is 'all', then all except the remaining models will be tested. 528 529 """) 530 531 return 1 532 533 runner = TestRunner(verbosity=verbosity, **test_args) 534 result = runner.run(make_suite(loaders, models)) 527 535 return 1 if result.failures or result.errors else 0 528 536 … … 563 571 564 572 if __name__ == "__main__": 565 sys.exit(main( ))573 sys.exit(main(*sys.argv[1:]))
Note: See TracChangeset
for help on using the changeset viewer.