diff --git a/opendbt/client.py b/opendbt/client.py index c607c01..7b03a6b 100644 --- a/opendbt/client.py +++ b/opendbt/client.py @@ -26,6 +26,7 @@ dbt.adapters.factory.AdapterContainer.register_adapter = dbt17.register_adapter + class OpenDbtCli: @staticmethod diff --git a/opendbt/examples.py b/opendbt/examples.py index adc8eda..9cab46b 100644 --- a/opendbt/examples.py +++ b/opendbt/examples.py @@ -18,24 +18,25 @@ def submit_local_python_job(self, parsed_model: Dict, compiled_code: str): # NOTE this is local python execution so session is None model(dbt=dbtObj(None), session=None) """ - with tempfile.NamedTemporaryFile(suffix=f'__{model_unique_id}.py', delete=False) as fp: + with tempfile.NamedTemporaryFile(suffix=f'__{model_unique_id}.py', delete=True) as fp: fp.write(__py_code.encode('utf-8')) - fp.close() + fp.flush() print(f"Created temp py file {fp.name}") Utils.runcommand(command=['python', fp.name]) + fp.close() # NOTE! used for testing -class DuckDBAdapterV1Custom_before_dbt18(DuckDBAdapter): +class DuckDBAdapterTestingOnlyDbt17(DuckDBAdapter): def __init__(self, config) -> None: print(f"WARNING: Using User Provided DBT Adapter: {type(self).__module__}.{type(self).__name__}") super().__init__(config=config) - raise Exception("Custom user defined test adapter activated, exception") + raise Exception("Custom user defined test adapter activated, test exception") # NOTE! used for testing -class DuckDBAdapterV1Custom_afer_dbt18(DuckDBAdapter): +class DuckDBAdapterTestingOnlyDbt18(DuckDBAdapter): def __init__(self, config, mp_context: SpawnContext) -> None: print(f"WARNING: Using User Provided DBT Adapter: {type(self).__module__}.{type(self).__name__}") super().__init__(config=config, mp_context=mp_context) - raise Exception("Custom user defined test adapter activated, exception") + raise Exception("Custom user defined test adapter activated, test exception") diff --git a/setup.py b/setup.py index 25f7ede..0bf03b4 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ 'opendbt = opendbt:main', ], }, - version='0.3.0', + version='0.4.0', packages=find_packages(), author="Memiiso Organization", description='Python opendbt', diff --git a/tests/test_custom_adapter.py b/tests/test_custom_adapter.py index aa11bfd..66cca84 100644 --- a/tests/test_custom_adapter.py +++ b/tests/test_custom_adapter.py @@ -14,9 +14,9 @@ class TestOpenDbtProject(TestCase): def test_run_with_custom_adapter(self): if Version(DBT_VERSION.to_version_string(skip_matcher=True)) > Version("1.8.0"): - dbt_custom_adapter = 'opendbt.examples.DuckDBAdapterV1Custom_afer_dbt18' + dbt_custom_adapter = 'opendbt.examples.DuckDBAdapterTestingOnlyDbt18' else: - dbt_custom_adapter = 'opendbt.examples.DuckDBAdapterV1Custom_before_dbt18' + dbt_custom_adapter = 'opendbt.examples.DuckDBAdapterTestingOnlyDbt17' dp = OpenDbtProject(project_dir=self.DBTTEST_DIR, profiles_dir=self.DBTTEST_DIR, args=['--vars', f"{{'dbt_custom_adapter': '{dbt_custom_adapter}'}}"])