Apply suggestions from code review

This commit is contained in:
Marek Wolan
2023-11-17 20:30:07 +00:00
parent c5b4ae45be
commit 9d0a98b221
3 changed files with 7 additions and 5 deletions

View File

@@ -74,10 +74,6 @@ class SB3Policy(PolicyABC, identifier="SB3"):
"""Load agent from a checkpoint."""
self._agent = self._agent_class.load(model_path, env=self.session.env)
def close(self) -> None:
"""Close the agent."""
pass
@classmethod
def from_config(cls, config: "TrainingOptions", session: "PrimaiteSession") -> "SB3Policy":
"""Create an agent from config file."""

View File

@@ -1,7 +1,7 @@
training_config:
rl_framework: SB3
rl_algorithm: PPO
se3ed: 333
se3ed: 333 # Purposeful typo to check that error is raised with bad configuration.
n_learn_steps: 2560
n_eval_episodes: 5

View File

@@ -1,3 +1,4 @@
import pydantic
import pytest
from tests.conftest import TempPrimaiteSession
@@ -5,6 +6,7 @@ from tests.conftest import TempPrimaiteSession
CFG_PATH = "tests/assets/configs/test_primaite_session.yaml"
TRAINING_ONLY_PATH = "tests/assets/configs/train_only_primaite_session.yaml"
EVAL_ONLY_PATH = "tests/assets/configs/eval_only_primaite_session.yaml"
MISCONFIGURED_PATH = "tests/assets/configs/bad_primaite_session.yaml"
class TestPrimaiteSession:
@@ -60,3 +62,7 @@ class TestPrimaiteSession:
session: TempPrimaiteSession
session.start_session()
# TODO: include checks that the model was loaded and that the eval-only session ran
def test_error_thrown_on_bad_configuration(self):
with pytest.raises(pydantic.ValidationError):
session = TempPrimaiteSession.from_config(MISCONFIGURED_PATH)