From 043e498e013842c869546fe856cacd50044e4b9f Mon Sep 17 00:00:00 2001 From: "yingda.chen" Date: Wed, 25 May 2022 12:15:38 +0800 Subject: [PATCH] refactor doc build and fix some typos Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/8819462 --- LICENSE | 4 ++-- docs/README.md | 16 +++++----------- docs/source/conf.py | 2 +- docs/source/tutorials/pipeline.md | 2 +- maas_lib/models/base.py | 2 +- maas_lib/models/builder.py | 1 - .../models/nlp/sequence_classification_model.py | 2 +- maas_lib/pipelines/base.py | 4 ++-- .../nlp/sequence_classification_pipeline.py | 4 ++-- maas_lib/preprocessors/builder.py | 2 +- maas_lib/utils/constant.py | 4 ++-- maas_lib/utils/registry.py | 2 +- setup.py | 4 ++-- 13 files changed, 21 insertions(+), 28 deletions(-) diff --git a/LICENSE b/LICENSE index 6f676250..85ed3d3a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright 2022-2023 Alibaba PAI. All rights reserved. +Copyright 2022-2023 Alibaba MaaS. All rights reserved. Apache License Version 2.0, January 2004 @@ -188,7 +188,7 @@ Copyright 2022-2023 Alibaba PAI. All rights reserved. same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2020-2022 Alibaba PAI. + Copyright 2020-2022 Alibaba MaaS. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/docs/README.md b/docs/README.md index e8b71575..a051c6be 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,23 +1,17 @@ ## maintain docs -1. install requirements needed to build docs +1. build docs ```shell - # in maas_lib root dir - pip install requirements/docs.txt + # in root directory: + make docs ``` -2. build docs - ```shell - # in maas_lib/docs dir - bash build_docs.sh - ``` - -3. doc string format +2. doc string format We adopt the google style docstring format as the standard, please refer to the following documents. 1. Google Python style guide docstring [link](http://google.github.io/styleguide/pyguide.html#381-docstrings) 2. Google docstring example [link](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html) 3. sample:torch.nn.modules.conv [link](https://pytorch.org/docs/stable/_modules/torch/nn/modules/conv.html#Conv1d) - 4. load fucntion as an example: + 4. load function as an example: ```python def load(file, file_format=None, **kwargs): diff --git a/docs/source/conf.py b/docs/source/conf.py index 4a62bc1b..4cdcd956 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -19,7 +19,7 @@ sys.path.insert(0, os.path.abspath('../../')) # -- Project information ----------------------------------------------------- project = 'maas_lib' -copyright = '2022-2023, Alibaba PAI' +copyright = '2022-2023, Alibaba MaaS' author = 'maas_lib Authors' version_file = '../../maas_lib/version.py' diff --git a/docs/source/tutorials/pipeline.md b/docs/source/tutorials/pipeline.md index 738f50ed..18e100c8 100644 --- a/docs/source/tutorials/pipeline.md +++ b/docs/source/tutorials/pipeline.md @@ -63,7 +63,7 @@ pipeline函数支持传入实例化的预处理对象、模型对象,从而支 wget https://atp-modelzoo-sh.oss-cn-shanghai.aliyuncs.com/release/easynlp_modelzoo/alibaba-pai/bert-base-sst2.zip && unzip bert-base-sst2.zip ``` -创建tokenzier和模型 +创建tokenizer和模型 ```python >>> from maas_lib.models.nlp import SequenceClassificationModel >>> path = 'bert-base-sst2' diff --git a/maas_lib/models/base.py b/maas_lib/models/base.py index 92a9564d..2781f8a4 100644 --- a/maas_lib/models/base.py +++ b/maas_lib/models/base.py @@ -26,4 +26,4 @@ class Model(ABC): @classmethod def from_pretrained(cls, model_name_or_path: str, *model_args, **kwargs): - raise NotImplementedError('from_preatrained has not been implemented') + raise NotImplementedError('from_pretrained has not been implemented') diff --git a/maas_lib/models/builder.py b/maas_lib/models/builder.py index f88b9bb4..1e52d271 100644 --- a/maas_lib/models/builder.py +++ b/maas_lib/models/builder.py @@ -1,7 +1,6 @@ # Copyright (c) Alibaba, Inc. and its affiliates. from maas_lib.utils.config import ConfigDict -from maas_lib.utils.constant import Tasks from maas_lib.utils.registry import Registry, build_from_cfg MODELS = Registry('models') diff --git a/maas_lib/models/nlp/sequence_classification_model.py b/maas_lib/models/nlp/sequence_classification_model.py index db89e3bd..e7ec69f7 100644 --- a/maas_lib/models/nlp/sequence_classification_model.py +++ b/maas_lib/models/nlp/sequence_classification_model.py @@ -21,7 +21,7 @@ class SequenceClassificationModel(Model): **kwargs): # Model.__init__(self, model_dir, model_cls, first_sequence, *args, **kwargs) # Predictor.__init__(self, *args, **kwargs) - """initilize the sequence classification model from the `model_dir` path. + """initialize the sequence classification model from the `model_dir` path. Args: model_dir (str): the model path. diff --git a/maas_lib/pipelines/base.py b/maas_lib/pipelines/base.py index 64c331c6..1d804d1a 100644 --- a/maas_lib/pipelines/base.py +++ b/maas_lib/pipelines/base.py @@ -25,10 +25,10 @@ class Pipeline(ABC): def __call__(self, input: Union[Input, List[Input]], *args, **post_kwargs) -> Dict[str, Any]: - # moodel provider should leave it as it is + # model provider should leave it as it is # maas library developer will handle this function - # simple show case, need to support iterator type for both tensorflow and pytorch + # simple showcase, need to support iterator type for both tensorflow and pytorch # input_dict = self._handle_input(input) if isinstance(input, list): output = [] diff --git a/maas_lib/pipelines/nlp/sequence_classification_pipeline.py b/maas_lib/pipelines/nlp/sequence_classification_pipeline.py index cc896ab5..f3b20f95 100644 --- a/maas_lib/pipelines/nlp/sequence_classification_pipeline.py +++ b/maas_lib/pipelines/nlp/sequence_classification_pipeline.py @@ -39,13 +39,13 @@ class SequenceClassificationPipeline(Pipeline): } def postprocess(self, inputs: Dict[str, Any]) -> Dict[str, str]: - """process the predict results + """process the prediction results Args: inputs (Dict[str, Any]): _description_ Returns: - Dict[str, str]: the predict results + Dict[str, str]: the prediction results """ probs = inputs['probabilities'] diff --git a/maas_lib/preprocessors/builder.py b/maas_lib/preprocessors/builder.py index 9440710a..69421b5f 100644 --- a/maas_lib/preprocessors/builder.py +++ b/maas_lib/preprocessors/builder.py @@ -10,7 +10,7 @@ PREPROCESSORS = Registry('preprocessors') def build_preprocessor(cfg: ConfigDict, field_name: str = None, default_args: dict = None): - """ build preprocesor given model config dict + """ build preprocessor given model config dict Args: cfg (:obj:`ConfigDict`): config dict for model object. diff --git a/maas_lib/utils/constant.py b/maas_lib/utils/constant.py index e3bb8434..0b1a4e75 100644 --- a/maas_lib/utils/constant.py +++ b/maas_lib/utils/constant.py @@ -35,10 +35,10 @@ class Tasks(object): relation_extraction = 'relation-extraction' zero_shot = 'zero-shot' translation = 'translation' - token_classificatio = 'token-classification' + token_classification = 'token-classification' conversational = 'conversational' text_generation = 'text-generation' - table_question_answ = 'table-question-answering' + table_question_answering = 'table-question-answering' feature_extraction = 'feature-extraction' sentence_similarity = 'sentence-similarity' fill_mask = 'fill-mask ' diff --git a/maas_lib/utils/registry.py b/maas_lib/utils/registry.py index 6464f533..838e6f83 100644 --- a/maas_lib/utils/registry.py +++ b/maas_lib/utils/registry.py @@ -118,7 +118,7 @@ class Registry(object): module_cls=module_cls) return module_cls - # if module_cls is None, should return a dectorator function + # if module_cls is None, should return a decorator function def _register(module_cls): self._register_module( group_key=group_key, diff --git a/setup.py b/setup.py index 35178fdf..c9040815 100644 --- a/setup.py +++ b/setup.py @@ -162,10 +162,10 @@ if __name__ == '__main__': description='', long_description=readme(), long_description_content_type='text/markdown', - author='Alibaba PAI team', + author='Alibaba MaaS team', author_email='maas_lib@list.alibaba-inc.com', keywords='', - url='https://github.com/alibaba/EasyCV.git', + url='TBD', packages=find_packages(exclude=('configs', 'tools', 'demo')), include_package_data=True, classifiers=[