tahamajs/DGM / PaperSLecturs /Generative_Codes /conditional-flow-matching /runner /tests /conftest.py
| import pyrootutils | |
| import pytest | |
| from hydra import compose, initialize | |
| from hydra.core.global_hydra import GlobalHydra | |
| from omegaconf import DictConfig, open_dict | |
| def cfg_train_global() -> DictConfig: | |
| with initialize(version_base="1.2", config_path="../configs"): | |
| cfg = compose(config_name="train.yaml", return_hydra_config=True, overrides=[]) | |
| # set defaults for all tests | |
| with open_dict(cfg): | |
| cfg.paths.root_dir = str(pyrootutils.find_root()) | |
| cfg.trainer.max_epochs = 1 | |
| cfg.trainer.limit_train_batches = 0.02 | |
| cfg.trainer.limit_val_batches = 0.2 | |
| cfg.trainer.limit_test_batches = 0.2 | |
| cfg.trainer.accelerator = "cpu" | |
| cfg.trainer.devices = 1 | |
| cfg.datamodule.num_workers = 0 | |
| cfg.datamodule.pin_memory = False | |
| cfg.extras.print_config = False | |
| cfg.extras.enforce_tags = False | |
| cfg.logger = None | |
| cfg.launcher = None | |
| return cfg | |
| def cfg_eval_global() -> DictConfig: | |
| with initialize(version_base="1.2", config_path="../configs"): | |
| cfg = compose(config_name="eval.yaml", return_hydra_config=True, overrides=["ckpt_path=."]) | |
| # set defaults for all tests | |
| with open_dict(cfg): | |
| cfg.paths.root_dir = str(pyrootutils.find_root()) | |
| cfg.trainer.max_epochs = 1 | |
| cfg.trainer.limit_test_batches = 0.2 | |
| cfg.trainer.accelerator = "cpu" | |
| cfg.trainer.devices = 1 | |
| cfg.datamodule.num_workers = 0 | |
| cfg.datamodule.pin_memory = False | |
| cfg.extras.print_config = False | |
| cfg.extras.enforce_tags = False | |
| cfg.logger = None | |
| return cfg | |
| # this is called by each test which uses `cfg_train` arg | |
| # each test generates its own temporary logging path | |
| def cfg_train(cfg_train_global, tmp_path) -> DictConfig: | |
| cfg = cfg_train_global.copy() | |
| with open_dict(cfg): | |
| cfg.paths.data_dir = str(tmp_path) | |
| cfg.paths.output_dir = str(tmp_path) | |
| cfg.paths.log_dir = str(tmp_path) | |
| yield cfg | |
| GlobalHydra.instance().clear() | |
| # this is called by each test which uses `cfg_eval` arg | |
| # each test generates its own temporary logging path | |
| def cfg_eval(cfg_eval_global, tmp_path) -> DictConfig: | |
| cfg = cfg_eval_global.copy() | |
| with open_dict(cfg): | |
| cfg.paths.data_dir = str(tmp_path) | |
| cfg.paths.output_dir = str(tmp_path) | |
| cfg.paths.log_dir = str(tmp_path) | |
| yield cfg | |
| GlobalHydra.instance().clear() | |
Xet Storage Details
- Size:
- 2.69 kB
- Xet hash:
- 541ce8b4079747220e41aa09c8920f38e0f6c780189d8fc6017eb0acd469a6a2
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.