Skip to content

Commit

Permalink
Skip if less than 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
aravind-segu committed Oct 4, 2024
1 parent b754004 commit ed97494
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions tests/test_open_ai_mixin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import sys

import pytest

from databricks.sdk.core import Config


Expand All @@ -14,19 +17,14 @@ def test_open_ai_client(monkeypatch):
assert client.api_key == "test_token"


@pytest.mark.skipif(sys.version_info < (3, 8), reason="Requires Python > 3.7")
def test_langchain_open_ai_client(monkeypatch):
from databricks.sdk import WorkspaceClient
print(sys.version_info)
print(sys.version_info <= (3,7))
if sys.version_info <= (3, 7):
with pytest.raises(ImportError):
w = WorkspaceClient(config=Config())
client = w.serving_endpoints.get_langchain_chat_open_ai_client("databricks-meta-llama-3-1-70b-instruct")
else:
monkeypatch.setenv('DATABRICKS_HOST', 'test_host')
monkeypatch.setenv('DATABRICKS_TOKEN', 'test_token')
w = WorkspaceClient(config=Config())
client = w.serving_endpoints.get_langchain_chat_open_ai_client("databricks-meta-llama-3-1-70b-instruct")

assert client.openai_api_base == "https://test_host/serving-endpoints"
assert client.model_name == "databricks-meta-llama-3-1-70b-instruct"

monkeypatch.setenv('DATABRICKS_HOST', 'test_host')
monkeypatch.setenv('DATABRICKS_TOKEN', 'test_token')
w = WorkspaceClient(config=Config())
client = w.serving_endpoints.get_langchain_chat_open_ai_client("databricks-meta-llama-3-1-70b-instruct")

assert client.openai_api_base == "https://test_host/serving-endpoints"
assert client.model_name == "databricks-meta-llama-3-1-70b-instruct"

0 comments on commit ed97494

Please sign in to comment.