Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recipe and recipe execution #1117

Closed
wants to merge 1 commit into from
Closed

Conversation

ttung
Copy link
Collaborator

@ttung ttung commented Mar 28, 2019

Builds on top of #1097 to construct and run recipes with one or more runnables.

A recipe wires together one or more runnables. Inputs to recipes are available to the recipe itself as the magic variable name "file_inputs". A runnable is invoked by the magic function "compute". Anything written to the magic variable "file_outputs" is matched and written out to a set of output paths.

Fixes #311

@ttung
Copy link
Collaborator Author

ttung commented Mar 28, 2019

This lacks tests, documentation, and probably has bugs. But I wanted to get this out in front of you guys sooner rather than later.

@codecov-io
Copy link

codecov-io commented Mar 28, 2019

Codecov Report

Merging #1117 into tonytung-runnable will increase coverage by 0.24%.
The diff coverage is 97.64%.

Impacted file tree graph

@@                  Coverage Diff                  @@
##           tonytung-runnable    #1117      +/-   ##
=====================================================
+ Coverage              89.07%   89.31%   +0.24%     
=====================================================
  Files                    131      132       +1     
  Lines                   4980     5065      +85     
=====================================================
+ Hits                    4436     4524      +88     
+ Misses                   544      541       -3
Impacted Files Coverage Δ
starfish/recipe/__init__.py 100% <100%> (ø) ⬆️
starfish/recipe/recipe.py 97.61% <97.61%> (ø)
starfish/recipe/runnable.py 95.74% <0%> (+1.06%) ⬆️
starfish/recipe/filesystem.py 95.91% <0%> (+8.16%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8519322...8860ad4. Read the comment docs.

Copy link
Member

@ambrosejcarr ambrosejcarr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read the tests, everything looks good from a user perspective. I didn't read the code in detail (can I leave @shanaxel42 to do that part of the review?)

You're going to add some documentation about how a user would use this, right? :-)


result_stack = ImageStack.from_path_or_url(output_path)
assert np.allclose(
BASE_EXPECTED * .5,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing suggestion:

Change the multiplicands to 0.5, 2.0, 4.0, and the expected to BASE_EXPECTED * 4; as the test stands, it would pass if only the first compute call executed for some reason.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did something similar to what you suggested.

@ttung ttung force-pushed the tonytung-recipe branch from 9a307c0 to 61b6ae3 Compare April 2, 2019 08:53
self.runnable_dependents: Mapping[Runnable, AbstractSet[Runnable]] = runnable_dependents

# completed results
self._completed_runnables: Set[Runnable] = set()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this imply that you could never have duplicate runnables?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, even runnables with the same parameters are treated as distinct entities.

while True:
candidate_runnable = next(self._runnable_sequence)

if candidate_runnable in self.needed_runnables:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what exactly does self.needed_runnables mean in this context?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, this is undesirable, and as such, removed.

if dependency not in runnable_dependents:
runnable_dependents[dependency] = set()
runnable_dependents[dependency].add(runnable)
Execution.build_graph(dependency, needed_runnables, runnable_dependents)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool

"compute": ordered_sequence,
"file_outputs": outputs,
}
ast = compile(recipe_str, "<string>", "exec")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does ast stand for?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

abstract syntax tree.

starfish/recipe/recipe.py Show resolved Hide resolved
ast = compile(recipe_str, "<string>", "exec")
exec(ast, recipe_scope)

assert len(outputs) == len(output_paths), \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outputs == fileoutputs

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@ttung ttung force-pushed the tonytung-recipe branch 3 times, most recently from d680299 to 9458cd6 Compare April 3, 2019 06:37
@ttung ttung force-pushed the tonytung-runnable branch from 75912cb to d02cb1d Compare April 3, 2019 06:40
@ttung ttung force-pushed the tonytung-recipe branch 4 times, most recently from a56438c to f220346 Compare April 3, 2019 18:40
@ttung ttung force-pushed the tonytung-runnable branch from 0d68051 to ee1a160 Compare April 4, 2019 00:55
@ttung ttung force-pushed the tonytung-recipe branch 2 times, most recently from e4db852 to caeb9b7 Compare April 4, 2019 01:04
@ttung ttung changed the title RFC: Recipe and recipe execution Recipe and recipe execution Apr 4, 2019
@ttung ttung force-pushed the tonytung-recipe branch 2 times, most recently from dc3e260 to c1fb51b Compare April 5, 2019 01:45
@ttung ttung force-pushed the tonytung-runnable branch from 54f428d to 959fa44 Compare April 5, 2019 01:52
@ttung ttung force-pushed the tonytung-recipe branch from c1fb51b to 79e25a0 Compare April 5, 2019 01:52
@ttung ttung force-pushed the tonytung-runnable branch from 959fa44 to c1d3b2f Compare April 5, 2019 08:06
@ttung ttung force-pushed the tonytung-recipe branch 4 times, most recently from c3f09a5 to dcd0212 Compare April 6, 2019 21:48
ttung added a commit that referenced this pull request Apr 23, 2019
1. Add the recipe runner CLI entry point.
2. Add a recipe for the ISS pipeline and a test that exercises the recipe.

Test plan: `pytest starfish/test/full_pipelines/recipe`

Depends on #1117

Fixes #311
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants