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

Unified Diff: gm/rebaseline_server/download_actuals.py

Issue 310093003: rebaseline_server: download actual-results.json files from GCS instead of SVN (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: download actual-results.json files from GCS instead of SVN Created 6 years, 7 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 | « no previous file | gm/rebaseline_server/server.py » ('j') | gm/rebaseline_server/server.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/rebaseline_server/download_actuals.py
diff --git a/gm/rebaseline_server/download_actuals.py b/gm/rebaseline_server/download_actuals.py
index 636958be6b545c2251628a3b0f65f2d2db0c25d1..96ea74cdfae0df66f9706f514e7a7b715d5ecd4f 100755
--- a/gm/rebaseline_server/download_actuals.py
+++ b/gm/rebaseline_server/download_actuals.py
@@ -105,8 +105,6 @@ class Download(object):
test_name=test, hash_type=hash_type, hash_digest=hash_digest,
gm_actuals_root_url=self._gm_actuals_root_url)
dest_path = os.path.join(dest_dir, config, test + '.png')
- # TODO(epoger): To speed this up, we should only download files that
- # we don't already have on local disk.
epoger 2014/06/03 20:11:03 This comment turns out to be misleading... downloa
copy_contents(source_url=source_url, dest_path=dest_path,
create_subdirs_if_needed=True)
@@ -162,12 +160,33 @@ def copy_contents(source_url, dest_path, create_subdirs_if_needed=False):
shutil.copyfileobj(fsrc=source_handle, fdst=dest_handle)
+def gcs_download_file(source_bucket, source_path, dest_path,
+ create_subdirs_if_needed=False):
+ """ Downloads a single file from Google Cloud Storage to local disk.
+
+ EPOGER: move into a gcs utility module?
epoger 2014/06/03 20:11:03 I think I should move gcs_download_file() and gcs_
borenet 2014/06/03 20:27:47 Yes, that SGTM, but what's the difference then bet
epoger 2014/06/03 20:39:04 In this case I went with "gcs_utils.py" because (a
+
+ Args:
+ source_bucket: GCS bucket to download the file from
+ source_path: full path (Posix-style) within that bucket
+ dest_path: full path (local-OS-style) on local disk to copy the file to
+ create_subdirs_if_needed: boolean; whether to create subdirectories as
+ needed to create dest_path
+ """
+ source_http_url = posixpath.join(
+ 'http://storage.googleapis.com', source_bucket, source_path)
+ copy_contents(source_url=source_http_url, dest_path=dest_path,
+ create_subdirs_if_needed=create_subdirs_if_needed)
+
+
def gcs_list_bucket_contents(bucket, subdir=None):
""" Returns files in the Google Cloud Storage bucket as a (dirs, files) tuple.
Uses the API documented at
https://developers.google.com/storage/docs/json_api/v1/objects/list
+ EPOGER: move into a gcs utility module?
+
Args:
bucket: name of the Google Storage bucket
subdir: directory within the bucket to list, or None for root directory
@@ -199,6 +218,17 @@ def gcs_list_bucket_contents(bucket, subdir=None):
return (dirs, files)
+def get_builders_list(summaries_bucket=GM_SUMMARIES_BUCKET):
+ """ Returns the list of builders we have actual results for.
+
+ Args:
+ summaries_bucket: Google Cloud Storage bucket containing the summary
+ JSON files
+ """
+ dirs, _ = gcs_list_bucket_contents(bucket=GM_SUMMARIES_BUCKET)
+ return dirs
+
+
def main():
parser = optparse.OptionParser()
required_params = []
@@ -234,8 +264,7 @@ def main():
(params, remaining_args) = parser.parse_args()
if params.list_builders:
- dirs, _ = gcs_list_bucket_contents(bucket=GM_SUMMARIES_BUCKET)
- print '\n'.join(dirs)
+ print '\n'.join(get_builders_list())
return
# Make sure all required options were set,
« no previous file with comments | « no previous file | gm/rebaseline_server/server.py » ('j') | gm/rebaseline_server/server.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698