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

Unified Diff: appengine/swarming/server/task_to_run.py

Issue 2926713004: Add support for repeated keys in TaskRequest. (Closed)
Patch Set: rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/swarming/server/task_scheduler_test.py ('k') | appengine/swarming/server/task_to_run_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/swarming/server/task_to_run.py
diff --git a/appengine/swarming/server/task_to_run.py b/appengine/swarming/server/task_to_run.py
index de69703f6263203344cb2e10fd2f2586bb22a09d..d8c8bd14c6bd880ad9026b45dc73c74f1ffae940 100644
--- a/appengine/swarming/server/task_to_run.py
+++ b/appengine/swarming/server/task_to_run.py
@@ -427,17 +427,17 @@ def validate_to_run_key(task_key):
def match_dimensions(request_dimensions, bot_dimensions):
- """Returns True if the bot dimensions satisfies the request dimensions."""
- assert isinstance(request_dimensions, dict), request_dimensions
+ """Returns True if the bot dimensions satisfies the request dimensions.
+
+ Arguments:
+ request_dimensions: list(tuple(unicode, unicode)).
+ bot_dimensions: dict(unicode: list(unicode)).
+ """
+ assert isinstance(request_dimensions, list), request_dimensions
assert isinstance(bot_dimensions, dict), bot_dimensions
- if frozenset(request_dimensions).difference(bot_dimensions):
- return False
- for key, required in request_dimensions.iteritems():
- bot_value = bot_dimensions[key]
- if isinstance(bot_value, (list, tuple)):
- if required not in bot_value:
- return False
- elif required != bot_value:
+ for key, required in request_dimensions:
+ bot_value = bot_dimensions.get(key)
+ if not bot_value or required not in bot_value:
return False
return True
« no previous file with comments | « appengine/swarming/server/task_scheduler_test.py ('k') | appengine/swarming/server/task_to_run_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698