Skip to content

Commit

Permalink
fix: update custom models
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkleiven committed Aug 23, 2024
1 parent 5174380 commit 078b62c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 22 deletions.
23 changes: 4 additions & 19 deletions tests/t_utils/custom_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import tests.t_utils.common as t_common
from cimsparql.graphdb import GraphDBClient, ServiceConfig
from cimsparql.model import ModelConfig, get_federated_cim_model, get_single_client_model
from cimsparql.model import ModelConfig, get_federated_cim_model

logger = logging.getLogger()

Expand All @@ -14,27 +14,12 @@ def combined_graphdb_service() -> ServiceConfig:
return ServiceConfig(repo=repo, max_delay_seconds=1, token=os.getenv("GRAPHDB_TOKEN"))


@functools.lru_cache
def combined_model() -> t_common.ModelTest:
if os.getenv("CI") or os.getenv("GRAPHDB_TOKEN") is None:
return t_common.ModelTest(None, False, False)
service = combined_graphdb_service()
system_state_repo = f"repository:{service.repo},infer=false"
eq_repo = f"repository:{service.repo},infer=false"
model = None
try:
model = get_single_client_model(service, ModelConfig(system_state_repo, eq_repo))
except Exception:
logger.exception("Failed to get single client model")
return t_common.ModelTest(model, False, False)


@functools.lru_cache
def federated_model() -> t_common.ModelTest:
if os.getenv("CI") or os.getenv("GRAPHDB_TOKEN") is None:
return t_common.ModelTest(None, False, False)
eq_repo = os.getenv("GRAPHDB_EQ", "abot_222-2-1_2")
system_state_repo = os.getenv("GRAPHDB_STATE", "abot_20220825T1621Z")
eq_repo = os.getenv("GRAPHDB_EQ", "abot-eq-1")
system_state_repo = os.getenv("GRAPHDB_STATE", "abot-situations-1")
eq_client_cfg = ServiceConfig(eq_repo, max_delay_seconds=1)
tpsvssh_client_cfg = ServiceConfig(system_state_repo, max_delay_seconds=1)
eq_client = GraphDBClient(eq_client_cfg)
Expand All @@ -52,4 +37,4 @@ def federated_model() -> t_common.ModelTest:


def all_custom_models() -> list[t_common.ModelTest]:
return [combined_model(), federated_model()]
return [federated_model()]
2 changes: 1 addition & 1 deletion tests/test_full_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


def test_full_model_1():
model = t_custom.combined_model().model
model = t_custom.federated_model().model
if not model:
pytest.skip("Require access to GRAPPHDB")
full_model = model.full_model()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_graphdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ async def test_not_empty(test_model: t_common.ModelTest):

@pytest.fixture
def model() -> Model:
test_model = t_custom.combined_model()
test_model = t_custom.federated_model()
if not test_model.model:
pytest.skip("Require access to GraphDB")
return test_model.model
Expand Down
2 changes: 1 addition & 1 deletion tests/test_model_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ async def get_node_consistency_test_data(


async def collect_node_consistency_data() -> list[NodeConsistencyData]:
test_models = [t_custom.combined_model(), t_entsoe.micro_t1_nl()]
test_models = [t_custom.federated_model(), t_entsoe.micro_t1_nl()]
if any(m.model is None and m.must_run_in_ci and os.getenv("CI") for m in test_models):
pytest.fail("Model that must run in CI is None")
res = await asyncio.gather(*[get_node_consistency_test_data(m.model) for m in test_models])
Expand Down

0 comments on commit 078b62c

Please sign in to comment.