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

Side by Side Diff: appengine/findit/waterfall/flake/initialize_flake_pipeline.py

Issue 2130543004: Waterfall components of regression range finder. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: cleanup Created 4 years, 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2014 The Chromium Authors. All rights reserved.
chanli 2016/07/19 20:48:27 2014 -> 2016
caiw 2016/07/20 18:26:47 Done.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 from datetime import datetime
6 import logging
chanli 2016/07/19 20:48:27 Remove this import
lijeffrey 2016/07/19 22:44:10 If you run gpylint <path to python file> it should
caiw 2016/07/20 18:26:47 Done.
7
8 from google.appengine.ext import ndb
9
10 from common import appengine_util
11 from common import constants
12 from model import analysis_status
13 from model.flake.flake_swarming_task import FlakeSwarmingTask
14 from model.flake.master_flake_analysis import MasterFlakeAnalysis
15 from waterfall.flake.recursive_flake_pipeline import RecursiveFlakePipeline
16
17
18 @ndb.transactional
19 def NeedANewAnalysis(
20 master_name, builder_name, build_number, step_name, test_name):
21 """Checks status of analysis for the test and decides if a new one is needed.
22
23 A MasterFlakeAnalysis entity for the given build will be created if none
24 exists. When a new analysis is needed, this function will create and
25 save a MasterFlakeAnalysis entity to the datastore, or it will
26 reset the existing one but still keep the result of last analysis.
27
28 Returns:
29 True if an analysis is needed, otherwise False.
30 """
31 analysis = MasterFlakeAnalysis.Get(master_name, builder_name, build_number,
32 step_name, test_name)
33
34 if not analysis:
35 analysis = MasterFlakeAnalysis.Create(
36 master_name, builder_name, build_number, step_name, test_name)
37 analysis.status = analysis_status.PENDING
38 analysis.put()
39 return True
40 elif (analysis.status == analysis_status.COMPLETED or
41 analysis.status == analysis_status.PENDING or
42 analysis.status == analysis_status.RUNNING):
43 return False
44 else:
chanli 2016/07/19 20:48:28 First: Maybe you can create the Reset method and r
caiw 2016/07/20 18:26:47 So this is only if the status of the last analysis
chanli 2016/07/21 20:34:09 Acknowledged.
45 # TODO(caiw): Reset method.
46 MasterFlakeAnalysis.Get(
47 master_name, builder_name, build_number,
48 step_name, test_name).key.delete()
49 analysis = MasterFlakeAnalysis.Create(
50 master_name, builder_name, build_number, step_name, test_name)
51 analysis.status = analysis_status.PENDING
52 analysis.put()
53 return True
54
55 # Unused arguments - pylint: disable=W0612, W0613
56 def ScheduleAnalysisIfNeeded(master_name, builder_name, build_number, step_name,
57 test_name, force=False,
chanli 2016/07/19 20:48:28 Is force saved for later change?
caiw 2016/07/20 18:26:47 Yes - I think later we will need to figure out who
chanli 2016/07/21 20:34:09 I think we can add force when we want to do it?
caiw 2016/07/22 21:46:42 So should we do it now?
chanli 2016/07/26 17:41:05 I would say add it in a separated CL, even the cha
caiw 2016/07/26 20:19:44 Acknowledged.
58 queue_name=constants.DEFAULT_QUEUE):
59 """Schedules an analysis if needed and returns the MasterFlakeAnalysis.
60
61 When the build failure was already analyzed and a new analysis is scheduled,
62 the returned WfAnalysis will still have the result of last completed analysis.
63
64 Args:
65 master_name (str): The master name of the failed test
66 builder_name (str): The builder name of the failed test
67 build_number (int): The build number of the failed test
68 step_name (str): The name of the test suite
69 test_name (str): The single test we are checking
70 Returns:
71 A MasterFlakeAnalysis instance.
72 """
73 if NeedANewAnalysis(
74 master_name, builder_name, build_number, step_name, test_name):
75 pipeline_job = RecursiveFlakePipeline(
76 master_name, builder_name, build_number, step_name, test_name,
77 master_build_number=build_number)
78 pipeline_job.target = appengine_util.GetTargetNameForModule(
79 constants.WATERFALL_BACKEND)
80 pipeline_job.start(queue_name=queue_name)
81 return MasterFlakeAnalysis.Get(
82 master_name, builder_name, build_number, step_name, test_name)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698