-
Notifications
You must be signed in to change notification settings - Fork 6
/
test_scripts.py
67 lines (60 loc) · 3.01 KB
/
test_scripts.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from test._base import BaseTest
from RLA.easy_log.log_tools import DeleteLogTool, Filter
from RLA.easy_log.log_tools import ArchiveLogTool, ViewLogTool
from RLA.easy_log.tester import exp_manager
import os
class ScriptTest(BaseTest):
def test_delete_reg(self) -> None:
"""
test delete log filtered by regex. See rla_scripts/delete_expt.py
"""
self.remove_and_copy_data()
filter = Filter()
filter.config(type=Filter.ALL, timstep_bound=1)
dlt = DeleteLogTool(proj_root=self.TARGET_DATA_ROOT, task_table_name=self.TASK_NAME, regex='2022/03/01/21-13*', filter=filter)
log_found = dlt.delete_related_log(skip_ask=True)
assert log_found == 10
log_found = dlt.delete_related_log(skip_ask=True)
assert log_found == 0
def test_delete_reg_small_ts(self) -> None:
"""
test delete log filtered by regex and threshold of time-step. See rla_scripts/delete_expt.py
"""
self.remove_and_copy_data()
filter = Filter()
# none of the experiment satisfied timestep <=1
filter.config(type=Filter.SMALL_TIMESTEP, timstep_bound=1)
dlt = DeleteLogTool(proj_root=self.TARGET_DATA_ROOT, task_table_name=self.TASK_NAME, regex='2022/03/01/21-13*', filter=filter)
log_found = dlt.delete_small_timestep_log(skip_ask=True)
assert log_found == 0
# all the experiment satisfied timestep <=2000
filter.config(type=Filter.SMALL_TIMESTEP, timstep_bound=2000)
dlt = DeleteLogTool(proj_root=self.TARGET_DATA_ROOT, task_table_name='demo_task', regex='2022/03/01/21-13*', filter=filter)
log_found = dlt.delete_small_timestep_log(skip_ask=True)
assert log_found == 10
# nothing left
filter.config(type=Filter.SMALL_TIMESTEP, timstep_bound=2000)
dlt = DeleteLogTool(proj_root=self.TARGET_DATA_ROOT, task_table_name=self.TASK_NAME, regex='2022/03/01/21-13*', filter=filter)
log_found = dlt.delete_small_timestep_log(skip_ask=True)
assert log_found == 0
def test_archive(self) -> None:
"""
archive experiment log. See rla_scripts/archive_expt.py
"""
self.remove_and_copy_data()
# archive experiments.
dlt = ArchiveLogTool(proj_root=self.TARGET_DATA_ROOT, task_table_name=self.TASK_NAME, regex='2022/03/01/21-13*')
dlt.archive_log(skip_ask=True)
# remove the archived experiments.
filter = Filter()
filter.config(type=Filter.ALL, timstep_bound=1)
dlt = DeleteLogTool(proj_root=self.TARGET_DATA_ROOT + '/arc', regex='2022/03/01/21-13*', filter=filter, task_table_name=self.TASK_NAME)
log_found = dlt.delete_related_log(skip_ask=True)
assert log_found == 10
def test_view(self) -> None:
"""
view experiment log.See rla_scripts/view_expt.py
"""
self.remove_and_copy_data()
dlt = ViewLogTool(proj_root=self.TARGET_DATA_ROOT, task_table_name=self.TASK_NAME, regex='2022/03/01/21-13*')
dlt.view_log(skip_ask=True)