You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

run.py 2.5 kB

[to #9061073] feat: merge tts to master Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/9061073 Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/9061073 * [to #41669377] docs and tools refinement and release 1. add build_doc linter script 2. add sphinx-docs support 3. add development doc and api doc 4. change version to 0.1.0 for the first internal release version Link: https://code.aone.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/8775307 * [to #41669377] add pipeline tutorial and fix bugs 1. add pipleine tutorial 2. fix bugs when using pipeline with certain model and preprocessor Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/8814301 * refine doc * refine doc * merge remote release/0.1 and fix conflict * Merge branch 'release/0.1' into 'nls/tts' Release/0.1 See merge request !1700968 * [Add] add tts preprocessor without requirements. finish requirements build later * [Add] add requirements and frd submodule * [Fix] remove models submodule * [Add] add am module * [Update] update am and vocoder * [Update] remove submodule * [Update] add models * [Fix] fix init error * [Fix] fix bugs with tts pipeline * merge master * [Update] merge from master * remove frd subdmoule and using wheel from oss * change scripts * [Fix] fix bugs in am and vocoder * [Merge] merge from master * Merge branch 'master' into nls/tts * [Fix] fix bugs * [Fix] fix pep8 * Merge branch 'master' into nls/tts * [Update] remove hparams and import configuration from kwargs * Merge branch 'master' into nls/tts * upgrade tf113 to tf115 * Merge branch 'nls/tts' of gitlab.alibaba-inc.com:Ali-MaaS/MaaS-lib into nls/tts * add multiple versions of ttsfrd * merge master * [Fix] fix cr comments * Merge branch 'master' into nls/tts * [Fix] fix cr comments 0617 * Merge branch 'master' into nls/tts * [Fix] remove comment out codes * [Merge] merge from master * [Fix] fix crash for incompatible tf and pytorch version, and frd using zip file resource * Merge branch 'master' into nls/tts * [Add] add cuda support
3 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #!/usr/bin/env python
  2. # Copyright (c) Alibaba, Inc. and its affiliates.
  3. import argparse
  4. import os
  5. import sys
  6. import unittest
  7. from fnmatch import fnmatch
  8. # NOTICE: Tensorflow 1.15 seems not so compatible with pytorch.
  9. # A segmentation fault may be raise by pytorch cpp library
  10. # if 'import tensorflow' in front of 'import torch'.
  11. # Puting a 'import torch' here can bypass this incompatibility.
  12. import torch
  13. from modelscope.utils.logger import get_logger
  14. from modelscope.utils.test_utils import set_test_level, test_level
  15. logger = get_logger()
  16. def gather_test_cases(test_dir, pattern, list_tests):
  17. case_list = []
  18. for dirpath, dirnames, filenames in os.walk(test_dir):
  19. for file in filenames:
  20. if fnmatch(file, pattern):
  21. case_list.append(file)
  22. test_suite = unittest.TestSuite()
  23. for case in case_list:
  24. test_case = unittest.defaultTestLoader.discover(
  25. start_dir=test_dir, pattern=case)
  26. test_suite.addTest(test_case)
  27. if hasattr(test_case, '__iter__'):
  28. for subcase in test_case:
  29. if list_tests:
  30. print(subcase)
  31. else:
  32. if list_tests:
  33. print(test_case)
  34. return test_suite
  35. def main(args):
  36. runner = unittest.TextTestRunner()
  37. test_suite = gather_test_cases(
  38. os.path.abspath(args.test_dir), args.pattern, args.list_tests)
  39. if not args.list_tests:
  40. result = runner.run(test_suite)
  41. if len(result.failures) > 0:
  42. sys.exit(len(result.failures))
  43. if len(result.errors) > 0:
  44. sys.exit(len(result.errors))
  45. if __name__ == '__main__':
  46. parser = argparse.ArgumentParser('test runner')
  47. parser.add_argument(
  48. '--list_tests', action='store_true', help='list all tests')
  49. parser.add_argument(
  50. '--pattern', default='test_*.py', help='test file pattern')
  51. parser.add_argument(
  52. '--test_dir', default='tests', help='directory to be tested')
  53. parser.add_argument(
  54. '--level', default=0, type=int, help='2 -- all, 1 -- p1, 0 -- p0')
  55. parser.add_argument(
  56. '--disable_profile', action='store_true', help='disable profiling')
  57. args = parser.parse_args()
  58. set_test_level(args.level)
  59. logger.info(f'TEST LEVEL: {test_level()}')
  60. if not args.disable_profile:
  61. from utils import profiler
  62. logger.info('enable profile ...')
  63. profiler.enable()
  64. main(args)