From aa9fd82ea9598ee0f56edecccf3a7e2fc1b6e3cc Mon Sep 17 00:00:00 2001 From: Youhei Sakurai Date: Thu, 13 Jul 2023 17:27:04 +0900 Subject: [PATCH 1/2] Migrate to entry_points #551 --- eland/cli/__init__.py | 16 ++++++++++++++++ .../cli/eland_import_hub_model.py | 2 -- noxfile.py | 2 +- setup.py | 4 +++- 4 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 eland/cli/__init__.py rename bin/eland_import_hub_model => eland/cli/eland_import_hub_model.py (99%) diff --git a/eland/cli/__init__.py b/eland/cli/__init__.py new file mode 100644 index 00000000..2a87d183 --- /dev/null +++ b/eland/cli/__init__.py @@ -0,0 +1,16 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. diff --git a/bin/eland_import_hub_model b/eland/cli/eland_import_hub_model.py similarity index 99% rename from bin/eland_import_hub_model rename to eland/cli/eland_import_hub_model.py index 94ec4d0d..6ce14fe7 100755 --- a/bin/eland_import_hub_model +++ b/eland/cli/eland_import_hub_model.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python - # Licensed to Elasticsearch B.V. under one or more contributor # license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright diff --git a/noxfile.py b/noxfile.py index acd5b6a4..aa658b4b 100644 --- a/noxfile.py +++ b/noxfile.py @@ -22,7 +22,7 @@ import nox BASE_DIR = Path(__file__).parent -SOURCE_FILES = ("setup.py", "noxfile.py", "eland/", "docs/", "utils/", "tests/", "bin/") +SOURCE_FILES = ("setup.py", "noxfile.py", "eland/", "docs/", "utils/", "tests/") # Whenever type-hints are completed on a file it should # be added here so that this file will continue to be checked diff --git a/setup.py b/setup.py index ffb96c2d..feb37067 100644 --- a/setup.py +++ b/setup.py @@ -87,7 +87,9 @@ "matplotlib>=3.6", "numpy>=1.2.0,<1.24", ], - scripts=["bin/eland_import_hub_model"], + entry_points={ + "console_scripts": "eland_import_hub_model=eland.cli.eland_import_hub_model:main" + }, python_requires=">=3.8", package_data={"eland": ["py.typed"]}, include_package_data=True, From ea014b4ee6e5b4928a29ffa8f0956aeebbb75a55 Mon Sep 17 00:00:00 2001 From: Youhei Sakurai Date: Thu, 13 Jul 2023 17:46:31 +0900 Subject: [PATCH 2/2] Fix flake8 lint errors --- eland/cli/eland_import_hub_model.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/eland/cli/eland_import_hub_model.py b/eland/cli/eland_import_hub_model.py index 6ce14fe7..b763d35f 100755 --- a/eland/cli/eland_import_hub_model.py +++ b/eland/cli/eland_import_hub_model.py @@ -207,9 +207,9 @@ def main(): textwrap.dedent( f"""\ \033[31mFailed to run because module '{e.name}' is not available.\033[0m - + This script requires PyTorch extras to run. You can install these by running: - + \033[1m{sys.executable} -m pip install 'eland[pytorch]' \033[0m""" ) @@ -272,15 +272,15 @@ def main(): logger.info(f"Creating model with id '{ptm.model_id}'") ptm.put_config(config=config) - logger.info(f"Uploading model definition") + logger.info("Uploading model definition") ptm.put_model(model_path) - logger.info(f"Uploading model vocabulary") + logger.info("Uploading model vocabulary") ptm.put_vocab(vocab_path) # Start the deployed model if args.start: - logger.info(f"Starting model deployment") + logger.info("Starting model deployment") ptm.start() logger.info(f"Model successfully imported with id '{ptm.model_id}'")