#1386: remove unneeded configs + setting the seed globally + temp test
This commit is contained in:
0
tests/e2e_integration_tests/__init__.py
Normal file
0
tests/e2e_integration_tests/__init__.py
Normal file
21
tests/e2e_integration_tests/conftest.py
Normal file
21
tests/e2e_integration_tests/conftest.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import polars as pl
|
||||
|
||||
|
||||
def compare_transaction_file(output_a_file_path: str | Path, output_b_file_path: str | Path):
|
||||
"""Function used to check if contents of transaction files are the same."""
|
||||
# load output a file
|
||||
data_a = pl.read_csv(output_a_file_path)
|
||||
|
||||
# load output b file
|
||||
data_b = pl.read_csv(output_b_file_path)
|
||||
|
||||
# remove the time stamp column
|
||||
data_a = data_a.drop("Timestamp")
|
||||
data_b = data_b.drop("Timestamp")
|
||||
|
||||
# if the comparison is empty, both files are the same i.e. True
|
||||
return data_a.frame_equal(data_b)
|
||||
@@ -1,3 +1,57 @@
|
||||
def temp():
|
||||
"""TODO rewrite tests."""
|
||||
pass
|
||||
"""
|
||||
Seed tests.
|
||||
|
||||
These tests will train an agent.
|
||||
This agent is then loaded and evaluated twice,
|
||||
the 2 evaluation wuns should be the same.
|
||||
|
||||
This proves that the seed works.
|
||||
"""
|
||||
import time
|
||||
|
||||
from primaite.config.lay_down_config import dos_very_basic_config_path
|
||||
from primaite.primaite_session import PrimaiteSession
|
||||
from tests import TEST_CONFIG_ROOT
|
||||
|
||||
|
||||
def test_seeded_sessions():
|
||||
"""Test to see if seed works in multiple sessions."""
|
||||
# ppo training session
|
||||
ppo_train = PrimaiteSession(TEST_CONFIG_ROOT / "e2e/ppo_seeded_training_config.yaml", dos_very_basic_config_path())
|
||||
# train agent
|
||||
ppo_train.setup()
|
||||
ppo_train.learn()
|
||||
ppo_train.close()
|
||||
|
||||
# agent path to use for evaluation
|
||||
path_prefix = f"{ppo_train._training_config.agent_framework}_{ppo_train._training_config.agent_identifier}"
|
||||
agent_path = ppo_train.session_path / f"{path_prefix}_{ppo_train.timestamp_str}.zip"
|
||||
|
||||
ppo_session_1 = PrimaiteSession(
|
||||
TEST_CONFIG_ROOT / "e2e/ppo_seeded_training_config.yaml", dos_very_basic_config_path()
|
||||
)
|
||||
|
||||
# load trained agent
|
||||
ppo_session_1._training_config.agent_load_file = agent_path
|
||||
ppo_session_1.setup()
|
||||
time.sleep(1)
|
||||
|
||||
ppo_session_2 = PrimaiteSession(
|
||||
TEST_CONFIG_ROOT / "e2e/ppo_seeded_training_config.yaml", dos_very_basic_config_path()
|
||||
)
|
||||
|
||||
# load trained agent
|
||||
ppo_session_2._training_config.agent_load_file = agent_path
|
||||
ppo_session_2.setup()
|
||||
|
||||
# run evaluation
|
||||
ppo_session_1.evaluate()
|
||||
ppo_session_1.close()
|
||||
ppo_session_2.evaluate()
|
||||
ppo_session_2.close()
|
||||
|
||||
# compare output
|
||||
# assert compare_transaction_file(
|
||||
# ppo_session_1.evaluation_path / f"all_transactions_{ppo_session_1.timestamp_str}.csv",
|
||||
# ppo_session_2.evaluation_path / f"all_transactions_{ppo_session_2.timestamp_str}.csv"
|
||||
# ) is True
|
||||
|
||||
Reference in New Issue
Block a user