From 49364c9d74ddbe05afb99041d1070da05ee98653 Mon Sep 17 00:00:00 2001 From: Patrick Wang Date: Mon, 30 Dec 2024 13:37:50 -0500 Subject: [PATCH] num_times_created_this_run -> _num_times_created_this_run --- benchmark/tests/integtest_benchmark.py | 4 ++-- dbms/tests/integtest_dbms.py | 8 ++++---- env/tests/gymlib_integtest_util.py | 2 +- util/tests/unittest_workspace.py | 4 ++-- util/workspace.py | 8 ++++---- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/benchmark/tests/integtest_benchmark.py b/benchmark/tests/integtest_benchmark.py index f8b9d9f8..b4f4fdbc 100644 --- a/benchmark/tests/integtest_benchmark.py +++ b/benchmark/tests/integtest_benchmark.py @@ -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: diff --git a/dbms/tests/integtest_dbms.py b/dbms/tests/integtest_dbms.py index 466030bd..822e8aac 100644 --- a/dbms/tests/integtest_dbms.py +++ b/dbms/tests/integtest_dbms.py @@ -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: @@ -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 diff --git a/env/tests/gymlib_integtest_util.py b/env/tests/gymlib_integtest_util.py index cac69827..577d1ffc 100644 --- a/env/tests/gymlib_integtest_util.py +++ b/env/tests/gymlib_integtest_util.py @@ -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 diff --git a/util/tests/unittest_workspace.py b/util/tests/unittest_workspace.py index 3a0f11fc..0575b8b3 100644 --- a/util/tests/unittest_workspace.py +++ b/util/tests/unittest_workspace.py @@ -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: diff --git a/util/workspace.py b/util/workspace.py index 286488ec..28ed17fa 100644 --- a/util/workspace.py +++ b/util/workspace.py @@ -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"]