From 7447af1699e76c889cc3b61da8df58942b8b6c3c Mon Sep 17 00:00:00 2001 From: Ryan Chan Date: Thu, 25 Apr 2024 13:10:51 +0000 Subject: [PATCH] adjust sleep for creating files --- tests/conftest.py | 55 +++-------------------------------------------- 1 file changed, 3 insertions(+), 52 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 275110c8..705c1ae1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -13,55 +13,6 @@ def change_test_dir(request: pytest.FixtureRequest, monkeypatch: pytest.MonkeyPa monkeypatch.chdir(request.fspath.dirname) -@pytest.fixture() -def temporary_utils_folder(tmp_path: Path): - """ - Creates a temporary folder structure for testing. - - Has the following structure: - tmp_path - ├── data/ - ├── dummy_data/ - ├── utils/ - └── first.jsonl - └── second.jsonl - └── third.jsonl - ├── experiment_pipeline/ - ├── input/ - └── first.jsonl - └── second.jsonl - ├── output/ - ├── media/ - ├── test.txt - └── test.jsonl - """ - # create a txt file in the folder - with open(Path(tmp_path / "test.txt"), "w") as f: - f.write("test line") - - # create utils folder which we use to test the sorting of files - utils_dir = Path(tmp_path / "utils").mkdir() - with open(Path(tmp_path / "utils" / "first.jsonl"), "w") as f: - f.write('{"prompt": "test prompt 1", "model": "test"}\n') - time.sleep(0.01) - with open(Path(tmp_path / "utils" / "second.jsonl"), "w") as f: - f.write('{"prompt": "test prompt 2", "model": "test"}\n') - time.sleep(0.01) - with open(Path(tmp_path / "utils" / "third.jsonl"), "w") as f: - f.write('{"prompt": "test prompt 3", "model": "test"}\n') - - # store current working directory - cwd = os.getcwd() - - # change to temporary directory - os.chdir(tmp_path) - - yield utils_dir - - # change back to original directory - os.chdir(cwd) - - @pytest.fixture() def temporary_data_folders(tmp_path: Path): """ @@ -100,10 +51,10 @@ def temporary_data_folders(tmp_path: Path): utils_dir = Path(tmp_path / "utils").mkdir() with open(Path(tmp_path / "utils" / "first.jsonl"), "w") as f: f.write('{"prompt": "test prompt 1", "model": "test"}\n') - time.sleep(0.001) + time.sleep(0.01) with open(Path(tmp_path / "utils" / "second.jsonl"), "w") as f: f.write('{"prompt": "test prompt 2", "model": "test"}\n') - time.sleep(0.001) + time.sleep(0.01) with open(Path(tmp_path / "utils" / "third.jsonl"), "w") as f: f.write('{"prompt": "test prompt 3", "model": "test"}\n') @@ -120,7 +71,7 @@ def temporary_data_folders(tmp_path: Path): f.write('{"prompt": "test prompt 1", "model": "test"}\n') f.write('{"prompt": "test prompt 2", "model": "test"}\n') f.write('{"prompt": "test prompt 3", "model": "test"}\n') - time.sleep(0.001) + time.sleep(0.01) with open( Path(tmp_path / "experiment_pipeline" / "input" / "second.jsonl"), "w" ) as f: