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

Unified Diff: dashboard/dashboard/pinpoint/handlers/new.py

Issue 2996473002: [pinpoint] Add QuestGenerator object. (Closed)
Patch Set: rebase Created 3 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
Index: dashboard/dashboard/pinpoint/handlers/new.py
diff --git a/dashboard/dashboard/pinpoint/handlers/new.py b/dashboard/dashboard/pinpoint/handlers/new.py
index 6f7f71c8d4ac4391351aad5ce5f7ca8ca86b4e86..ec8ff73ba4a2476b7605b3bcccc93f3e5005c87f 100644
--- a/dashboard/dashboard/pinpoint/handlers/new.py
+++ b/dashboard/dashboard/pinpoint/handlers/new.py
@@ -8,14 +8,10 @@ import webapp2
from dashboard.api import api_auth
from dashboard.pinpoint.models import change
from dashboard.pinpoint.models import job as job_module
+from dashboard.pinpoint.models import quest_generator as quest_generator_module
-_ERROR_METRIC_NO_TEST_SUITE = "Specified a metric but there's no test_suite "\
- "to run."
-_ERROR_BUG_ID = 'Bug ID must be integer value.'
-
-class ParameterValidationError(Exception):
- pass
+_ERROR_BUG_ID = 'Bug ID must be an integer.'
class New(webapp2.RequestHandler):
@@ -24,7 +20,7 @@ class New(webapp2.RequestHandler):
def post(self):
try:
self._CreateJob()
- except (api_auth.ApiAuthException, ParameterValidationError) as e:
+ except (api_auth.ApiAuthException, KeyError, TypeError, ValueError) as e:
self._WriteErrorMessage(e.message)
def _WriteErrorMessage(self, message):
@@ -33,12 +29,8 @@ class New(webapp2.RequestHandler):
@api_auth.Authorize
def _CreateJob(self):
"""Start a new Pinpoint job."""
- configuration = self.request.get('configuration')
- test_suite = self.request.get('test_suite')
- test = self.request.get('test')
- metric = self.request.get('metric')
auto_explore = self.request.get('auto_explore') == '1'
- bug_id = self._ValidateBugId(self.request.get('bug_id'))
+ bug_id = self.request.get('bug_id')
change_1 = {
'base_commit': {
@@ -54,18 +46,15 @@ class New(webapp2.RequestHandler):
}
}
- # Validate parameters.
- self._ValidateMetric(test_suite, metric)
-
- # Convert parameters to canonical internal representation.
+ # Validate arguments and convert them to canonical internal representation.
+ quest_generator = quest_generator_module.QuestGenerator(self.request)
+ bug_id = self._ValidateBugId(bug_id)
changes = self._ValidateChanges(change_1, change_2)
# Create job.
job = job_module.Job.New(
- configuration=configuration,
- test_suite=test_suite,
- test=test,
- metric=metric,
+ arguments=quest_generator.AsDict(),
+ quests=quest_generator.Quests(),
auto_explore=auto_explore,
bug_id=bug_id)
@@ -80,6 +69,8 @@ class New(webapp2.RequestHandler):
job.Start()
job.put()
+ # TODO: Figure out if these should be underscores or lowerCamelCase.
+ # TODO: They should match the input arguments.
self.response.out.write(json.dumps({
'jobId': job_id,
'jobUrl': job.url
@@ -92,17 +83,7 @@ class New(webapp2.RequestHandler):
try:
return int(bug_id)
except ValueError:
- raise ParameterValidationError(_ERROR_BUG_ID)
+ raise ValueError(_ERROR_BUG_ID)
def _ValidateChanges(self, change_1, change_2):
- try:
- changes = (change.Change.FromDict(change_1),
- change.Change.FromDict(change_2))
- except (KeyError, ValueError) as e:
- raise ParameterValidationError(str(e))
-
- return changes
-
- def _ValidateMetric(self, test_suite, metric):
- if metric and not test_suite:
- raise ParameterValidationError(_ERROR_METRIC_NO_TEST_SUITE)
+ return (change.Change.FromDict(change_1), change.Change.FromDict(change_2))
« no previous file with comments | « dashboard/dashboard/pinpoint/handlers/jobs_test.py ('k') | dashboard/dashboard/pinpoint/handlers/new_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698