-
Notifications
You must be signed in to change notification settings - Fork 5
feat: Support aggregation client in preprocessing steps #618
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
Open
ThanKarab
wants to merge
1
commit into
master
Choose a base branch
from
feature/MIP-1273_add_agg_client_in_preprocessing_steps
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
tests/standalone_tests/controller/services/test_algorithm_execution_strategy_factory.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| import sys | ||
| import types | ||
|
|
||
| from exaflow.algorithms.specifications import ComponentType | ||
|
|
||
| dns_module = types.ModuleType("dns") | ||
| dns_resolver_module = types.ModuleType("dns.resolver") | ||
| dns_module.resolver = dns_resolver_module | ||
| sys.modules.setdefault("dns", dns_module) | ||
| sys.modules.setdefault("dns.resolver", dns_resolver_module) | ||
|
|
||
| from exaflow.controller.services import algorithm_execution_strategy_factory as factory | ||
| from exaflow.controller.services.api.analysis_request_dtos import AnalysisAlgorithmDTO | ||
| from exaflow.controller.services.api.analysis_request_dtos import AnalysisInputDataDTO | ||
| from exaflow.controller.services.api.analysis_request_dtos import ( | ||
| AnalysisPreprocessingStepDTO, | ||
| ) | ||
| from exaflow.controller.services.api.analysis_request_dtos import AnalysisRequestDTO | ||
| from exaflow.controller.services.exareme3.strategies import Exareme3Strategy | ||
| from exaflow.controller.services.exareme3.strategies import ( | ||
| Exareme3WithAggregationServerStrategy, | ||
| ) | ||
|
|
||
|
|
||
| class _NoAggregationPreprocessing: | ||
| @classmethod | ||
| def aggregation_server_required(cls): | ||
| return False | ||
|
|
||
|
|
||
| class _AggregationPreprocessing: | ||
| @classmethod | ||
| def aggregation_server_required(cls): | ||
| return True | ||
|
|
||
|
|
||
| class _Specifications: | ||
| def get_component_types(self, algo_name): | ||
| return [] | ||
|
|
||
|
|
||
| def _request(preprocessing=None): | ||
| return AnalysisRequestDTO( | ||
| inputdata=AnalysisInputDataDTO( | ||
| data_model="dementia", | ||
| datasets=["ppmi0"], | ||
| variables=["x"], | ||
| ), | ||
| preprocessing=preprocessing, | ||
| algorithm=AnalysisAlgorithmDTO(name="sample_algo", y=["x"]), | ||
| ) | ||
|
|
||
|
|
||
| def test_preprocessing_aggregation_requirement_contributes_component(monkeypatch): | ||
| monkeypatch.setattr(factory, "specifications", _Specifications()) | ||
| monkeypatch.setattr( | ||
| factory, | ||
| "exareme3_preprocessing_step_classes", | ||
| { | ||
| "local": _NoAggregationPreprocessing, | ||
| "global": _AggregationPreprocessing, | ||
| }, | ||
| ) | ||
|
|
||
| components = factory._get_required_component_types( | ||
| _request( | ||
| preprocessing=[ | ||
| AnalysisPreprocessingStepDTO(name="local", parameters={}), | ||
| AnalysisPreprocessingStepDTO(name="global", parameters={}), | ||
| ] | ||
| ) | ||
| ) | ||
|
|
||
| assert ComponentType.AGGREGATION_SERVER in components | ||
|
|
||
|
|
||
| def test_preprocessing_aggregation_component_selects_aggregation_strategy(): | ||
| strategy_type = factory._get_algorithm_strategy_type( | ||
| algo_type=factory.AlgorithmType.EXAREME3, | ||
| algo_component_types=[ComponentType.AGGREGATION_SERVER], | ||
| ) | ||
|
|
||
| assert strategy_type is Exareme3WithAggregationServerStrategy | ||
|
|
||
|
|
||
| def test_no_aggregation_component_selects_plain_exareme3_strategy(): | ||
| strategy_type = factory._get_algorithm_strategy_type( | ||
| algo_type=factory.AlgorithmType.EXAREME3, | ||
| algo_component_types=[], | ||
| ) | ||
|
|
||
| assert strategy_type is Exareme3Strategy |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this?