Skip to content

Commit

Permalink
refactor: refactor env var reading in docs/conf.py (#6043)
Browse files Browse the repository at this point in the history
  • Loading branch information
ai-naymul authored Sep 7, 2023
1 parent d20a5d8 commit 35b1067
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
11 changes: 8 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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()
Expand All @@ -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 = [
Expand Down Expand Up @@ -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 = [
Expand Down
5 changes: 2 additions & 3 deletions jina/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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

0 comments on commit 35b1067

Please sign in to comment.