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

Introduce Runnable #1163

Merged
merged 1 commit into from
Apr 22, 2019
Merged

Introduce Runnable #1163

merged 1 commit into from
Apr 22, 2019

Conversation

ttung
Copy link
Collaborator

@ttung ttung commented Apr 11, 2019

Runnable is the base unit of a recipe. Each runnable constitutes a PipelineComponent with a specific algorithm. Constructor arguments that are FileProviders are loaded into memory and passed in. Inputs to the run() method can also include FileProviders. In all cases, FileProviders are associated with a file path or url. The type is inferred from the typing parameters of the method (currently supported: ImageStack, IntensityTable, ExpressionMatrix, and Codebook).

Runnables will be wired together to constitute a pipeline recipe.

Test plan: Added tests to verify a simple Runnable, chained Runnables, and Runnables that has constructor arguments that are FileProviders.

This is a continuation of #1097

@codecov-io
Copy link

codecov-io commented Apr 11, 2019

Codecov Report

Merging #1163 into master will increase coverage by 0.13%.
The diff coverage is 92.76%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1163      +/-   ##
==========================================
+ Coverage   88.42%   88.55%   +0.13%     
==========================================
  Files         133      137       +4     
  Lines        4923     5075     +152     
==========================================
+ Hits         4353     4494     +141     
- Misses        570      581      +11
Impacted Files Coverage Δ
starfish/recipe/errors.py 100% <100%> (ø)
starfish/recipe/__init__.py 100% <100%> (ø)
starfish/recipe/filesystem.py 87.75% <87.75%> (ø)
starfish/recipe/runnable.py 94.44% <94.44%> (ø)

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 051f77c...389da68. 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.

Looks ok to me. Would like some usage docs for this concept and a pointer to the tip of your tree so that I can test the functionality.

Would like @shanaxel42 or @kne42 to take a close look at the code.

The save method is expected to be called with the object and a string, which is the path to
write the object to.
"""
IMAGESTACK = (ImageStack, imagestack_convert, ImageStack.export)
Copy link
Member

Choose a reason for hiding this comment

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

Scope creep: I feel the save/load names for our methods should be consistent across the 4 objects we have. What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

#1097 (comment)

LOL you and @shanaxel42 think alike. :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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



class FileProvider:
"""This is used to wrap paths or URLs that are passed into Runnables via the `file_inputs` magic
Copy link
Member

Choose a reason for hiding this comment

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

file_inputs is not used anywhere in this PR, just mentioned in docs. Confused.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it's used in a separate PR. :)

Copy link
Collaborator Author

@ttung ttung left a comment

Choose a reason for hiding this comment

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

Looks ok to me. Would like some usage docs for this concept and a pointer to the tip of your tree so that I can test the functionality.

check out the branch tonytung-recipe-cli



class FileProvider:
"""This is used to wrap paths or URLs that are passed into Runnables via the `file_inputs` magic
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it's used in a separate PR. :)

The save method is expected to be called with the object and a string, which is the path to
write the object to.
"""
IMAGESTACK = (ImageStack, imagestack_convert, ImageStack.export)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

@shanaxel42 shanaxel42 left a comment

Choose a reason for hiding this comment

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

I think just some more comments in the tests/runnable class explaining stuff would be helpful!

starfish/recipe/runnable.py Outdated Show resolved Hide resolved
starfish/recipe/runnable.py Outdated Show resolved Hide resolved
with pytest.raises(ConstructorError):
Runnable(
"filter", "SimpleFilterAlgorithm",
FileProvider(URL),
Copy link
Collaborator

Choose a reason for hiding this comment

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

why does this error? because we don't provide params?

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. Updated the documentation.



def test_run_type_inference_error():
"""Verify that we get a properly typed error when we cannot properly infer the type for one of
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could use more explanation here too, maybe some comments about what input causes the error

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed, and added more commentary on how to fix this error in the documentation for TypeInferenceError.

@ttung ttung requested a review from shanaxel42 April 17, 2019 02:33
@ttung ttung force-pushed the tonytung-runnable branch from 4cb0f6a to e7afa06 Compare April 18, 2019 19:52
@ttung ttung changed the base branch from master to tonytung-normalize April 18, 2019 19:52
@ttung
Copy link
Collaborator Author

ttung commented Apr 18, 2019

Restacked on top of #1218

@ttung ttung force-pushed the tonytung-normalize branch 5 times, most recently from 057649b to 8616308 Compare April 19, 2019 16:10
@ttung ttung changed the base branch from tonytung-normalize to master April 19, 2019 16:35
@ttung ttung force-pushed the tonytung-runnable branch from e7afa06 to 389da68 Compare April 19, 2019 16:37
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.

Looks good enough to merge. Should we recipe -> _recipe? I am guessing users won't call this from the API.

I may have follow-up comments when I try it out more thoroughly.

)


def imagestack_convert(indirect_path_or_url: str) -> ImageStack:
Copy link
Member

Choose a reason for hiding this comment

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

single-line docstring please: what is this intended to do?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added doc.

)


def codebook_convert(indirect_path_or_url: str) -> Codebook:
Copy link
Member

Choose a reason for hiding this comment

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

single-line docstring please: what is this intended to do?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added doc.

Runnable is the base unit of a recipe.  Each runnable constitutes a PipelineComponent with a specific algorithm.  Constructor arguments that are FileProviders are loaded into memory and passed in.  Inputs to the `run()` method can also include FileProviders.  In all cases, FileProviders are associated with a file path or url.  The type is inferred from the typing parameters of the method (currently supported: ImageStack, IntensityTable, ExpressionMatrix, and Codebook).

Runnables will be wired together to constitute a pipeline recipe.

Test plan: Added tests to verify a simple Runnable, chained Runnables, and Runnables that has constructor arguments that are FileProviders.

Depends on spacetx#1095
@ttung ttung force-pushed the tonytung-runnable branch from 389da68 to 0ef68e4 Compare April 22, 2019 19:28
@ttung ttung merged commit 36d08a3 into spacetx:master Apr 22, 2019
@ttung ttung deleted the tonytung-runnable branch April 22, 2019 19:29
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