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

Restructure the relationship between PipelineComponent and AlgorithmBase #1095

Merged
merged 1 commit into from
Mar 22, 2019

Conversation

ttung
Copy link
Collaborator

@ttung ttung commented Mar 19, 2019

Restructure the relationship between PipelineComponent and AlgorithmBase

Rather than each specific PipelineComponent have a link to the AlgorithmBase that describes the contract that the algorithm must implement, each AlgorithmBase implementation points to the PipelineComponent that it serves.

The current arrangement forces all the algorithms to be defined and evaluated in the interpreter before the pipeline component is defined and evaluated. If we want to create an algorithm that's only used in tests, this is not possible.

The new arrangement ensures that any implementation of a specific AlgorithmBase is registered with its corresponding PipelineComponent.

This adds explicit abstract classes to the AlgorithmBase class hierarchy to make it easier to detect what's an actual algorithm implementation.

Depends on #1094

Test plan: make -j fast

@ttung
Copy link
Collaborator Author

ttung commented Mar 19, 2019

This also partially addresses #921

@ttung ttung force-pushed the tonytung-restructure-pipelines branch from 70e9a14 to d75719f Compare March 19, 2019 19:22
@codecov-io
Copy link

codecov-io commented Mar 19, 2019

Codecov Report

Merging #1095 into master will increase coverage by 0.02%.
The diff coverage is 98.72%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1095      +/-   ##
==========================================
+ Coverage   88.87%   88.89%   +0.02%     
==========================================
  Files         168      168              
  Lines        6535     6540       +5     
==========================================
+ Hits         5808     5814       +6     
+ Misses        727      726       -1
Impacted Files Coverage Δ
starfish/pipeline/pipelinecomponent.py 92.3% <ø> (-0.8%) ⬇️
starfish/spots/_decoder/_base.py 96.77% <100%> (+21.77%) ⬆️
starfish/image/_segmentation/__init__.py 100% <100%> (ø) ⬆️
starfish/image/_filter/_base.py 96.66% <100%> (+16.66%) ⬆️
starfish/spots/_pixel_decoder/__init__.py 100% <100%> (ø) ⬆️
starfish/spots/_detector/__init__.py 100% <100%> (+5.26%) ⬆️
starfish/spots/_decoder/__init__.py 100% <100%> (ø) ⬆️
starfish/image/_segmentation/_base.py 97.05% <100%> (+17.05%) ⬆️
starfish/spots/_target_assignment/__init__.py 100% <100%> (ø) ⬆️
starfish/spots/_pixel_decoder/_base.py 86.04% <100%> (+21.04%) ⬆️
... and 6 more

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 3033002...cbc8192. Read the comment docs.

@ttung ttung mentioned this pull request Mar 19, 2019


class AlgorithmBaseType(type):
DISALLOWED_BASES: Set[Type] = set()
Copy link
Collaborator

Choose a reason for hiding this comment

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

what's an example of a disallowed base?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let me improve the documentation. Basically, we want the subclasses of FilterAlgorithmBase, RegistrationAlgorithmBase, etc., and not the subclasses of AlgorithmBase.

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 went with a different approach that removed the need for this.

@ttung ttung changed the base branch from tonytung-get-component-by-name to master March 20, 2019 22:53
@ttung ttung force-pushed the tonytung-restructure-pipelines branch 3 times, most recently from 112224b to f9ec78f Compare March 21, 2019 02:14
@ttung ttung force-pushed the tonytung-restructure-pipelines branch from f9ec78f to 581974c Compare March 21, 2019 17:23
Rather than each specific PipelineComponent have a link to the AlgorithmBase that describes the contract that the algorithm must implement, each AlgorithmBase implementation points to the PipelineComponent that it serves.

The current arrangement forces all the algorithms to be defined and evaluated in the interpreter before the pipeline component is defined and evaluated.  If we want to create an algorithm that's only used in tests, this is not possible.

The new arrangement ensures that any implementation of a specific AlgorithmBase is registered with its corresponding PipelineComponent.

This adds explicit abstract classes to the AlgorithmBase class hierarchy to make it easier to detect what's an actual algorithm implementation.

Depends on #1094

Test plan: `make -j fast`
@ttung ttung force-pushed the tonytung-restructure-pipelines branch from 581974c to cbc8192 Compare March 22, 2019 03:53
@ttung ttung merged commit b2373f7 into master Mar 22, 2019
ttung added a commit that referenced this pull request Mar 22, 2019
…ase (#1095)

Rather than each specific PipelineComponent have a link to the AlgorithmBase that describes the contract that the algorithm must implement, each AlgorithmBase implementation points to the PipelineComponent that it serves.

The current arrangement forces all the algorithms to be defined and evaluated in the interpreter before the pipeline component is defined and evaluated.  If we want to create an algorithm that's only used in tests, this is not possible.

The new arrangement ensures that any implementation of a specific AlgorithmBase is registered with its corresponding PipelineComponent.

This adds explicit abstract classes to the AlgorithmBase class hierarchy to make it easier to detect what's an actual algorithm implementation.

Depends on #1094

Test plan: `make -j fast`
@ttung ttung deleted the tonytung-restructure-pipelines branch March 22, 2019 20:09
ttung pushed a commit that referenced this pull request Mar 22, 2019
ttung added a commit that referenced this pull request Mar 26, 2019
ttung pushed a commit to ttung/starfish that referenced this pull request Apr 22, 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.

Depends on spacetx#1095
ttung added a commit that referenced this pull request Apr 22, 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.

Depends on #1095
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.

3 participants