-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add --ephemeral flag option to knockoff run command and unit tests
- Loading branch information
Showing
17 changed files
with
493 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,4 +65,8 @@ target/ | |
.idea/ | ||
|
||
# pyenv | ||
.python-version | ||
.python-version | ||
|
||
# jupyter | ||
*.ipynb_checkpoints/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Copyright 2021-present, Nike, Inc. | ||
# All rights reserved. | ||
# | ||
# This source code is licensed under the Apache-2.0 license found in | ||
# the LICENSE file in the root directory of this source tree. | ||
|
||
|
||
from dependency_injector import containers, providers | ||
|
||
from knockoff.utilities.importlib_utils import resolve_package_name | ||
from knockoff.tempdb.db import TempDatabaseService | ||
from knockoff.tempdb.initialize_tables import SqlAlchemyInitTablesFunc | ||
|
||
|
||
class TempDBContainer(containers.DeclarativeContainer): | ||
config = providers.Configuration() | ||
|
||
setup_teardown = providers.Factory( | ||
resolve_package_name, | ||
config.tempdb.setup_teardown.package | ||
) | ||
|
||
base = providers.Factory( | ||
resolve_package_name, | ||
config.tempdb.initialize_tables.base.package | ||
) | ||
|
||
initialize_tables = providers.Factory( | ||
SqlAlchemyInitTablesFunc, | ||
base | ||
) | ||
|
||
temp_db = providers.Factory( | ||
TempDatabaseService, | ||
url=config.tempdb.url, | ||
setup_teardown=setup_teardown, | ||
initialize_tables=initialize_tables, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright 2021-present, Nike, Inc. | ||
# All rights reserved. | ||
# | ||
# This source code is licensed under the Apache-2.0 license found in | ||
# the LICENSE file in the root directory of this source tree. | ||
|
||
|
||
import inspect | ||
import sys | ||
|
||
from dependency_injector import containers | ||
from knockoff.utilities.importlib_utils import resolve_package_name | ||
|
||
|
||
def get_container(package_name, config_path=None): | ||
"""parses declarative container, loads optional config, wires and returns""" | ||
Container = resolve_package_name(package_name) | ||
_validate_container_class(Container, package_name) | ||
container = Container() | ||
container.init_resources() | ||
if config_path: | ||
container.config.from_yaml(config_path) | ||
container.wire(modules=[sys.modules[__name__]]) | ||
return container | ||
|
||
|
||
def _validate_container_class(cls, package_name): | ||
if not inspect.isclass(cls) or not issubclass(cls, containers.DeclarativeContainer): | ||
raise TypeError(f"{package_name} resolves to " | ||
f"{cls} instead of " | ||
f"a subclass of dependency_injector" | ||
f".containers.DeclarativeContainer") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright 2021-present, Nike, Inc. | ||
# All rights reserved. | ||
# | ||
# This source code is licensed under the Apache-2.0 license found in | ||
# the LICENSE file in the root directory of this source tree. | ||
|
||
|
||
database_service: | ||
url: postgresql://postgres@localhost:5432/postgres | ||
|
||
blueprint: | ||
plan: | ||
package: knockoff.sdk.blueprint:noplan | ||
|
||
tempdb: | ||
url: postgresql://postgres@localhost:5432/postgres | ||
setup_teardown: | ||
package: knockoff.tempdb.setup_teardown:postgres_setup_teardown | ||
initialize_tables: | ||
base: | ||
package: tests.knockoff.data_model:Base |
Oops, something went wrong.