You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The test_execute_query_without_connection unit test fails if the system libraries for ODBC are not unavailable. This is an undocumented project requirement, with an ImportError being triggered if the native libraries cannot be found.
Expected Behavior
This test should be skipped if:
Not running under the CI environment;
The ODBC libraries are unavailable.
Alternatively, the project setup/requirements for local development should be updated. (Installing the ODBC libraries is not within the scope of hatch/pip: they are limited to installing Python libraries in the local virtual environment.)
Steps To Reproduce
On a macOS, verify that unixodbc is not installed.
Run the project tests:
HATCH_PYTHON=$(which python3.10) make clean dev test
The test_execute_query_without_connection test will fail with an ImportError because pyodbc cannot load the native library.
Relevant log output or Exception details
FAILED
tests/unit/connections/test_database_manager.py:47 (test_execute_query_without_connection)
def test_execute_query_without_connection():
> db_manager = DatabaseManager("mssql", sample_config)
tests/unit/connections/test_database_manager.py:49:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/databricks/labs/remorph/connections/database_manager.py:83: in __init__
self.connector = _create_connector(db_type, config)
src/databricks/labs/remorph/connections/database_manager.py:54: in _create_connector
return connector_class(config)
src/databricks/labs/remorph/connections/database_manager.py:28: in __init__
self.engine: Engine = self._connect()
src/databricks/labs/remorph/connections/database_manager.py:78: in _connect
return create_engine(connection_string)
<string>:2: in create_engine
???
.venv/lib/python3.10/site-packages/sqlalchemy/util/deprecations.py:281: in warned
return fn(*args, **kwargs) # type: ignore[no-any-return]
.venv/lib/python3.10/site-packages/sqlalchemy/engine/create.py:602: in create_engine
dbapi = dbapi_meth(**dbapi_args)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'sqlalchemy.dialects.mssql.pyodbc.MSDialect_pyodbc'>
@classmethod
def import_dbapi(cls) -> ModuleType:
>return __import__("pyodbc")
E ImportError: dlopen(/Users/**REDACTED**/dev/remorph-2/.venv/lib/python3.10/site-packages/pyodbc.cpython-310-darwin.so, 0x0002): Library not loaded: /usr/local/opt/unixodbc/lib/libodbc.2.dylib
E Referenced from: <13D74168-289F-36F6-8E48-C5C94BC764C8> /Users/**REDACTED**/dev/remorph-2/.venv/lib/python3.10/site-packages/pyodbc.cpython-310-darwin.so
E Reason: tried: '/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/usr/local/lib/libodbc.2.dylib' (no such file), '/usr/lib/libodbc.2.dylib' (no such file, not in dyld cache)
.venv/lib/python3.10/site-packages/sqlalchemy/connectors/pyodbc.py:60: ImportError
Operating System
macOS
Version
latest via Databricks CLI
The text was updated successfully, but these errors were encountered:
…ly if ODBC isn't available (#1550)
This PR resolves#1549 by marking the
`test_execute_query_without_connection` test as expected to fail, but
only locally and when ODBC isn't available.
There's currently an undocumented platform dependency that requires the
system to have native ODBC libraries installed for this test to pass.
This cannot be satisfied by Hatch, and rather than complicate setup
instructions, this PR marks the test as expected to fail, but only:
- If running locally; and
- The `pyodbc` module cannot be imported.
Note that under CI this test must pass, and currently does because the
CI environment sets up ODBC before running the tests.
Is there an existing issue for this?
Category of Bug / Issue
Other
Current Behavior
The
test_execute_query_without_connection
unit test fails if the system libraries for ODBC are not unavailable. This is an undocumented project requirement, with anImportError
being triggered if the native libraries cannot be found.Expected Behavior
This test should be skipped if:
Alternatively, the project setup/requirements for local development should be updated. (Installing the ODBC libraries is not within the scope of hatch/pip: they are limited to installing Python libraries in the local virtual environment.)
Steps To Reproduce
unixodbc
is not installed.test_execute_query_without_connection
test will fail with anImportError
becausepyodbc
cannot load the native library.Relevant log output or Exception details
Operating System
macOS
Version
latest via Databricks CLI
The text was updated successfully, but these errors were encountered: