Skip to content

Commit

Permalink
adjust sleep for creating files
Browse files Browse the repository at this point in the history
  • Loading branch information
rchan26 committed Apr 25, 2024
1 parent 3c3ace4 commit 7447af1
Showing 1 changed file with 3 additions and 52 deletions.
55 changes: 3 additions & 52 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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')

Expand All @@ -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:
Expand Down

0 comments on commit 7447af1

Please sign in to comment.