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

Side by Side Diff: appengine/swarming/server/task_request.py

Issue 2453873002: Add --output option to Swarming client and pass it through to the bot (Closed)
Patch Set: Extra help text for examples Created 4 years, 1 month 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
« no previous file with comments | « appengine/swarming/local_smoke_test.py ('k') | appengine/swarming/server/task_request_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # coding: utf-8 1 # coding: utf-8
2 # Copyright 2014 The LUCI Authors. All rights reserved. 2 # Copyright 2014 The LUCI Authors. All rights reserved.
3 # Use of this source code is governed under the Apache License, Version 2.0 3 # Use of this source code is governed under the Apache License, Version 2.0
4 # that can be found in the LICENSE file. 4 # that can be found in the LICENSE file.
5 5
6 """Tasks definition. 6 """Tasks definition.
7 7
8 Each user request creates a new TaskRequest. The TaskRequest instance saves the 8 Each user request creates a new TaskRequest. The TaskRequest instance saves the
9 metadata of the request, e.g. who requested it, when why, etc. It links to the 9 metadata of the request, e.g. who requested it, when why, etc. It links to the
10 actual data of the request in a TaskProperties. The TaskProperties represents 10 actual data of the request in a TaskProperties. The TaskProperties represents
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 219
220 def _validate_package_version(prop, value): 220 def _validate_package_version(prop, value):
221 """Validates a CIPD package version.""" 221 """Validates a CIPD package version."""
222 if not cipd.is_valid_version(value): 222 if not cipd.is_valid_version(value):
223 raise datastore_errors.BadValueError( 223 raise datastore_errors.BadValueError(
224 '%s must be a valid package version "%s"' % (prop._name, value)) 224 '%s must be a valid package version "%s"' % (prop._name, value))
225 225
226 226
227 def _validate_package_path(_prop, path): 227 def _validate_package_path(_prop, path):
228 """Validates a CIPD installation path.""" 228 """Validates a CIPD installation path."""
229 if not path:
230 raise datastore_errors.BadValueError(
231 'CIPD package path is required. Use "." to install to run dir.')
229 _validate_rel_path('CIPD package path', path) 232 _validate_rel_path('CIPD package path', path)
230 233
231 234
235 def _validate_output_path(_prop, value):
236 """Validates a path for an output file."""
237 _validate_rel_path('output file', value)
238
239
232 def _validate_rel_path(value_name, path): 240 def _validate_rel_path(value_name, path):
233 if not path: 241 if not path:
234 raise datastore_errors.BadValueError( 242 raise datastore_errors.BadValueError(
235 '%s is required. Use "." to install to run dir.' % value_name) 243 'No argument provided for %s.' % value_name)
236 if '\\' in path: 244 if '\\' in path:
237 raise datastore_errors.BadValueError( 245 raise datastore_errors.BadValueError(
238 '%s cannot contain \\. On Windows forward-slashes ' 246 '%s cannot contain \\. On Windows forward-slashes '
239 'will be replaced with back-slashes.' % value_name) 247 'will be replaced with back-slashes.' % value_name)
240 if '..' in path.split('/'): 248 if '..' in path.split('/'):
241 raise datastore_errors.BadValueError( 249 raise datastore_errors.BadValueError(
242 '%s cannot contain "..".' % value_name) 250 '%s cannot contain "..".' % value_name)
243 normalized = posixpath.normpath(path) 251 normalized = posixpath.normpath(path)
244 if path != normalized: 252 if path != normalized:
245 raise datastore_errors.BadValueError( 253 raise datastore_errors.BadValueError(
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 # Bot controlled timeout for new bytes from the subprocess. If a subprocess 450 # Bot controlled timeout for new bytes from the subprocess. If a subprocess
443 # doesn't output new data to stdout for .io_timeout_secs, consider the command 451 # doesn't output new data to stdout for .io_timeout_secs, consider the command
444 # timed out. Optional. 452 # timed out. Optional.
445 io_timeout_secs = ndb.IntegerProperty( 453 io_timeout_secs = ndb.IntegerProperty(
446 validator=_validate_timeout, indexed=False) 454 validator=_validate_timeout, indexed=False)
447 455
448 # If True, the task can safely be served results from a previously succeeded 456 # If True, the task can safely be served results from a previously succeeded
449 # task. 457 # task.
450 idempotent = ndb.BooleanProperty(default=False, indexed=False) 458 idempotent = ndb.BooleanProperty(default=False, indexed=False)
451 459
460 # A list of outputs expected. If empty, all files written to
461 # $(ISOLATED_OUTDIR) will be returned; otherwise, the files in this list
462 # will be added to those in that directory.
463 outputs = ndb.StringProperty(repeated=True, indexed=False,
464 validator=_validate_output_path)
465
452 @property 466 @property
453 def is_terminate(self): 467 def is_terminate(self):
454 """If True, it is a terminate request.""" 468 """If True, it is a terminate request."""
455 return ( 469 return (
456 not self.commands and 470 not self.commands and
457 not self.command and 471 not self.command and
458 self.dimensions.keys() == [u'id'] and 472 self.dimensions.keys() == [u'id'] and
459 not (self.inputs_ref and self.inputs_ref.isolated) and 473 not (self.inputs_ref and self.inputs_ref.isolated) and
460 not self.env and 474 not self.env and
461 not self.execution_timeout_secs and 475 not self.execution_timeout_secs and
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 init_new_request(request, allow_high_priority) 914 init_new_request(request, allow_high_priority)
901 return request 915 return request
902 916
903 917
904 def validate_priority(priority): 918 def validate_priority(priority):
905 """Throws ValueError if priority is not a valid value.""" 919 """Throws ValueError if priority is not a valid value."""
906 if 0 > priority or MAXIMUM_PRIORITY < priority: 920 if 0 > priority or MAXIMUM_PRIORITY < priority:
907 raise datastore_errors.BadValueError( 921 raise datastore_errors.BadValueError(
908 'priority (%d) must be between 0 and %d (inclusive)' % 922 'priority (%d) must be between 0 and %d (inclusive)' %
909 (priority, MAXIMUM_PRIORITY)) 923 (priority, MAXIMUM_PRIORITY))
OLDNEW
« no previous file with comments | « appengine/swarming/local_smoke_test.py ('k') | appengine/swarming/server/task_request_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698