diff --git a/ibis-server/app/main.py b/ibis-server/app/main.py index d18d49176..af4ff6988 100644 --- a/ibis-server/app/main.py +++ b/ibis-server/app/main.py @@ -77,6 +77,7 @@ def custom_http_error_handler(request, exc: CustomHttpError): logger.opt(exception=exc).error("Request failed") return PlainTextResponse(str(exc), status_code=exc.status_code) + @app.exception_handler(NotImplementedError) def not_implemented_error_handler(request, exc: NotImplementedError): - return PlainTextResponse(str(exc), status_code=501) \ No newline at end of file + return PlainTextResponse(str(exc), status_code=501) diff --git a/ibis-server/app/model/data_source.py b/ibis-server/app/model/data_source.py index c4ef98220..ab31feb67 100644 --- a/ibis-server/app/model/data_source.py +++ b/ibis-server/app/model/data_source.py @@ -74,7 +74,9 @@ def get_connection(self, info: ConnectionInfo) -> BaseBackend: if hasattr(info, "connection_url"): return ibis.connect(info.connection_url.get_secret_value()) if self.name == "local_file": - raise NotImplementedError("Local file connection is not implemented to get ibis backend") + raise NotImplementedError( + "Local file connection is not implemented to get ibis backend" + ) return getattr(self, f"get_{self.name}_connection")(info) except KeyError: raise NotImplementedError(f"Unsupported data source: {self}") diff --git a/ibis-server/app/model/metadata/object_storage.py b/ibis-server/app/model/metadata/object_storage.py index f0ce6001a..403dc1b4b 100644 --- a/ibis-server/app/model/metadata/object_storage.py +++ b/ibis-server/app/model/metadata/object_storage.py @@ -1,6 +1,7 @@ +import os + import duckdb import opendal -import os from app.model import LocalFileConnectionInfo from app.model.metadata.dto import ( @@ -28,7 +29,7 @@ def get_table_list(self) -> list[Table]: table_name = os.path.basename(os.path.normpath(file.path)) else: # if the file is a file, use the file name as the table name - table_name = table_name = os.path.splitext(os.path.basename(file.path))[0] + table_name = os.path.splitext(os.path.basename(file.path))[0] unique_tables[table_name] = Table( name=table_name, description=None, diff --git a/ibis-server/tests/routers/v2/connector/test_local_file.py b/ibis-server/tests/routers/v2/connector/test_local_file.py index 4cb348017..cd11f2228 100644 --- a/ibis-server/tests/routers/v2/connector/test_local_file.py +++ b/ibis-server/tests/routers/v2/connector/test_local_file.py @@ -231,6 +231,7 @@ async def test_metadata_db_version(client, connection_info): assert response.status_code == 200 assert "Local File System" in response.text + async def test_unsupported_format(client): response = await client.post( url=f"{base_url}/metadata/tables",