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

Issue 2628523004: Allow module self-reference in loader (Closed)

Created:
3 years, 11 months ago by Paweł Hajdan Jr.
Modified:
3 years, 10 months ago
CC:
chromium-reviews, infra-reviews+recipes-py_chromium.org
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Allow module self-reference in loader See https://chromium-review.googlesource.com/c/426658/ for example where it's useful. BUG=679756

Patch Set 1 #

Patch Set 2 : typo #

Unified diffs Side-by-side diffs Delta from patch set Stats (+41 lines, -0 lines) Patch
M recipe_engine/loader.py View 1 chunk +5 lines, -0 lines 0 comments Download
A recipes/example/module_self_ref.py View 1 1 chunk +23 lines, -0 lines 0 comments Download
A recipes/example/module_self_ref.expected/basic.json View 1 chunk +13 lines, -0 lines 0 comments Download

Messages

Total messages: 15 (11 generated)
Paweł Hajdan Jr.
3 years, 11 months ago (2017-01-10 15:52:52 UTC) #8
iannucci
On 2017/01/10 at 15:52:52, phajdan.jr wrote: > This seems unnecessary... why can't you pass self ...
3 years, 11 months ago (2017-01-10 19:03:24 UTC) #13
Paweł Hajdan Jr.
On 2017/01/10 19:03:24, iannucci wrote: > This seems unnecessary... why can't you pass self instead ...
3 years, 11 months ago (2017-01-10 19:14:19 UTC) #14
iannucci
3 years, 11 months ago (2017-01-10 19:15:35 UTC) #15
On 2017/01/10 at 19:03:24, iannucci wrote:
> On 2017/01/10 at 15:52:52, phajdan.jr wrote:
> > 
> 
> This seems unnecessary... why can't you pass self instead of creating a
reference cycle on every module?

Ah, nevermind, I see the difference.

However the CL you pointed to looks wrong to me; I don't think the pattern of
passing the whole api object around is a good one at all. The purpose of
declaring dependencies in the module definition was so that the dependencies of
everything in recipes would be clear (or more-clear). The .m pattern itself
wasn't a great design choice itself. The code in question obscures the
dependencies in a not-so-good way (i.e. everything gets the same api blob which
is the union of all of the deps for every implementation). 

I think that adding this to the recipe engine loader would legitimize and
further encourage this pattern, which I don't think is a good idea. I realize
that you're refactoring the chromium recipes to make them simpler and easier to
work with, and as a transitionary measure, manually injecting self into the .m
collection (and probably JUST for functions that interact with Test objects like
serialized_test_runner()) there is ok. I don't think any other modules besides
the chromium ones exhibit this pattern though, so I don't think adding it to the
core engine is a good idea.

Powered by Google App Engine
This is Rietveld 408576698