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

Side by Side Diff: appengine/swarming/message_conversion.py

Issue 2928823002: Make backward-forward compatible version. (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « no previous file | appengine/swarming/server/task_queues_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 # Copyright 2015 The LUCI Authors. All rights reserved. 1 # Copyright 2015 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed under the Apache License, Version 2.0 2 # Use of this source code is governed under the Apache License, Version 2.0
3 # that can be found in the LICENSE file. 3 # that can be found in the LICENSE file.
4 4
5 """This module facilitates conversion from dictionaries to ProtoRPC messages. 5 """This module facilitates conversion from dictionaries to ProtoRPC messages.
6 6
7 Given a dictionary whose keys' names and values' types comport with the 7 Given a dictionary whose keys' names and values' types comport with the
8 fields defined for a protorpc.messages.Message subclass, this module tries to 8 fields defined for a protorpc.messages.Message subclass, this module tries to
9 generate a Message instance that corresponds to the provided dictionary. The 9 generate a Message instance that corresponds to the provided dictionary. The
10 "normal" use case is for ndb.Models which need to be represented as a 10 "normal" use case is for ndb.Models which need to be represented as a
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 178
179 properties = _rpc_to_ndb( 179 properties = _rpc_to_ndb(
180 task_request.TaskProperties, 180 task_request.TaskProperties,
181 props, 181 props,
182 caches=[_rpc_to_ndb(task_request.CacheEntry, c) for c in props.caches], 182 caches=[_rpc_to_ndb(task_request.CacheEntry, c) for c in props.caches],
183 cipd_input=cipd_input, 183 cipd_input=cipd_input,
184 # Passing command=None is supported at API level but not at NDB level. 184 # Passing command=None is supported at API level but not at NDB level.
185 command=props.command or [], 185 command=props.command or [],
186 has_secret_bytes=secret_bytes is not None, 186 has_secret_bytes=secret_bytes is not None,
187 secret_bytes=None, # ignore this, it's handled out of band 187 secret_bytes=None, # ignore this, it's handled out of band
188 dimensions={i.key: i.value for i in props.dimensions}, 188 dimensions=None,
189 dimensions_dict={i.key: i.value for i in props.dimensions},
190 dimensions_flat=[],
189 env={i.key: i.value for i in props.env}, 191 env={i.key: i.value for i in props.env},
190 inputs_ref=inputs_ref) 192 inputs_ref=inputs_ref)
191 193
192 req = _rpc_to_ndb( 194 req = _rpc_to_ndb(
193 task_request.TaskRequest, 195 task_request.TaskRequest,
194 msg, 196 msg,
195 created_ts=now, 197 created_ts=now,
196 expiration_ts=now+datetime.timedelta(seconds=msg.expiration_secs), 198 expiration_ts=now+datetime.timedelta(seconds=msg.expiration_secs),
197 # It is set in task_request.init_new_request(). 199 # It is set in task_request.init_new_request().
198 authenticated=None, 200 authenticated=None,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 kwargs['run_id'] = entity.task_id 257 kwargs['run_id'] = entity.task_id
256 else: 258 else:
257 assert entity.__class__ is task_result.TaskResultSummary, entity 259 assert entity.__class__ is task_result.TaskResultSummary, entity
258 kwargs['properties_hash'] = ( 260 kwargs['properties_hash'] = (
259 entity.properties_hash.encode('hex') 261 entity.properties_hash.encode('hex')
260 if entity.properties_hash else None) 262 if entity.properties_hash else None)
261 # This returns the right value for deduped tasks too. 263 # This returns the right value for deduped tasks too.
262 k = entity.run_result_key 264 k = entity.run_result_key
263 kwargs['run_id'] = task_pack.pack_run_result_key(k) if k else None 265 kwargs['run_id'] = task_pack.pack_run_result_key(k) if k else None
264 return _ndb_to_rpc(swarming_rpcs.TaskResult, entity, **kwargs) 266 return _ndb_to_rpc(swarming_rpcs.TaskResult, entity, **kwargs)
OLDNEW
« no previous file with comments | « no previous file | appengine/swarming/server/task_queues_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698