Skip to content

Commit

Permalink
refactor: Make having no sharding a explicit option (#14)
Browse files Browse the repository at this point in the history
* Make having no shard a explict configuration option

Signed-off-by: Andrew Ciambrone <andrjc4@vt.edu>

* Upgrade the package version

Signed-off-by: Andrew Ciambrone <andrjc4@vt.edu>

* Add unit test

Signed-off-by: Andrew Ciambrone <andrjc4@vt.edu>
  • Loading branch information
AndrewCiambrone authored Apr 7, 2021
1 parent 51e2c60 commit 25aa409
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 4 additions & 1 deletion amundsen_gremlin/test_and_development_shard.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/test_test_and_development_shard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 25aa409

Please sign in to comment.