Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ jobs:
githubToken: ${{ github.token }}
install: |
apt-get update
apt-get install -y --no-install-recommends python3 python3-pip python3-venv cargo
apt-get install -y --no-install-recommends python3 python3-pip python3-venv python3-dev cargo
pip3 install -U pip
# Create and use a virtual environment to avoid the externally-managed-environment error
run: |
Expand Down Expand Up @@ -307,7 +307,7 @@ jobs:
image: alpine:latest
options: -v ${{ github.workspace }}:/io -w /io
run: |
apk add python3 py3-pip rust
apk add python3 python3-dev py3-pip rust
python -m venv .venv
.venv/bin/pip3 install dist/${{ env.PACKAGE_NAME }}-*.whl --force-reinstall
.venv/bin/${{ env.EXECUTABLE_NAME }} --help
Expand Down Expand Up @@ -348,7 +348,7 @@ jobs:
distro: alpine_latest
githubToken: ${{ github.token }}
install: |
apk add python3 py3-pip rust
apk add python3 python3-dev py3-pip rust
run: |
python -m venv .venv
.venv/bin/pip3 install dist/${{ env.PACKAGE_NAME }}-*.whl --force-reinstall
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
*.pyc
__pycache__


# may contain sensitive data
pytest.ini

#
# Artifacts from the Rust client generation process
#
Expand Down
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,7 @@ uv run pytest tests

If you need to get the latest OpenAPI SDK, you can run
`./scripts/generate-python-api-client.sh`.

## Testing
We use pytest to run tests. Copy `pytest.ini.template` to `pytest.ini` and
replace the values of environment variables
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@ classifiers = [
dependencies = [
"attrs==24.2.0",
"httpx==0.28.1",
"huggingface-hub>=0.34.3",
"ollama>=0.4.7",
"pyiceberg==0.9.0",
"python-dateutil==2.9.0.post0",
]

[project.optional-dependencies]
ai = ["huggingface-hub==0.30.2", "ollama==0.4.7"]
ai = ["huggingface-hub==0.34.3", "ollama==0.4.7"]
iceberg = ["polars==1.27.1", "pyarrow==19.0.1", "pyiceberg==0.9.0"]
all = ["tower[ai,iceberg]"]

Expand All @@ -65,5 +68,6 @@ dev = [
"openapi-python-client==0.24.3",
"pytest==8.3.5",
"pytest-httpx==0.35.0",
"pytest-env>=1.1.3",
"pyiceberg[sql-sqlite]==0.9.0",
]
12 changes: 12 additions & 0 deletions pytest.ini.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[pytest]
pythonpath = src
testpaths = tests
python_files = test_*.py
python_classes = Test*
python_functions = test_*
addopts = -v --tb=short
filterwarnings =
ignore::DeprecationWarning
ignore::PendingDeprecationWarning
env =
TOWER_INFERENCE_ROUTER_API_KEY=<hf_1234567890>
22 changes: 13 additions & 9 deletions src/tower/_context.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import os

class TowerContext:
def __init__(self, tower_url: str, environment: str, api_key: str = None, hugging_face_provider: str = None, hugging_face_api_key: str = None, jwt: str = None):
def __init__(self, tower_url: str, environment: str, api_key: str = None,
inference_router: str = None, inference_router_api_key: str = None,
inference_provider: str = None, jwt: str = None):
self.tower_url = tower_url
self.environment = environment
self.api_key = api_key
self.jwt = jwt
self.hugging_face_provider = hugging_face_provider
self.hugging_face_api_key = hugging_face_api_key
self.inference_router = inference_router
self.inference_router_api_key = inference_router_api_key
self.inference_provider = inference_provider

def is_local(self) -> bool:
if self.environment is None or self.environment == "":
Expand All @@ -24,17 +27,18 @@ def build(cls):
tower_api_key = os.getenv("TOWER_API_KEY")
tower_jwt = os.getenv("TOWER_JWT")

# NOTE: These are experimental, used only for our experimental Hugging
# Face integration for LLMs.
hugging_face_provider = os.getenv("TOWER_HUGGING_FACE_PROVIDER")
hugging_face_api_key = os.getenv("TOWER_HUGGING_FACE_API_KEY")
# Replaces the deprecated hugging_face_provider and hugging_face_api_key
inference_router = os.getenv("TOWER_INFERENCE_ROUTER")
inference_router_api_key = os.getenv("TOWER_INFERENCE_ROUTER_API_KEY")
inference_provider = os.getenv("TOWER_INFERENCE_PROVIDER")

return cls(
tower_url = tower_url,
environment = tower_environment,
api_key = tower_api_key,
hugging_face_provider = hugging_face_provider,
hugging_face_api_key = hugging_face_api_key,
inference_router = inference_router,
inference_router_api_key = inference_router_api_key,
inference_provider = inference_provider,
jwt = tower_jwt,
)

Loading