tahamajs's picture
download
raw
890 Bytes
import os
import pytest
from hydra.core.hydra_config import HydraConfig
from omegaconf import open_dict
from src.eval import evaluate
from src.train import train
@pytest.mark.slow
def test_train_eval(tmp_path, cfg_train, cfg_eval):
"""Train for 1 epoch with `train.py` and evaluate with `eval.py`"""
assert str(tmp_path) == cfg_train.paths.output_dir == cfg_eval.paths.output_dir
with open_dict(cfg_train):
cfg_train.trainer.max_epochs = 1
cfg_train.test = True
HydraConfig().set_config(cfg_train)
train_metric_dict, _ = train(cfg_train)
assert "last.ckpt" in os.listdir(tmp_path / "checkpoints")
with open_dict(cfg_eval):
cfg_eval.ckpt_path = str(tmp_path / "checkpoints" / "last.ckpt")
HydraConfig().set_config(cfg_eval)
test_metric_dict, _ = evaluate(cfg_eval)
assert test_metric_dict["test/2-Wasserstein"] > 0.0

Xet Storage Details

Size:
890 Bytes
·
Xet hash:
2f427e702319ba8e44e17c665e7f7de3017e910b8e2a4e598c0a4a91c8890715

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.