From 35b10678a84e9e37552807842655dc6849254b95 Mon Sep 17 00:00:00 2001 From: Naymul Islam <68547750+ai-naymul@users.noreply.github.com> Date: Thu, 7 Sep 2023 22:40:17 +0600 Subject: [PATCH] refactor: refactor env var reading in docs/conf.py (#6043) --- docs/conf.py | 11 ++++++++--- jina/constants.py | 5 ++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index a9dd3ee0c7850..c0b3d86e09330 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -3,6 +3,10 @@ import sys from os import path + +# Centralize environment variables +JINA_VERSION = os.environ.get('JINA_VERSION', None) + sys.path.insert(0, path.abspath('..')) project = 'Jina' @@ -15,7 +19,7 @@ repo_dir = '../' try: - if 'JINA_VERSION' not in os.environ: + if not JINA_VERSION: pkg_name = 'jina' libinfo_py = path.join(repo_dir, pkg_name, '__init__.py') libinfo_content = open(libinfo_py, 'r', encoding='utf-8').readlines() @@ -24,12 +28,13 @@ ][0] exec(version_line) else: - __version__ = os.environ['JINA_VERSION'] + __version__ = JINA_VERSION except FileNotFoundError: __version__ = '0.0.0' version = __version__ release = __version__ +SPHINX_MULTIVERSION_VERSION = os.environ.get('SPHINX_MULTIVERSION_VERSION', version) templates_path = ['_templates'] exclude_patterns = [ @@ -168,7 +173,7 @@ ogp_description_length = 300 ogp_type = 'website' ogp_site_name = ( - f'Jina {os.environ.get("SPHINX_MULTIVERSION_VERSION", version)} Documentation' + f'Jina {SPHINX_MULTIVERSION_VERSION} Documentation' ) ogp_custom_meta_tags = [ diff --git a/jina/constants.py b/jina/constants.py index 4c3c2ad16693f..1ccc5d18ed43a 100644 --- a/jina/constants.py +++ b/jina/constants.py @@ -35,7 +35,7 @@ 'JINA_STREAMER_ARGS', ) -__default_host__ = _os.environ.get( +__default_host__ = _os.getenv( 'JINA_DEFAULT_HOST', '127.0.0.1' if __windows__ else '0.0.0.0' ) __docker_host__ = 'host.docker.internal' @@ -77,7 +77,6 @@ '__windows__', ] -__all__ = [_s for _s in dir() if not _s.startswith('_')] -__all__.extend(_names_with_underscore) +__all__ = [_s for _s in dir() if not _s.startswith('_')] + _names_with_underscore RAFT_TO_EXECUTOR_PORT = 100