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

Unified Diff: recipe_modules/step/api.py

Issue 2934583003: [step] Remove config indirection. (Closed)
Patch Set: cleanup 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
Index: recipe_modules/step/api.py
diff --git a/recipe_modules/step/api.py b/recipe_modules/step/api.py
index 4a250c1b057290e7cebcc247be4c41c866297e16..fba027c19895bd2389f188d4bb98a90cc25a63f2 100644
--- a/recipe_modules/step/api.py
+++ b/recipe_modules/step/api.py
@@ -4,8 +4,11 @@
import contextlib
import copy
+import types
from recipe_engine import recipe_api
+from recipe_engine.config_types import Path
+from recipe_engine.util import Placeholder
# Inherit from RecipeApiPlain because the only thing which is a step is
@@ -137,33 +140,6 @@ class StepApi(recipe_api.RecipeApiPlain):
Returns:
Opaque step object produced and understood by recipe engine.
"""
- kwargs = {}
- if allow_subannotations is not None:
- kwargs['allow_subannotations'] = allow_subannotations
- if trigger_specs:
- kwargs['trigger_specs'] = trigger_specs
- if stdout:
- kwargs['stdout'] = stdout
- if stderr:
- kwargs['stderr'] = stderr
- if stdin:
- kwargs['stdin'] = stdin
- if step_test_data:
- kwargs['step_test_data'] = step_test_data
- assert cmd is None or isinstance(cmd, list)
- if not ok_ret:
- ok_ret = {0}
- if ok_ret in ('any', 'all'):
- ok_ret = set(range(-256, 256))
-
- if cmd is not None:
- command = list(wrapper)
- command += cmd
- kwargs['cmd'] = command
-
- kwargs['timeout'] = timeout
- kwargs['ok_ret'] = ok_ret
-
# Calculate our full step name. If a step already has that name, add an
# index to the end of it.
#
@@ -184,25 +160,61 @@ class StepApi(recipe_api.RecipeApiPlain):
name_suffix = ' (%d)' % step_count
self._seen_steps.add(full_name)
+ assert isinstance(cmd, (types.NoneType, list))
+ if cmd is not None:
+ cmd = list(wrapper) + cmd
+ assert all(isinstance(x, (int, long, basestring, Path, Placeholder))
+ for x in cmd)
+
cwd = self.m.context.cwd
- if cwd is not None and cwd != self.m.path['start_dir']:
- kwargs['cwd'] = cwd
- kwargs['env'] = self.m.context.env
+ if cwd and cwd == self.m.path['start_dir']:
+ cwd = None
+
+ env = self.m.context.env
if self._prefix_path:
ps = self.m.path.pathsep
prefix = ps.join(self._prefix_path)
- suffix = kwargs['env'].get('PATH', '%(PATH)s')
- kwargs['env']['PATH'] = '%s%s%s' % (prefix, ps, suffix)
- kwargs['infra_step'] = self.m.context.infra_step or bool(infra_step)
- kwargs['step_nest_level'] = self.m.context.nest_level
- kwargs['name'] = full_name
- kwargs['base_name'] = name
-
- schema = self.make_config()
- schema.set_val(kwargs)
- return self.run_from_dict(schema.as_jsonish())
-
- # TODO(martiniss) delete, and make generator_script use **kwargs on step()
+ suffix = env.get('PATH', '%(PATH)s')
+ env['PATH'] = '%s%s%s' % (prefix, ps, suffix)
+
+ if ok_ret in ('any', 'all'):
+ ok_ret = range(-256, 256)
+
+ return self.run_step(
+ name=full_name,
+ base_name=full_name or name,
+ cmd=cmd,
+ cwd=cwd,
+ env=env,
+ allow_subannotations=bool(allow_subannotations),
+ trigger_specs=[self._make_trigger_spec(trig)
+ for trig in (trigger_specs or ())],
+ timeout=timeout,
+ infra_step=self.m.context.infra_step or bool(infra_step),
+ stdout=stdout,
+ stderr=stderr,
+ stdin=stdin,
+ ok_ret=ok_ret,
+ step_test_data=step_test_data,
+ nest_level=self.m.context.nest_level,
+ )
+
@recipe_api.composite_step
- def run_from_dict(self, dct):
- return self.step_client.run_step(dct)
+ def run_step(self, **kwargs):
+ # TODO(dnj,iannucci): Remove this once "generator_script" is deleted. Make
+ # sure we preserve "composite_step".
+ return self.step_client.run_step(**kwargs)
+
+ def _make_trigger_spec(self, trig):
+ buildbot_changes = trig.get('buildbot_changes')
+ assert isinstance(buildbot_changes, (types.NoneType, list))
+
+ critical = trig.get('critical')
+ return self.step_client.make_trigger_spec(
+ bucket=trig.get('bucket'),
+ builder_name=trig['builder_name'],
+ properties=trig.get('properties'),
+ buildbot_changes=buildbot_changes,
+ tags=trig.get('tags'),
+ critical=bool(critical) if critical is not None else (True),
+ )

Powered by Google App Engine
This is Rietveld 408576698