From 25aa4097f8c1f3dd27ec60d1d8488a217c2a3f79 Mon Sep 17 00:00:00 2001 From: Andrew Ciambrone Date: Wed, 7 Apr 2021 15:46:00 -0600 Subject: [PATCH] refactor: Make having no sharding a explicit option (#14) * Make having no shard a explict configuration option Signed-off-by: Andrew Ciambrone * Upgrade the package version Signed-off-by: Andrew Ciambrone * Add unit test Signed-off-by: Andrew Ciambrone --- amundsen_gremlin/test_and_development_shard.py | 5 ++++- setup.py | 2 +- tests/unit/test_test_and_development_shard.py | 8 ++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/amundsen_gremlin/test_and_development_shard.py b/amundsen_gremlin/test_and_development_shard.py index 7bd0382..a8ab8ff 100644 --- a/amundsen_gremlin/test_and_development_shard.py +++ b/amundsen_gremlin/test_and_development_shard.py @@ -1,6 +1,7 @@ # Copyright Contributors to the Amundsen project. # SPDX-License-Identifier: Apache-2.0 +import distutils.util import os from threading import Lock from typing import Optional @@ -14,7 +15,9 @@ def _shard_default() -> Optional[str]: - if os.environ.get('CI'): + if distutils.util.strtobool(os.environ.get('IGNORE_NEPTUNE_SHARD', 'False')): + return None + elif os.environ.get('CI'): # TODO: support CI-specific env variables in config? # BUILD_PART_ID: identifies a part-build (doesn't change when you click rebuild, but also not shared across # builds) diff --git a/setup.py b/setup.py index 13f1c8b..74be0c7 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ setup( name='amundsen-gremlin', - version='0.0.7', + version='0.0.8', description='Gremlin code library for Amundsen', url='https://github.com/amundsen-io/amundsengremlin', maintainer='Amundsen TSC', diff --git a/tests/unit/test_test_and_development_shard.py b/tests/unit/test_test_and_development_shard.py index 03516dd..460f664 100644 --- a/tests/unit/test_test_and_development_shard.py +++ b/tests/unit/test_test_and_development_shard.py @@ -69,6 +69,14 @@ def test_shard_default_environment_production(self) -> None: actual = _shard_default() self.assertIsNone(actual) + def test_shard_default_environment_ignoring_shard(self) -> None: + with mock.patch.dict(os.environ): + os.environ.pop('CI', None) + os.environ.pop('BUILD_PART_ID', None) + os.environ['IGNORE_NEPTUNE_SHARD'] = 'True' + actual = _shard_default() + self.assertIsNone(actual) + def test_shard_default_environment_staging(self) -> None: with mock.patch.dict(os.environ): os.environ.pop('CI', None)