From ec1eb78712db64018410b86b94bb6d6f70463335 Mon Sep 17 00:00:00 2001 From: hanhxiao Date: Tue, 20 Aug 2019 12:44:30 +0800 Subject: [PATCH] chore(release): fix duplicate release notes --- CHANGELOG.md | 31 ------------------------------- gnes/base/__init__.py | 31 +++++++++++++++++++++++++++++++ gnes/indexer/base.py | 9 --------- gnes/router/base.py | 16 ++++++++++++++++ 4 files changed, 47 insertions(+), 40 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8aeac105..80a744b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,34 +1,3 @@ - -# Release Note (`v0.0.30`) -> Release time: 2019-08-19 14:13:31 - - -🙇 We'd like to thank all contributors for this new release! In particular, - hanhxiao, 🙇 - - -### 🆕 New Features - - - [[```7b5cc86a```](https://github.com/gnes-ai/gnes/commit/7b5cc86a585c75965b224cb7f668cae2bb854885)] __-__ __contrib__: no need to give module name in advance (*hanhxiao*) - -### 🐞 Bug fixes - - - [[```b5b1a1e7```](https://github.com/gnes-ai/gnes/commit/b5b1a1e7877724851de8487de306b78d76b995ae)] __-__ __ci__: check if master is up-to-date before releasing (*hanhxiao*) - - [[```5f69c781```](https://github.com/gnes-ai/gnes/commit/5f69c7811376eba0d3724002724e0b30054447ed)] __-__ __contrib__: allowing dump for contribued module (*hanhxiao*) - -### 🚧 Code Refactoring - - - [[```ee61fcec```](https://github.com/gnes-ai/gnes/commit/ee61fcec49455417ef4694cfbabaa548b19ff03f)] __-__ __base__: parameter now names as parameters (*hanhxiao*) - -### 🏁 Unit Test and CICD - - - [[```435f7be7```](https://github.com/gnes-ai/gnes/commit/435f7be7096359437cf9c287eca780f775b9d341)] __-__ __drone__: fix drone links (*hanhxiao*) - - [[```cd8a5cc5```](https://github.com/gnes-ai/gnes/commit/cd8a5cc5bc0027f4f39d1a00ddfc854168365dcb)] __-__ __contrib__: test external modules with services (*hanhxiao*) - -### 🍹 Other Improvements - - - [[```565ef569```](https://github.com/gnes-ai/gnes/commit/565ef569b0ddfab2904c8b6f807f0ea88ddee429)] __-__ __changelog__: update change log to v0.0.29 (*hanhxiao*) - # Release Note (`v0.0.30`) > Release time: 2019-08-19 14:13:03 diff --git a/gnes/base/__init__.py b/gnes/base/__init__.py index 95177160..fcfcdca8 100644 --- a/gnes/base/__init__.py +++ b/gnes/base/__init__.py @@ -160,6 +160,10 @@ def arg_wrapper(self, *args, **kwargs): class TrainableBase(metaclass=TrainableType): + """ + The base class for preprocessor, encoder, indexer and router + + """ store_args_kwargs = False def __init__(self, *args, **kwargs): @@ -183,6 +187,10 @@ def _post_init_wrapper(self): self._post_init_vars = {k for k in self.__dict__ if k not in _before} def post_init(self): + """ + Declare class attributes/members that can not be serialized in standard way + + """ pass @classmethod @@ -191,10 +199,19 @@ def pre_init(cls): @property def dump_full_path(self): + """ + Get the binary dump path + + :return: + """ return os.path.join(self.work_dir, '%s.bin' % self.name) @property def yaml_full_path(self): + """ + Get the file path of the yaml config + :return: + """ return os.path.join(self.work_dir, '%s.yml' % self.name) def __getstate__(self): @@ -214,10 +231,17 @@ def __setstate__(self, d): 'which often can be solved by "pip install" relevant package.') def train(self, *args, **kwargs): + """ + Train the model, need to be overrided + """ pass @profiling def dump(self, filename: str = None) -> None: + """ + Serialize the object to a binary file + :param filename: file path of the serialized file, if not given then `self.dump_full_path` is used + """ f = filename or self.dump_full_path if not f: f = tempfile.NamedTemporaryFile('w', delete=False, dir=os.environ.get('GNES_VOLUME', None)).name @@ -227,6 +251,10 @@ def dump(self, filename: str = None) -> None: @profiling def dump_yaml(self, filename: str = None) -> None: + """ + Serialize the object to a yaml file + :param filename: file path of the yaml file, if not given then `self.dump_yaml_path` is used + """ f = filename or self.yaml_full_path if not f: f = tempfile.NamedTemporaryFile('w', delete=False, dir=os.environ.get('GNES_VOLUME', None)).name @@ -252,6 +280,9 @@ def load(filename: str = None) -> T: return pickle.load(fp) def close(self): + """ + Release the resources as model is destroyed + """ pass def __enter__(self): diff --git a/gnes/indexer/base.py b/gnes/indexer/base.py index e5818552..c08c0b93 100644 --- a/gnes/indexer/base.py +++ b/gnes/indexer/base.py @@ -41,9 +41,6 @@ def add(self, keys: List[Tuple[int, int]], vectors: np.ndarray, weights: List[fl def query(self, keys: np.ndarray, top_k: int, *args, **kwargs) -> List[List[Tuple]]: pass - def normalize_score(self, *args, **kwargs): - pass - class BaseTextIndexer(BaseIndexer): @@ -53,9 +50,6 @@ def add(self, keys: List[int], docs: Any, weights: List[float], *args, **kwargs) def query(self, keys: List[int], *args, **kwargs) -> List[Any]: pass - def normalize_score(self, *args, **kwargs): - pass - class BaseKeyIndexer(BaseIndexer): @@ -65,9 +59,6 @@ def add(self, keys: List[Tuple[int, int]], weights: List[float], *args, **kwargs def query(self, keys: List[int], *args, **kwargs) -> List[Tuple[int, int, float]]: pass - def normalize_score(self, *args, **kwargs): - pass - class JointIndexer(CompositionalTrainableBase): diff --git a/gnes/router/base.py b/gnes/router/base.py index 7fbb56e5..cf2f8f3e 100644 --- a/gnes/router/base.py +++ b/gnes/router/base.py @@ -21,7 +21,17 @@ class BaseRouter(TrainableBase): + """ Base class for the router. Inherit from this class to create a new router. + + Router forwards messages between services. Essentially, it receives a 'gnes_pb2.Message' + and call `apply()` method on it. + """ def apply(self, msg: 'gnes_pb2.Message', *args, **kwargs): + """ + Modify the incoming message + + :param msg: incoming message + """ pass @@ -32,6 +42,12 @@ def apply(self, msg: 'gnes_pb2.Message', *args, **kwargs) -> Generator: class BaseReduceRouter(BaseRouter): def apply(self, msg: 'gnes_pb2.Message', accum_msgs: List['gnes_pb2.Message'], *args, **kwargs) -> None: + """ + Modify the current message based on accumulated messages + + :param msg: the current message + :param accum_msgs: accumulated messages + """ merge_routes(msg, accum_msgs) if len(msg.envelope.num_part) > 1: msg.envelope.num_part.pop()