Skip to content

Commit

Permalink
rename and extend parallel cache files tests
Browse files Browse the repository at this point in the history
  • Loading branch information
IIaKyJIuH committed Jul 14, 2023
1 parent af89b59 commit f50918b
Showing 1 changed file with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def get_unused_pid() -> int:
return -1


def test_parallel_cache_files():
def test_prev_cache_parallel_deletion():
# all files cache files in test dir must be removed
# if `cache_dir` api param wasn't specified explicitly
unused_test_pid = get_unused_pid()
Expand All @@ -27,10 +27,12 @@ def test_parallel_cache_files():
test_file_2 = Path(default_fedot_data_dir(), f'cache_{unused_test_pid}.preprocessors_db')
test_file_2.touch()

common_params = dict(timeout=0.1, with_tuning=False)

tasks = [
delayed(run_regression_example)(with_tuning=False),
delayed(run_classification_example)(timeout=1., with_tuning=False),
delayed(run_ts_forecasting_example)(dataset='beer', horizon=10, timeout=1., with_tuning=False),
delayed(run_regression_example)(**common_params, preset='fast_train'),
delayed(run_classification_example)(**common_params),
delayed(run_ts_forecasting_example)(**common_params, dataset='beer', horizon=10),
]

cpus = cpu_count()
Expand All @@ -41,3 +43,24 @@ def test_parallel_cache_files():
assert False, 'DBs collides'
assert not test_file_1.exists()
assert not test_file_2.exists()


def test_parallel_cache_files():
# all files cache files in test dir must be removed
# if `cache_dir` api param wasn't specified explicitly
data_dir = Path(default_fedot_data_dir())
common_params = dict(timeout=0.1, with_tuning=False)

tasks = [
delayed(run_regression_example)(**common_params, preset='fast_train'),
delayed(run_classification_example)(**common_params),
delayed(run_ts_forecasting_example)(**common_params, dataset='beer', horizon=10),
]

cpus = cpu_count()
if cpus > 1:
try:
Parallel(n_jobs=cpus)(tasks)
except sqlite3.OperationalError:
assert False, 'DBs collides'
assert len(list(data_dir.glob('cache_*.*'))) == 6 # (operations_cache, preprocessing_cache) x 3

0 comments on commit f50918b

Please sign in to comment.