soundwave 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #!/usr/bin/env vpython3
  2. # Copyright 2018 The Chromium Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. import argparse
  6. import os
  7. import sys
  8. from core import path_util
  9. path_util.AddPyUtilsToPath()
  10. from core import cli_utils
  11. from core import external_modules
  12. from core.services import luci_auth
  13. from cli_tools.soundwave import commands
  14. from cli_tools.soundwave import studies
  15. DEFAULT_DATABASE_PATH = os.path.abspath(os.path.join(
  16. os.path.dirname(__file__), '_cached_data', 'soundwave', 'soundwave.db'))
  17. def main():
  18. print('*** WARNING: soundwave is deprecated and will be removed soon.\n' +
  19. '*** Please see go/chromeperf-bigquery for a replacement.\n')
  20. parser = argparse.ArgumentParser()
  21. # Default args for all actions.
  22. parser.add_argument(
  23. '-s', '--sheriff', default='Chromium Perf Sheriff',
  24. help='Only get data for this sheriff rotation, default: "%(default)s". '
  25. 'You can use the special value "all" to disable filtering by '
  26. 'sheriff rotation.')
  27. parser.add_argument(
  28. '-d', '--days', default=30, type=int,
  29. help='Number of days to collect data for (default: %(default)s)')
  30. parser.add_argument(
  31. '--continue', action='store_true', dest='use_cache',
  32. help='Skip refreshing some data for elements already in local db.')
  33. parser.add_argument(
  34. '--processes', type=int, default=40,
  35. help='Number of concurrent processes to use for fetching data.')
  36. parser.add_argument(
  37. '--database-file', default=DEFAULT_DATABASE_PATH,
  38. help='File path for database where to store data.')
  39. parser.add_argument(
  40. '-v', '--verbose', action='count', default=0,
  41. help='Increase verbosity level')
  42. subparsers = parser.add_subparsers(dest='action')
  43. subparsers.required = True
  44. # Subparser args for fetching alerts data.
  45. subparser = subparsers.add_parser('alerts')
  46. subparser.add_argument(
  47. '-b', '--benchmark', required=True,
  48. help='Fetch alerts for this benchmark.')
  49. # Subparser args for fetching timeseries data.
  50. subparser = subparsers.add_parser('timeseries')
  51. group = subparser.add_mutually_exclusive_group(required=True)
  52. group.add_argument(
  53. '-b', '--benchmark', help='Fetch timeseries for this benchmark.')
  54. group.add_argument(
  55. '--study', choices=studies.NAMES,
  56. help='Fetch timeseries needed for a specific study.')
  57. group.add_argument(
  58. '-i', '--input-file',
  59. help='Fetch timeseries listed in this json file (see e.g.'
  60. ' examples/soundwave directory).')
  61. subparser.add_argument(
  62. '-f', '--filters', action='append',
  63. help='Only get data for timeseries whose path contains all the given '
  64. 'substrings.')
  65. group = subparser.add_mutually_exclusive_group()
  66. group.add_argument(
  67. '--output-csv', metavar='PATH',
  68. help='Export the timeseries data to a csv file, the PATH given may be '
  69. 'either a local or a cloud storage (i.e. gs://...) path.')
  70. group.add_argument(
  71. '--upload-csv', action='store_true',
  72. help='Export the timeseries data to the default cloud storage path for '
  73. 'a given --study.')
  74. args = parser.parse_args()
  75. cli_utils.ConfigureLogging(args.verbose)
  76. luci_auth.CheckLoggedIn()
  77. if args.action == 'alerts':
  78. commands.FetchAlertsData(args)
  79. elif args.action == 'timeseries':
  80. if args.study is not None:
  81. args.study = studies.GetStudy(args.study)
  82. if args.upload_csv:
  83. args.output_csv = args.study.CLOUD_PATH
  84. elif args.upload_csv:
  85. return 'ERROR: --upload-csv also requires a --study to be specified'
  86. commands.FetchTimeseriesData(args)
  87. else:
  88. raise NotImplementedError(args.action)
  89. if __name__ == '__main__':
  90. external_modules.RequireModules()
  91. sys.exit(main())