Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Unified Diff: infra/bots/recipe_modules/ct/api.py

Issue 2221413002: Move ct_skps recipe from tools repo to Skia repo (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Address comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « infra/bots/recipe_modules/ct/__init__.py ('k') | infra/bots/recipe_modules/run/api.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: infra/bots/recipe_modules/ct/api.py
diff --git a/infra/bots/recipe_modules/ct/api.py b/infra/bots/recipe_modules/ct/api.py
new file mode 100644
index 0000000000000000000000000000000000000000..91478fb50e13ead4d3abe1dacfe2d455d6118e39
--- /dev/null
+++ b/infra/bots/recipe_modules/ct/api.py
@@ -0,0 +1,51 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+
+from recipe_engine import recipe_api
+
+import re
+
+
+class CTApi(recipe_api.RecipeApi):
+ """Provides steps to run CT tasks."""
+
+ CT_GS_BUCKET = 'cluster-telemetry'
+
+ def download_swarming_skps(self, page_type, slave_num, skps_chromium_build,
+ dest_dir, start_range, num_skps):
+ """Downloads SKPs corresponding to the specified page type, slave and build.
+
+ The SKPs are stored in Google Storage in the following dirs in CT_GS_BUCKET:
+ /swarming/skps/${page_type}/${skps_chromium_build}/{start_range..end_num}/
+ The SKPs are downloaded into subdirectories in the dest_dir.
+
+ Args:
+ api: RecipeApi instance.
+ page_type: str. The CT page type. Eg: 1k, 10k.
+ slave_num: int. The number of the swarming bot.
+ skps_chromium_build: str. The build the SKPs were captured from.
+ dest_dir: path obj. The directory to download SKPs into.
+ start_range: int. The subdirectory number to start from.
+ num_skps: int. The total number of SKPs to download starting with
+ start_range.
+ """
+ slave_dest_dir = dest_dir.join('slave%s' % slave_num )
+ remote_dir = 'gs://%s/swarming/skps/%s/%s' % (
+ self.CT_GS_BUCKET, page_type, skps_chromium_build)
+
+ # Delete and recreate the local dir.
+ self.m.run.rmtree(slave_dest_dir)
+ self.m.file.makedirs(self.m.path.basename(slave_dest_dir), slave_dest_dir)
+
+ # Populate the empty local dir.
+ gsutil_args = ['-m', 'cp']
+ for i in range(start_range, start_range+num_skps):
+ gsutil_args.append('%s/%s/*.skp' % (str(remote_dir), i))
+ gsutil_args.append(str(slave_dest_dir))
+ try:
+ self.m.gsutil(gsutil_args, use_retry_wrapper=False)
+ except self.m.step.StepFailure: # pragma: nocover
+ # Some subdirectories might have no SKPs in them.
+ pass
« no previous file with comments | « infra/bots/recipe_modules/ct/__init__.py ('k') | infra/bots/recipe_modules/run/api.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698