forked from AntonOsika/gpt-engineer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove
delete_existing
option; Introduce archive (AntonOsika#409)
* Remove `delete_existing` option; Introduce archive * Update gpt_engineer/db.py * Update gpt_engineer/main.py * Update gpt_engineer/main.py * Update gpt_engineer/steps.py * Update gpt_engineer/steps.py --------- Co-authored-by: Anton Osika <[email protected]>
- Loading branch information
1 parent
14ae0e7
commit 60e0a7e
Showing
7 changed files
with
79 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import datetime | ||
import os | ||
|
||
from unittest.mock import MagicMock | ||
|
||
from gpt_engineer.db import DB, DBs | ||
from gpt_engineer.steps import archive | ||
|
||
|
||
def freeze_at(monkeypatch, time): | ||
datetime_mock = MagicMock(wraps=datetime.datetime) | ||
datetime_mock.now.return_value = time | ||
monkeypatch.setattr(datetime, "datetime", datetime_mock) | ||
|
||
|
||
def setup_dbs(tmp_path, dir_names): | ||
directories = [tmp_path / name for name in dir_names] | ||
|
||
# Create DB objects | ||
dbs = [DB(dir) for dir in directories] | ||
|
||
# Create DBs instance | ||
return DBs(*dbs) | ||
|
||
|
||
def test_archive(tmp_path, monkeypatch): | ||
dbs = setup_dbs( | ||
tmp_path, ["memory", "logs", "preprompts", "input", "workspace", "archive"] | ||
) | ||
freeze_at(monkeypatch, datetime.datetime(2020, 12, 25, 17, 5, 55)) | ||
archive(None, dbs) | ||
assert not os.path.exists(tmp_path / "memory") | ||
assert not os.path.exists(tmp_path / "workspace") | ||
assert os.path.isdir(tmp_path / "archive" / "20201225_170555") | ||
|
||
dbs = setup_dbs( | ||
tmp_path, ["memory", "logs", "preprompts", "input", "workspace", "archive"] | ||
) | ||
freeze_at(monkeypatch, datetime.datetime(2022, 8, 14, 8, 5, 12)) | ||
archive(None, dbs) | ||
assert not os.path.exists(tmp_path / "memory") | ||
assert not os.path.exists(tmp_path / "workspace") | ||
assert os.path.isdir(tmp_path / "archive" / "20201225_170555") | ||
assert os.path.isdir(tmp_path / "archive" / "20220814_080512") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters