/ tests / test_skinny_client_omits_sql_libs.py
test_skinny_client_omits_sql_libs.py
 1  import os
 2  import sys
 3  
 4  import pytest
 5  
 6  
 7  @pytest.mark.skipif(
 8      "MLFLOW_SKINNY" not in os.environ, reason="This test is only valid for the skinny client"
 9  )
10  def test_fails_import_sqlalchemy():
11      import mlflow  # noqa: F401
12  
13      with pytest.raises(ImportError, match="sqlalchemy"):
14          import sqlalchemy  # noqa: F401
15  
16  
17  @pytest.mark.skipif(
18      "MLFLOW_SKINNY" not in os.environ, reason="This test is only valid for the skinny client"
19  )
20  def test_skinny_client_without_importing_sqlalchemy() -> None:
21      from mlflow.tracking.client import MlflowClient
22  
23      client = MlflowClient(
24          tracking_uri="databricks",
25          registry_uri="databricks",
26      )
27      client._tracking_client.store
28      client._get_registry_client().store
29      assert "sqlalchemy" not in sys.modules