This repository has been archived by the owner on Feb 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(flow): make base flow as class not object
- Loading branch information
hanhxiao
committed
Oct 16, 2019
1 parent
a419c34
commit 660f8f9
Showing
3 changed files
with
40 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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,36 @@ | ||
from . import Flow | ||
|
||
|
||
class BaseIndexFlow(Flow): | ||
""" | ||
BaseIndexFlow defines a common service pipeline when indexing. | ||
It can not be directly used as all services are using the base module by default. | ||
You have to use :py:meth:`set` to change the `yaml_path` of each service. | ||
""" | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
(self.add_preprocessor(name='prep', yaml_path='BasePreprocessor', copy_flow=False) | ||
.add_encoder(name='enc', yaml_path='BaseEncoder', copy_flow=False) | ||
.add_indexer(name='vec_idx', yaml_path='BaseIndexer', copy_flow=False) | ||
.add_indexer(name='doc_idx', yaml_path='BaseIndexer', recv_from='prep', copy_flow=False) | ||
.add_router(name='sync', yaml_path='BaseReduceRouter', | ||
num_part=2, recv_from=['vec_idx', 'doc_idx'], copy_flow=False)) | ||
|
||
|
||
class BaseQueryFlow(Flow): | ||
""" | ||
BaseIndexFlow defines a common service pipeline when indexing. | ||
It can not be directly used as all services are using the base module by default. | ||
You have to use :py:meth:`set` to change the `yaml_path` of each service. | ||
""" | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
(self.add_preprocessor(name='prep', yaml_path='BasePreprocessor', copy_flow=False) | ||
.add_encoder(name='enc', yaml_path='BaseEncoder', copy_flow=False) | ||
.add_indexer(name='vec_idx', yaml_path='BaseIndexer', copy_flow=False) | ||
.add_router(name='scorer', yaml_path='Chunk2DocTopkReducer', copy_flow=False) | ||
.add_indexer(name='doc_idx', yaml_path='BaseIndexer', copy_flow=False)) |
This file was deleted.
Oops, something went wrong.
This file contains 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