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

Integration test to ensuse project versions consistency #24

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
3 changes: 2 additions & 1 deletion ols/src/llms/providers/azure_openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def default_params(self) -> dict[str, Any]:
"""Construct and return structure with default LLM params."""
self.url = str(self.provider_config.url or self.url)
self.credentials = self.provider_config.credentials
api_version = self.provider_config.api_version
deployment_name = self.provider_config.deployment_name
azure_config = self.provider_config.azure_config

Expand All @@ -60,7 +61,7 @@ def default_params(self) -> dict[str, Any]:

default_parameters = {
"azure_endpoint": self.url,
"api_version": "2024-02-15-preview",
"api_version": api_version,
"deployment_name": deployment_name,
"model": self.model,
"model_kwargs": {
Expand Down
64 changes: 64 additions & 0 deletions tests/integration/test_project_version_consistency.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
"""Test that the project version is set consistently."""

import json
import tomllib

import semantic_version

from ols import config


def read_version_from_openapi():
"""Read version from OpenAPI.json file."""
# retrieve pre-generated OpenAPI schema
with open("docs/openapi.json") as fin:
pre_generated_schema = json.load(fin)
assert pre_generated_schema is not None
assert "info" in pre_generated_schema, "node 'info' not found in openapi.json"
info = pre_generated_schema["info"]
assert "version" in info, "node 'version' not found in 'info'"
return info["version"]


def read_version_from_pyproject():
"""Read version from pyproject.toml file."""
with open("pyproject.toml", "rb") as fin:
pyproject = tomllib.load(fin)
assert pyproject is not None
assert "project" in pyproject, "section [project] is missing in pyproject.toml"
project = pyproject["project"]
assert (
"version" in project
), "attribute 'version' is missing in section [project]"
return project["version"]


def read_version_from_app():
"""Read version from app object."""
config.reload_from_yaml_file("tests/config/config_for_integration_tests.yaml")
# app.main need to be imported after the configuration is read
from ols.app.main import app

assert app.version is not None
return app.version


def check_semantic_version(value):
"""Check that the value contains semantic version."""
# we just need to parse the value, that's all
semantic_version.Version(value)


def test_project_version_consistency():
"""Test than the project version is set consistently."""
openapi_version = read_version_from_openapi()
check_semantic_version(openapi_version)

project_version = read_version_from_pyproject()
check_semantic_version(project_version)

app_version = read_version_from_app()
check_semantic_version(app_version)

assert openapi_version == project_version
assert project_version == app_version
Loading