diff --git a/.drone-cd.yml b/.drone-cd.yml index 57239288..99385a74 100644 --- a/.drone-cd.yml +++ b/.drone-cd.yml @@ -46,7 +46,7 @@ steps: from_secret: BOT_URL commands: - export MSG_LINK=$DRONE_REPO_LINK - - export MSG_TITLE="✅🎁 All images is successfully updated!" + - export MSG_TITLE="✅🎁 All images are successfully delivered!" - export MSG_CONTENT="" - ./shell/push-wechatwork.sh @@ -90,8 +90,8 @@ steps: BOT_URL: from_secret: BOT_URL commands: - - export MSG_LINK=${DRONE_BUILD_LINK} - - export MSG_TITLE="⌛🗳 Start to build docker image for new release \`$DRONE_SOURCE_BRANCH\`(\`${DRONE_BUILD_NUMBER}\`)" + - export MSG_LINK="https://github.com/gnes-ai/gnes/tree/${DRONE_TAG}" + - export MSG_TITLE="⌛🗳 Start to build docker image for new release \`$DRONE_SOURCE_BRANCH\`(\`${DRONE_TAG}\`)" - export MSG_CONTENT="click the link below to see the status" - ./shell/push-wechatwork.sh @@ -123,8 +123,8 @@ steps: BOT_URL: from_secret: BOT_URL commands: - - export MSG_LINK=$DRONE_REPO_LINK - - export MSG_TITLE="✅🎁 All images is successfully updated!" + - export MSG_LINK="https://github.com/gnes-ai/gnes/tree/${DRONE_TAG}" + - export MSG_TITLE="✅🎁 All images are successfully delivered!" - export MSG_CONTENT="" - ./shell/push-wechatwork.sh @@ -134,7 +134,7 @@ steps: BOT_URL: from_secret: BOT_URL commands: - - export MSG_LINK=$DRONE_BUILD_LINK + - export MSG_LINK="https://github.com/gnes-ai/gnes/tree/${DRONE_TAG}" - export MSG_TITLE="❌🎁 fail to build docker image!" - export MSG_CONTENT="please inform [$DRONE_COMMIT_AUTHOR]($DRONE_COMMIT_AUTHOR_EMAIL) to modify and fix [\`$DRONE_SOURCE_BRANCH\`]($DRONE_COMMIT_LINK). click the link below to see the details." - ./shell/push-wechatwork.sh diff --git a/.drone.yml b/.drone.yml index 72bbc2f4..d584077c 100644 --- a/.drone.yml +++ b/.drone.yml @@ -12,7 +12,7 @@ steps: BOT_URL: from_secret: BOT_URL commands: - - export MSG_LINK=${DRONE_BUILD_LINK} + - export MSG_LINK="https://github.com/gnes-ai/gnes/pull/${DRONE_PULL_REQUEST}" - export MSG_TITLE="⌛🏗 Start a CI pipeline \`$DRONE_SOURCE_BRANCH\`(\`${DRONE_BUILD_NUMBER}\`)" - export MSG_CONTENT="submit by [$DRONE_COMMIT_AUTHOR]($DRONE_COMMIT_AUTHOR_EMAIL), click the link below to see the status" - ./shell/push-wechatwork.sh @@ -65,7 +65,7 @@ steps: BOT_URL: from_secret: BOT_URL commands: - - export MSG_LINK=$DRONE_REPO_LINK + - export MSG_LINK="https://github.com/gnes-ai/gnes/pull/${DRONE_PULL_REQUEST}" - export MSG_TITLE="✅😃 All tests passed, good job! \`$DRONE_SOURCE_BRANCH\`(\`${DRONE_BUILD_NUMBER}\`)" - export MSG_CONTENT="the branch \`$DRONE_SOURCE_BRANCH\` submit by [$DRONE_COMMIT_AUTHOR]($DRONE_COMMIT_AUTHOR_EMAIL) is ready to merge to master" - ./shell/push-wechatwork.sh @@ -77,7 +77,7 @@ steps: BOT_URL: from_secret: BOT_URL commands: - - export MSG_LINK=$DRONE_BUILD_LINK + - export MSG_LINK="https://github.com/gnes-ai/gnes/pull/${DRONE_PULL_REQUEST}" - export MSG_TITLE="❌😥 CI pipeline \`$DRONE_SOURCE_BRANCH\`(\`${DRONE_BUILD_NUMBER}\`) is failed!" - export MSG_CONTENT="please inform [$DRONE_COMMIT_AUTHOR]($DRONE_COMMIT_AUTHOR_EMAIL) to modify and fix [\`$DRONE_SOURCE_BRANCH\`]($DRONE_COMMIT_LINK). click the link below to see the details." - ./shell/push-wechatwork.sh diff --git a/gnes/helper.py b/gnes/helper.py index 7ad03377..2a1033cb 100644 --- a/gnes/helper.py +++ b/gnes/helper.py @@ -504,13 +504,11 @@ def load_contrib_module(): if contrib: default_logger.info( - 'find a value in $GNES_CONTRIB_MODULE=%s, will try to load these modules from external' % contrib) - for c in contrib.split(','): - if ':' in c: - _name, _path = c.split(':') - m = PathImporter.add_modules(_path) - modules.append(m) - default_logger.info('successfully register %s class, you can now use it via yaml.' % m) + 'find a value in $GNES_CONTRIB_MODULE=%s, will load them as external modules' % contrib) + for p in contrib.split(','): + m = PathImporter.add_modules(p) + modules.append(m) + default_logger.info('successfully registered %s class, you can now use it via yaml.' % m) return modules @@ -528,7 +526,6 @@ def add_modules(*paths): if not os.path.exists(p): raise FileNotFoundError('cannot import module from %s, file not exist') module, spec = PathImporter._path_import(p) - sys.modules[spec.name] = module return module @staticmethod diff --git a/gnes/service/grpc.py b/gnes/service/grpc.py index a256405b..da2df279 100644 --- a/gnes/service/grpc.py +++ b/gnes/service/grpc.py @@ -30,10 +30,10 @@ def post_init(self): options=[('grpc.max_send_message_length', self.args.max_message_size * 1024 * 1024), ('grpc.max_receive_message_length', self.args.max_message_size * 1024 * 1024)]) - foo = PathImporter.add_modules(self.args.pb2_path, self.args.pb2_grpc_path) + m = PathImporter.add_modules(self.args.pb2_path, self.args.pb2_grpc_path) # build stub - self.stub = getattr(foo, self.args.stub_name)(self.channel) + self.stub = getattr(m, self.args.stub_name)(self.channel) def close(self): self.channel.close() diff --git a/tests/test_contrib_module.py b/tests/test_contrib_module.py index 5fb83de9..5b554a3c 100644 --- a/tests/test_contrib_module.py +++ b/tests/test_contrib_module.py @@ -3,7 +3,6 @@ dirname = os.path.dirname(__file__) module_path = os.path.join(dirname, 'contrib', 'dummy_contrib.py') -cls_name = 'FooContribEncoder' @unittest.SkipTest @@ -20,7 +19,7 @@ def tearDown(self): os.remove(self.dump_yaml_path) def test_load_contrib(self): - os.environ['GNES_CONTRIB_MODULE'] = '%s:%s' % (cls_name, module_path) + os.environ['GNES_CONTRIB_MODULE'] = module_path from gnes.encoder.base import BaseEncoder, BaseTextEncoder a = BaseEncoder.load_yaml(self.yaml_path) self.assertIsInstance(a, BaseTextEncoder) @@ -32,14 +31,14 @@ def test_load_contrib(self): self.assertEqual(b.encode([]), 'hello 531') def test_bad_name(self): - os.environ['GNES_CONTRIB_MODULE'] = '%s:%s' % ('blah', module_path) + os.environ['GNES_CONTRIB_MODULE'] = module_path try: from gnes.encoder.base import BaseEncoder except AttributeError: pass def test_bad_path(self): - os.environ['GNES_CONTRIB_MODULE'] = '%s:%s' % (cls_name, 'blah') + os.environ['GNES_CONTRIB_MODULE'] = 'blah' try: from gnes.encoder.base import BaseEncoder except AttributeError: