Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade openai and move tests #34

Merged
merged 2 commits into from
Apr 3, 2024
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Builder
name: Addon Builder

# TODO: figure out a more wildcard-y way to do this
env:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Lint
name: Addon Lint

on:
push:
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/integration-k3d.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,5 @@ jobs:
run: |
wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash
- name: Test with pytest
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
pytest -v -s -c pytest.ini --deploy-mode=k3d --replay-mode=replay
working-directory: mindctrl-addon/tests
pytest -v -s -c tests/pytest.ini --deploy-mode=k3d --replay-mode=replay
5 changes: 1 addition & 4 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,5 @@ jobs:
run: |
ruff check .
- name: Test with pytest
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
pytest -v -s -c pytest.ini --deploy-mode=local --replay-mode=replay
working-directory: mindctrl-addon/tests
pytest -v -s -c tests/pytest.ini --deploy-mode=local --replay-mode=replay
70 changes: 0 additions & 70 deletions .github/workflows/k3s.yaml

This file was deleted.

8 changes: 4 additions & 4 deletions python/src/mindctrl/mlmodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def log_system_models(force_publish=False) -> list[RegisteredModel]:
if TIMERANGE_MODEL not in registry_models or force_publish:
log_model(
model="gpt-3.5-turbo-0125",
task=openai.ChatCompletion,
task=openai.chat.completions,
messages=[
{"role": "system", "content": QUERY_PROMPT},
{"role": "user", "content": "INPUT: {query}"},
Expand All @@ -85,7 +85,7 @@ def log_system_models(force_publish=False) -> list[RegisteredModel]:
if CHAT_MODEL not in registry_models or force_publish:
log_model(
model=CHAT_OAI_MODEL,
task=openai.ChatCompletion,
task=openai.chat.completions,
messages=[
{"role": "system", "content": SUMMARIZATION_PROMPT},
{
Expand All @@ -101,7 +101,7 @@ def log_system_models(force_publish=False) -> list[RegisteredModel]:
if SUMMARIZER_MODEL not in registry_models or force_publish:
log_model(
model=SUMMARIZER_OAI_MODEL,
task=openai.ChatCompletion,
task=openai.chat.completions,
messages=[
{"role": "system", "content": SUMMARIZATION_PROMPT},
{
Expand All @@ -121,7 +121,7 @@ def log_system_models(force_publish=False) -> list[RegisteredModel]:
if EMBEDDINGS_MODEL not in registry_models or force_publish:
log_model(
model="text-embedding-ada-002",
task=openai.Embedding,
task=openai.embeddings,
artifact_path="oai-embeddings",
registered_model_name=EMBEDDINGS_MODEL,
)
Expand Down
2 changes: 1 addition & 1 deletion services/multiserver/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ uvicorn[standard]<1
watchfiles<1
aiohttp<4
boto3<2,>=1.28.56
openai<1
openai
tiktoken
tenacity
# homeassistant>2023.11 # TODO: I need to switch to Arch from debian :(
Expand Down
17 changes: 0 additions & 17 deletions services/tracking/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,2 @@
# https://raw.githubusercontent.com/mlflow/mlflow/master/requirements/gateway-requirements.txt

mlflow[genai]~=2.11
pydantic<3,>=1.0
pydantic-settings~=2.2
fastapi<1
uvicorn[standard]<1
watchfiles<1
aiohttp<4
boto3<2,>=1.28.56
openai<1
tiktoken
tenacity
# homeassistant>2023.11 # TODO: I need to switch to Arch from debian :(
# https://aur.archlinux.org/packages/python-mlflow
azureml-mlflow
aiomqtt
pgvector
asyncpg
26 changes: 16 additions & 10 deletions mindctrl-addon/tests/conftest.py → tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
_logger = logging.getLogger(__name__)


REPO_ROOT_PATH = Path(__file__).parent.parent


class DeployMode(Enum):
LOCAL = "local"
K3D = "k3d"
Expand Down Expand Up @@ -64,7 +67,7 @@ def build_app(
source_path: Path,
):
tag = f"{k3d_registry_url}/{app}:latest" if k3d_registry_url else f"{app}:latest"
app_to_build = Path(__file__).parent.parent.parent / "services" / app
app_to_build = REPO_ROOT_PATH / "services" / app
assert app_to_build.exists(), f"Missing {app_to_build}"

_logger.info(f"Building {app_to_build} with tag {tag}")
Expand Down Expand Up @@ -237,16 +240,14 @@ async def deployment_server(
return

deployment_server_dir = tmp_path_factory.mktemp("deploymentserver")
original_deployment_server = (
Path(__file__).parent.parent.parent / "services/deployments"
)
original_deployment_server = REPO_ROOT_PATH / "services/deployments"
assert original_deployment_server.exists(), f"Missing {original_deployment_server}"

shutil.copytree(
original_deployment_server, deployment_server_dir, dirs_exist_ok=True
)

mindctrl_source = Path(__file__).parent.parent.parent / "python"
mindctrl_source = REPO_ROOT_PATH / "python"
_logger.info(f"Building deployment server with context: {deployment_server_dir}")

tag = build_app("deployments", None, mindctrl_source)
Expand Down Expand Up @@ -323,6 +324,8 @@ def hosting_settings(
m.setenv("EVENTS__EVENTS_TYPE", "mqtt")
m.setenv("EVENTS__BROKER", mqtt_host)
m.setenv("EVENTS__PORT", str(mqtt_port))
if replay_mode == ReplayMode.REPLAY:
m.setenv("OPENAI_API_KEY", "DUMMY")

# TODO: maybe just take a connection string as a setting instead of exploded
yield AppSettings(
Expand Down Expand Up @@ -359,7 +362,7 @@ def prepare_apps(

# Don't push until the registry is created later
if "postgres" not in app.name and "mosquitto" not in app.name:
mindctrl_source = Path(__file__).parent.parent.parent / "python"
mindctrl_source = REPO_ROOT_PATH / "python"
built_tags.append(build_app(app.stem, registry_url, mindctrl_source))

with open(app, "r") as f:
Expand Down Expand Up @@ -443,9 +446,11 @@ def k3d_server_url(
m.setenv("EVENTS__PORT", str(constants.MQTT_PORT))
m.setenv("EVENTS__USERNAME", constants.MQTT_USER)
m.setenv("EVENTS__PASSWORD", constants.MQTT_PASSWORD)
if replay_mode == ReplayMode.REPLAY:
m.setenv("OPENAI_API_KEY", "DUMMY")

target_deploy_folder = tmp_path_factory.mktemp("deploy-resolved")
deploy_folder = Path(__file__).parent.parent.parent / "services/deploy"
deploy_folder = REPO_ROOT_PATH / "services/deploy"
assert deploy_folder.exists(), (
f"Missing {deploy_folder}"
) # Life easier when I inevitably move stuff around
Expand All @@ -469,9 +474,7 @@ def k3d_server_url(
cluster.create_secret("events-password", "EVENTS__PASSWORD")

# TODO: Get rid of all this gross path assumptions all across the fixtures
deployment_server_content = (
Path(__file__).parent.parent.parent / "services/deployments"
)
deployment_server_content = REPO_ROOT_PATH / "services/deployments"
assert (
deployment_server_content.exists()
), f"Missing {deployment_server_content}"
Expand Down Expand Up @@ -554,6 +557,9 @@ def k3d_server_url(
except subprocess.TimeoutExpired as e:
_logger.error(f"Timeout waiting for readiness: {e}")
if not os.environ.get("CI", "false") == "true":
_logger.error(
"##################\nBREAKING TO PRESERVE CLUSTER\n####################"
)
breakpoint()

finally:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.