-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test to the scripts of RLA
BREAKING CHANGE: change the name of parameter from 'task' to 'task_table_name' in rla_scripts for better readability.
- Loading branch information
1 parent
3ae1cab
commit 5764414
Showing
12 changed files
with
128 additions
and
49 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
DATA_ROOT = '../example/simplest_code/' | ||
DATA_ROOT = '../example/simplest_code/' | ||
ARCHIVED_TABLE = 'archived' |
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
|
||
setup( | ||
name='RLA', | ||
version="0.5.1", | ||
version="0.5.2", | ||
description=( | ||
'RL assistant' | ||
), | ||
|
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,18 @@ | ||
import unittest | ||
import shutil | ||
import os | ||
|
||
class BaseTest(unittest.TestCase): | ||
""" | ||
Base test class. | ||
""" | ||
SOURCE_DATA_ROOT = './test_data_root' | ||
TARGET_DATA_ROOT = './target_data_root' | ||
TASK_NAME = 'demo_task' | ||
def remove_and_copy_data(self): | ||
""" | ||
reset the experiment data for test. | ||
""" | ||
if os.path.exists(self.TARGET_DATA_ROOT): | ||
shutil.rmtree(self.TARGET_DATA_ROOT) | ||
shutil.copytree(self.SOURCE_DATA_ROOT, self.TARGET_DATA_ROOT) |
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,54 @@ | ||
from test._base import BaseTest | ||
from RLA.easy_log.log_tools import DeleteLogTool, Filter | ||
from RLA.easy_log.log_tools import ArchiveLogTool | ||
|
||
class ScriptTest(BaseTest): | ||
|
||
def test_delete_reg(self) -> None: | ||
""" | ||
test delete log filtered by regex. | ||
""" | ||
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): | ||
""" | ||
test delete log filtered by regex and threshold of time-step. | ||
""" | ||
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): | ||
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*', | ||
archive_table_name='archived', remove=False) | ||
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, task_table_name='archived', regex='2022/03/01/21-13*', filter=filter) | ||
log_found = dlt.delete_related_log(skip_ask=True) | ||
assert log_found == 10 | ||
|