Skip to content

Commit

Permalink
num_times_created_this_run -> _num_times_created_this_run
Browse files Browse the repository at this point in the history
  • Loading branch information
wangpatrick57 committed Dec 30, 2024
1 parent b5fd76e commit 49364c9
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions benchmark/tests/integtest_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def setUp(self) -> None:
shutil.rmtree(workspace_path)

# Reset this to avoid the error of it being created twice.
# In real usage, the second run would be a different Python process so DBGymWorkspace.num_times_created_this_run would be 0.
DBGymWorkspace.num_times_created_this_run = 0
# In real usage, the second run would be a different Python process so DBGymWorkspace._num_times_created_this_run would be 0.
DBGymWorkspace._num_times_created_this_run = 0
self.workspace = DBGymWorkspace(workspace_path)

def tearDown(self) -> None:
Expand Down
8 changes: 4 additions & 4 deletions dbms/tests/integtest_dbms.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ def setUp(self) -> None:
shutil.rmtree(workspace_path)

# Reset this to avoid the error of it being created twice.
# In real usage, the second run would be a different Python process so DBGymWorkspace.num_times_created_this_run would be 0.
DBGymWorkspace.num_times_created_this_run = 0
# In real usage, the second run would be a different Python process so DBGymWorkspace._num_times_created_this_run would be 0.
DBGymWorkspace._num_times_created_this_run = 0
self.workspace = DBGymWorkspace(workspace_path)

def tearDown(self) -> None:
Expand All @@ -44,10 +44,10 @@ def test_postgres_dbdata(self) -> None:
# Make sure to recreate self.workspace so that each function call counts as its own run.
scale_factor = 0.01
_postgres_build(self.workspace, False)
DBGymWorkspace.num_times_created_this_run = 0
DBGymWorkspace._num_times_created_this_run = 0
self.workspace = DBGymWorkspace(self.workspace.dbgym_workspace_path)
_tpch_tables(self.workspace, scale_factor)
DBGymWorkspace.num_times_created_this_run = 0
DBGymWorkspace._num_times_created_this_run = 0
self.workspace = DBGymWorkspace(self.workspace.dbgym_workspace_path)

# Test
Expand Down
2 changes: 1 addition & 1 deletion env/tests/gymlib_integtest_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def set_up_workspace() -> None:
# However, it also can't be created more than once so we need to check `is None`.
if GymlibIntegtestManager.DBGYM_WORKSPACE is None:
# Reset this in case it had been created by a test *not* using GymlibIntegtestManager.set_up_workspace().
DBGymWorkspace.num_times_created_this_run = 0
DBGymWorkspace._num_times_created_this_run = 0
GymlibIntegtestManager.DBGYM_WORKSPACE = DBGymWorkspace(workspace_path)

@staticmethod
Expand Down
4 changes: 2 additions & 2 deletions util/tests/unittest_workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def tearDown(self) -> None:
# Importantly though, I don't have helper functions for the complex functions that I want to test (e.g. link_result and save_file).
def init_workspace_helper(self) -> None:
# Reset this to avoid the error of it being created twice.
# In real usage, the second run would be a different Python process so DBGymWorkspace.num_times_created_this_run would be 0.
DBGymWorkspace.num_times_created_this_run = 0
# In real usage, the second run would be a different Python process so DBGymWorkspace._num_times_created_this_run would be 0.
DBGymWorkspace._num_times_created_this_run = 0
self.workspace = DBGymWorkspace(self.workspace_path)

if self.expected_structure is None:
Expand Down
8 changes: 4 additions & 4 deletions util/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,15 @@ class DBGymWorkspace:
Global configurations that apply to all parts of DB-Gym
"""

num_times_created_this_run: int = 0
_num_times_created_this_run: int = 0

def __init__(self, dbgym_workspace_path: Path):
# The logic around dbgym_tmp_path assumes that DBGymWorkspace is only constructed once.
# This is because DBGymWorkspace creates a new run_*/ dir when it's initialized.
DBGymWorkspace.num_times_created_this_run += 1
DBGymWorkspace._num_times_created_this_run += 1
assert (
DBGymWorkspace.num_times_created_this_run == 1
), f"DBGymWorkspace has been created {DBGymWorkspace.num_times_created_this_run} times. It should only be created once per run."
DBGymWorkspace._num_times_created_this_run == 1
), f"DBGymWorkspace has been created {DBGymWorkspace._num_times_created_this_run} times. It should only be created once per run."

self.base_dbgym_repo_path = get_base_dbgym_repo_path()
self.cur_path_list: list[str] = ["dbgym"]
Expand Down

0 comments on commit 49364c9

Please sign in to comment.