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

Side by Side Diff: client/swarming.py

Issue 1939343002: swarming: change meaning of inputs_ref (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@master
Patch Set: remove FilesRef.is_ref Created 4 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 unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2013 The LUCI Authors. All rights reserved. 2 # Copyright 2013 The LUCI Authors. All rights reserved.
3 # Use of this source code is governed by the Apache v2.0 license that can be 3 # Use of this source code is governed by the Apache v2.0 license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Client tool to trigger tasks or retrieve results from a Swarming server.""" 6 """Client tool to trigger tasks or retrieve results from a Swarming server."""
7 7
8 __version__ = '0.8.5' 8 __version__ = '0.8.5'
9 9
10 import collections 10 import collections
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 else: 114 else:
115 key = options.user 115 key = options.user
116 options.task_name = u'%s/%s/%s' % ( 116 options.task_name = u'%s/%s/%s' % (
117 key, 117 key,
118 '_'.join( 118 '_'.join(
119 '%s=%s' % (k, v) 119 '%s=%s' % (k, v)
120 for k, v in sorted(options.dimensions.iteritems())), 120 for k, v in sorted(options.dimensions.iteritems())),
121 options.isolated) 121 options.isolated)
122 122
123 inputs_ref = FilesRef( 123 inputs_ref = FilesRef(
124 isolated=options.isolated, 124 isolated=options.isolated,
125 isolatedserver=options.isolate_server, 125 isolatedserver=options.isolate_server,
126 namespace=options.namespace) 126 namespace=options.namespace)
127 return isolated_cmd_args, inputs_ref 127 return isolated_cmd_args, inputs_ref
128 128
129 129
130 ### Triggering. 130 ### Triggering.
131 131
132 132
133 # See ../appengine/swarming/swarming_rpcs.py. 133 # See ../appengine/swarming/swarming_rpcs.py.
134 FilesRef = collections.namedtuple( 134 FilesRef = collections.namedtuple(
135 'FilesRef', 135 'FilesRef',
136 [ 136 [
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 '%s=%s' % (k, v) 923 '%s=%s' % (k, v)
924 for k, v in sorted(options.dimensions.iteritems()))) 924 for k, v in sorted(options.dimensions.iteritems())))
925 inputs_ref = None 925 inputs_ref = None
926 else: 926 else:
927 isolateserver.process_isolate_server_options(parser, options, False, True) 927 isolateserver.process_isolate_server_options(parser, options, False, True)
928 try: 928 try:
929 command, inputs_ref = isolated_handle_options(options, args) 929 command, inputs_ref = isolated_handle_options(options, args)
930 except ValueError as e: 930 except ValueError as e:
931 parser.error(str(e)) 931 parser.error(str(e))
932 932
933 # If inputs_ref is used, command is actually extra_args. Otherwise it's an 933 # If inputs_ref.isolated is used, command is actually extra_args.
934 # actual command to run. 934 # Otherwise it's an actual command to run.
935 isolated_input = inputs_ref and inputs_ref.isolated
935 properties = TaskProperties( 936 properties = TaskProperties(
936 command=None if inputs_ref else command, 937 command=None if isolated_input else command,
937 dimensions=options.dimensions, 938 dimensions=options.dimensions,
938 env=options.env, 939 env=options.env,
939 execution_timeout_secs=options.hard_timeout, 940 execution_timeout_secs=options.hard_timeout,
940 extra_args=command if inputs_ref else None, 941 extra_args=command if isolated_input else None,
941 grace_period_secs=30, 942 grace_period_secs=30,
942 idempotent=options.idempotent, 943 idempotent=options.idempotent,
943 inputs_ref=inputs_ref, 944 inputs_ref=inputs_ref,
944 io_timeout_secs=options.io_timeout) 945 io_timeout_secs=options.io_timeout)
945 if not all(len(t.split(':', 1)) == 2 for t in options.tags): 946 if not all(len(t.split(':', 1)) == 2 for t in options.tags):
946 parser.error('--tags must be in the format key:value') 947 parser.error('--tags must be in the format key:value')
947 return NewTaskRequest( 948 return NewTaskRequest(
948 expiration_secs=options.expiration, 949 expiration_secs=options.expiration,
949 name=options.task_name, 950 name=options.task_name,
950 parent_task_id=os.environ.get('SWARMING_TASK_ID', ''), 951 parent_task_id=os.environ.get('SWARMING_TASK_ID', ''),
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
1371 if properties.get('env'): 1372 if properties.get('env'):
1372 env = os.environ.copy() 1373 env = os.environ.copy()
1373 logging.info('env: %r', properties['env']) 1374 logging.info('env: %r', properties['env'])
1374 for i in properties['env']: 1375 for i in properties['env']:
1375 key = i['key'].encode('utf-8') 1376 key = i['key'].encode('utf-8')
1376 if not i['value']: 1377 if not i['value']:
1377 env.pop(key, None) 1378 env.pop(key, None)
1378 else: 1379 else:
1379 env[key] = i['value'].encode('utf-8') 1380 env[key] = i['value'].encode('utf-8')
1380 1381
1381 if properties.get('inputs_ref'): 1382 if properties.get('inputs_ref'):
M-A Ruel 2016/05/12 13:47:03 This assumption needs to fixed too.
1382 # Create the tree. 1383 # Create the tree.
1383 with isolateserver.get_storage( 1384 with isolateserver.get_storage(
1384 properties['inputs_ref']['isolatedserver'], 1385 properties['inputs_ref']['isolatedserver'],
1385 properties['inputs_ref']['namespace']) as storage: 1386 properties['inputs_ref']['namespace']) as storage:
1386 bundle = isolateserver.fetch_isolated( 1387 bundle = isolateserver.fetch_isolated(
1387 properties['inputs_ref']['isolated'], 1388 properties['inputs_ref']['isolated'],
1388 storage, 1389 storage,
1389 isolateserver.MemoryCache(file_mode_mask=0700), 1390 isolateserver.MemoryCache(file_mode_mask=0700),
1390 workdir) 1391 workdir)
1391 command = bundle.command 1392 command = bundle.command
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1524 def main(args): 1525 def main(args):
1525 dispatcher = subcommand.CommandDispatcher(__name__) 1526 dispatcher = subcommand.CommandDispatcher(__name__)
1526 return dispatcher.execute(OptionParserSwarming(version=__version__), args) 1527 return dispatcher.execute(OptionParserSwarming(version=__version__), args)
1527 1528
1528 1529
1529 if __name__ == '__main__': 1530 if __name__ == '__main__':
1530 fix_encoding.fix_encoding() 1531 fix_encoding.fix_encoding()
1531 tools.disable_buffering() 1532 tools.disable_buffering()
1532 colorama.init() 1533 colorama.init()
1533 sys.exit(main(sys.argv[1:])) 1534 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « appengine/swarming/swarming_bot/bot_code/task_runner_test.py ('k') | client/tests/swarming_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698