-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2c53804
commit 28d1387
Showing
8 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import pytest | ||
|
||
|
||
class BaseTest: | ||
@pytest.fixture | ||
def initdir(self, tmpdir): | ||
return tmpdir.chdir() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"workers": { | ||
"manager_ip": "localhost", | ||
"manager_port": 8000, | ||
"instances": [ | ||
{ | ||
"name": "worker1", | ||
"remote": true, | ||
"id": "1235" | ||
}, | ||
{ | ||
"name": "worker2", | ||
"id": "1234" | ||
} | ||
] | ||
}, | ||
"nodes": [ | ||
{ | ||
"registry_name": "MyCustomNode", | ||
"name": "node1", | ||
"kwargs": { | ||
"param1": 1, | ||
"param2": "abc" | ||
} | ||
}, | ||
"node2" | ||
], | ||
"adj": [ | ||
["node1", "node2"] | ||
], | ||
"manager_config": { | ||
"logdir": "/tmp/logs", | ||
"port": 8000 | ||
}, | ||
"mappings": { | ||
"worker1": ["node1"], | ||
"1234": ["node2"] | ||
}, | ||
"discover_nodes_from": ["my_module"] | ||
} |
Empty file.
56 changes: 56 additions & 0 deletions
56
chimerapy_orchestrator/tests/models/test_pipeline_config.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import json | ||
|
||
import pytest | ||
|
||
from chimerapy_orchestrator.models.pipeline_config import ( | ||
ChimeraPyPipelineConfig, | ||
) | ||
from chimerapy_orchestrator.tests.base_test import BaseTest | ||
from chimerapy_orchestrator.tests.utils import get_test_file_path | ||
|
||
|
||
class TestPipelineConfig(BaseTest): | ||
@pytest.fixture(scope="class") | ||
def dummy_pipeline_config(self) -> ChimeraPyPipelineConfig: | ||
with get_test_file_path("dummy_pipeline.json").open() as f: | ||
return ChimeraPyPipelineConfig.parse_obj(json.load(f)) | ||
|
||
def test_worker_config(self, dummy_pipeline_config): | ||
assert dummy_pipeline_config.workers.manager_ip == "localhost" | ||
assert dummy_pipeline_config.workers.manager_port == 8000 | ||
|
||
assert dummy_pipeline_config.workers.instances[0].remote | ||
assert dummy_pipeline_config.workers.instances[0].name == "worker1" | ||
assert dummy_pipeline_config.workers.instances[0].id == "1235" | ||
|
||
assert not dummy_pipeline_config.workers.instances[1].remote | ||
assert dummy_pipeline_config.workers.instances[1].name == "worker2" | ||
assert dummy_pipeline_config.workers.instances[1].id == "1234" | ||
|
||
assert len(dummy_pipeline_config.workers.instances) == 2 | ||
|
||
def test_nodes_config(self, dummy_pipeline_config): | ||
assert len(dummy_pipeline_config.nodes) == 2 | ||
assert dummy_pipeline_config.nodes[0].name == "node1" | ||
assert dummy_pipeline_config.nodes[0].registry_name == "MyCustomNode" | ||
assert dummy_pipeline_config.nodes[0].kwargs == { | ||
"param1": 1, | ||
"param2": "abc", | ||
} | ||
assert dummy_pipeline_config.nodes[1].name == "node2" | ||
assert dummy_pipeline_config.nodes[1].registry_name == "node2" | ||
assert dummy_pipeline_config.nodes[1].kwargs == {} | ||
|
||
def test_adj_config(self, dummy_pipeline_config): | ||
assert len(dummy_pipeline_config.adj) == 1 | ||
assert dummy_pipeline_config.adj[0] == ("node1", "node2") | ||
|
||
def test_mappings_config(self, dummy_pipeline_config): | ||
assert len(dummy_pipeline_config.mappings) == 2 | ||
assert dummy_pipeline_config.mappings["worker1"] == ["node1"] | ||
assert dummy_pipeline_config.mappings["1234"] == ["node2"] | ||
|
||
def test_manager_config(self, dummy_pipeline_config): | ||
manager = dummy_pipeline_config.manager_config | ||
assert manager.port == 8000 | ||
assert str(manager.logdir) == "/tmp/logs" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from pathlib import Path | ||
|
||
|
||
def get_test_file_path(file_name: str) -> Path: | ||
"""Get the path to a test file""" | ||
return Path(__file__).parent / "data" / file_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters