Skip to content

Commit 835ffec

Browse files
committed
removed log.py
1 parent d0d38e0 commit 835ffec

File tree

10 files changed

+42
-210
lines changed

10 files changed

+42
-210
lines changed

benchmark/job/cli.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
)
1111

1212
from benchmark.constants import DEFAULT_SCALE_FACTOR
13-
from util.log import DBGYM_LOGGER_NAME
1413
from util.shell import subprocess_run
1514
from util.workspace import DBGymWorkspace, fully_resolve_path
1615

@@ -213,12 +212,10 @@ def _download_and_untar_dir(
213212
dbgym_workspace.dbgym_cur_symlinks_path / f"{untarred_dname}.link"
214213
)
215214
if expected_symlink_path.exists():
216-
logging.getLogger(DBGYM_LOGGER_NAME).info(
217-
f"Skipping download: {expected_symlink_path}"
218-
)
215+
logging.info(f"Skipping download: {expected_symlink_path}")
219216
return
220217

221-
logging.getLogger(DBGYM_LOGGER_NAME).info(f"Downloading: {expected_symlink_path}")
218+
logging.info(f"Downloading: {expected_symlink_path}")
222219
subprocess_run(f"curl -O {download_url}", cwd=dbgym_workspace.dbgym_this_run_path)
223220
untarred_data_path = dbgym_workspace.dbgym_this_run_path / untarred_dname
224221

@@ -243,7 +240,7 @@ def _download_and_untar_dir(
243240
)
244241
symlink_path = dbgym_workspace.link_result(untarred_data_path)
245242
assert expected_symlink_path.samefile(symlink_path)
246-
logging.getLogger(DBGYM_LOGGER_NAME).info(f"Downloaded: {expected_symlink_path}")
243+
logging.info(f"Downloaded: {expected_symlink_path}")
247244

248245

249246
def _generate_job_workload(
@@ -259,14 +256,10 @@ def _generate_job_workload(
259256
name_to_linkname(workload_name)
260257
)
261258
if expected_workload_symlink_path.exists():
262-
logging.getLogger(DBGYM_LOGGER_NAME).info(
263-
f"Skipping generation: {expected_workload_symlink_path}"
264-
)
259+
logging.info(f"Skipping generation: {expected_workload_symlink_path}")
265260
return
266261

267-
logging.getLogger(DBGYM_LOGGER_NAME).info(
268-
f"Generating: {expected_workload_symlink_path}"
269-
)
262+
logging.info(f"Generating: {expected_workload_symlink_path}")
270263
workload_path = dbgym_workspace.dbgym_this_run_path / workload_name
271264
workload_path.mkdir(parents=False, exist_ok=False)
272265

@@ -291,6 +284,4 @@ def _generate_job_workload(
291284

292285
workload_symlink_path = dbgym_workspace.link_result(workload_path)
293286
assert workload_symlink_path == expected_workload_symlink_path
294-
logging.getLogger(DBGYM_LOGGER_NAME).info(
295-
f"Generated: {expected_workload_symlink_path}"
296-
)
287+
logging.info(f"Generated: {expected_workload_symlink_path}")

benchmark/tpch/cli.py

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
from benchmark.constants import DEFAULT_SCALE_FACTOR
1515
from benchmark.tpch.constants import DEFAULT_TPCH_SEED, NUM_TPCH_QUERIES
16-
from util.log import DBGYM_LOGGER_NAME
1716
from util.shell import subprocess_run
1817
from util.workspace import DBGymWorkspace, fully_resolve_path, is_fully_resolved
1918

@@ -102,12 +101,10 @@ def _clone_tpch_kit(dbgym_workspace: DBGymWorkspace) -> None:
102101
name_to_linkname(TPCH_KIT_DIRNAME)
103102
)
104103
if expected_symlink_path.exists():
105-
logging.getLogger(DBGYM_LOGGER_NAME).info(
106-
f"Skipping clone: {expected_symlink_path}"
107-
)
104+
logging.info(f"Skipping clone: {expected_symlink_path}")
108105
return
109106

110-
logging.getLogger(DBGYM_LOGGER_NAME).info(f"Cloning: {expected_symlink_path}")
107+
logging.info(f"Cloning: {expected_symlink_path}")
111108
subprocess_run(
112109
f"./clone_tpch_kit.sh {dbgym_workspace.dbgym_this_run_path}",
113110
cwd=dbgym_workspace.base_dbgym_repo_path / "benchmark" / "tpch",
@@ -116,7 +113,7 @@ def _clone_tpch_kit(dbgym_workspace: DBGymWorkspace) -> None:
116113
dbgym_workspace.dbgym_this_run_path / TPCH_KIT_DIRNAME
117114
)
118115
assert expected_symlink_path.samefile(symlink_path)
119-
logging.getLogger(DBGYM_LOGGER_NAME).info(f"Cloned: {expected_symlink_path}")
116+
logging.info(f"Cloned: {expected_symlink_path}")
120117

121118

122119
def _generate_tpch_queries(
@@ -125,9 +122,7 @@ def _generate_tpch_queries(
125122
tpch_kit_path = dbgym_workspace.dbgym_cur_symlinks_path / (
126123
name_to_linkname(TPCH_KIT_DIRNAME)
127124
)
128-
logging.getLogger(DBGYM_LOGGER_NAME).info(
129-
f"Generating queries: [{seed_start}, {seed_end}]"
130-
)
125+
logging.info(f"Generating queries: [{seed_start}, {seed_end}]")
131126
for seed in range(seed_start, seed_end + 1):
132127
expected_queries_symlink_path = dbgym_workspace.dbgym_cur_symlinks_path / (
133128
name_to_linkname(_get_queries_dirname(seed, scale_factor))
@@ -149,9 +144,7 @@ def _generate_tpch_queries(
149144
)
150145
queries_symlink_path = dbgym_workspace.link_result(queries_parent_path)
151146
assert queries_symlink_path.samefile(expected_queries_symlink_path)
152-
logging.getLogger(DBGYM_LOGGER_NAME).info(
153-
f"Generated queries: [{seed_start}, {seed_end}]"
154-
)
147+
logging.info(f"Generated queries: [{seed_start}, {seed_end}]")
155148

156149

157150
def _generate_tpch_tables(dbgym_workspace: DBGymWorkspace, scale_factor: float) -> None:
@@ -162,14 +155,10 @@ def _generate_tpch_tables(dbgym_workspace: DBGymWorkspace, scale_factor: float)
162155
dbgym_workspace.dbgym_workspace_path, "tpch", scale_factor
163156
)
164157
if expected_tables_symlink_path.exists():
165-
logging.getLogger(DBGYM_LOGGER_NAME).info(
166-
f"Skipping generation: {expected_tables_symlink_path}"
167-
)
158+
logging.info(f"Skipping generation: {expected_tables_symlink_path}")
168159
return
169160

170-
logging.getLogger(DBGYM_LOGGER_NAME).info(
171-
f"Generating: {expected_tables_symlink_path}"
172-
)
161+
logging.info(f"Generating: {expected_tables_symlink_path}")
173162
subprocess_run(f"./dbgen -vf -s {scale_factor}", cwd=tpch_kit_path / "dbgen")
174163
tables_parent_path = dbgym_workspace.dbgym_this_run_path / get_tables_dirname(
175164
"tpch", scale_factor
@@ -179,9 +168,7 @@ def _generate_tpch_tables(dbgym_workspace: DBGymWorkspace, scale_factor: float)
179168

180169
tables_symlink_path = dbgym_workspace.link_result(tables_parent_path)
181170
assert tables_symlink_path.samefile(expected_tables_symlink_path)
182-
logging.getLogger(DBGYM_LOGGER_NAME).info(
183-
f"Generated: {expected_tables_symlink_path}"
184-
)
171+
logging.info(f"Generated: {expected_tables_symlink_path}")
185172

186173

187174
def _generate_tpch_workload(
@@ -200,14 +187,10 @@ def _generate_tpch_workload(
200187
),
201188
)
202189
if expected_workload_symlink_path.exists():
203-
logging.getLogger(DBGYM_LOGGER_NAME).info(
204-
f"Skipping generation: {expected_workload_symlink_path}"
205-
)
190+
logging.info(f"Skipping generation: {expected_workload_symlink_path}")
206191
return
207192

208-
logging.getLogger(DBGYM_LOGGER_NAME).info(
209-
f"Generating: {expected_workload_symlink_path}"
210-
)
193+
logging.info(f"Generating: {expected_workload_symlink_path}")
211194
workload_path = dbgym_workspace.dbgym_this_run_path / linkname_to_name(
212195
expected_workload_symlink_path.name
213196
)
@@ -238,6 +221,4 @@ def _generate_tpch_workload(
238221

239222
workload_symlink_path = dbgym_workspace.link_result(workload_path)
240223
assert workload_symlink_path == expected_workload_symlink_path
241-
logging.getLogger(DBGYM_LOGGER_NAME).info(
242-
f"Generated: {expected_workload_symlink_path}"
243-
)
224+
logging.info(f"Generated: {expected_workload_symlink_path}")

dbms/postgres/cli.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from benchmark.job.load_info import JobLoadInfo
2222
from benchmark.tpch.load_info import TpchLoadInfo
2323
from dbms.load_info_base_class import LoadInfoBaseClass
24-
from util.log import DBGYM_LOGGER_NAME
2524
from util.pg import (
2625
DBGYM_POSTGRES_DBNAME,
2726
DBGYM_POSTGRES_PASS,
@@ -72,14 +71,10 @@ def _postgres_build(dbgym_workspace: DBGymWorkspace, rebuild: bool) -> None:
7271
dbgym_workspace.dbgym_workspace_path
7372
)
7473
if not rebuild and expected_repo_symlink_path.exists():
75-
logging.getLogger(DBGYM_LOGGER_NAME).info(
76-
f"Skipping _postgres_build: {expected_repo_symlink_path}"
77-
)
74+
logging.info(f"Skipping _postgres_build: {expected_repo_symlink_path}")
7875
return
7976

80-
logging.getLogger(DBGYM_LOGGER_NAME).info(
81-
f"Setting up repo in {expected_repo_symlink_path}"
82-
)
77+
logging.info(f"Setting up repo in {expected_repo_symlink_path}")
8378
repo_real_path = dbgym_workspace.dbgym_this_run_path / "repo"
8479
repo_real_path.mkdir(parents=False, exist_ok=False)
8580
subprocess_run(
@@ -90,9 +85,7 @@ def _postgres_build(dbgym_workspace: DBGymWorkspace, rebuild: bool) -> None:
9085
# only link at the end so that the link only ever points to a complete repo
9186
repo_symlink_path = dbgym_workspace.link_result(repo_real_path)
9287
assert expected_repo_symlink_path.samefile(repo_symlink_path)
93-
logging.getLogger(DBGYM_LOGGER_NAME).info(
94-
f"Set up repo in {expected_repo_symlink_path}"
95-
)
88+
logging.info(f"Set up repo in {expected_repo_symlink_path}")
9689

9790

9891
@postgres_group.command(
@@ -198,9 +191,7 @@ def _create_dbdata(
198191
scale_factor,
199192
)
200193
if expected_dbdata_tgz_symlink_path.exists():
201-
logging.getLogger(DBGYM_LOGGER_NAME).info(
202-
f"Skipping _create_dbdata: {expected_dbdata_tgz_symlink_path}"
203-
)
194+
logging.info(f"Skipping _create_dbdata: {expected_dbdata_tgz_symlink_path}")
204195
return
205196

206197
# It's ok for the dbdata/ directory to be temporary. It just matters that the .tgz is saved in a safe place.
@@ -236,9 +227,7 @@ def _create_dbdata(
236227
# Only link at the end so that the link only ever points to a complete dbdata.
237228
dbdata_tgz_symlink_path = dbgym_workspace.link_result(dbdata_tgz_real_path)
238229
assert expected_dbdata_tgz_symlink_path.samefile(dbdata_tgz_symlink_path)
239-
logging.getLogger(DBGYM_LOGGER_NAME).info(
240-
f"Created dbdata in {dbdata_tgz_symlink_path}"
241-
)
230+
logging.info(f"Created dbdata in {dbdata_tgz_symlink_path}")
242231

243232

244233
def _generic_dbdata_setup(dbgym_workspace: DBGymWorkspace) -> None:

env/pg_conn.py

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from plumbum import local
2323
from psycopg.errors import ProgramLimitExceeded, QueryCanceled
2424

25-
from util.log import DBGYM_LOGGER_NAME
2625
from util.pg import DBGYM_POSTGRES_DBNAME, SHARED_PRELOAD_LIBRARIES, get_kv_connstr
2726
from util.workspace import DBGymWorkspace, parent_path_of_path
2827

@@ -177,14 +176,10 @@ def time_query(
177176
qid_runtime = float(c["Execution Time"]) * 1e3
178177
explain_data = c
179178

180-
logging.getLogger(DBGYM_LOGGER_NAME).debug(
181-
f"{query} evaluated in {qid_runtime/1e6}"
182-
)
179+
logging.debug(f"{query} evaluated in {qid_runtime/1e6}")
183180

184181
except QueryCanceled:
185-
logging.getLogger(DBGYM_LOGGER_NAME).debug(
186-
f"{query} exceeded evaluation timeout {timeout}"
187-
)
182+
logging.debug(f"{query} exceeded evaluation timeout {timeout}")
188183
qid_runtime = timeout * 1e6
189184
did_time_out = True
190185
except Exception as e:
@@ -203,14 +198,12 @@ def shutdown_postgres(self) -> None:
203198
return
204199

205200
while True:
206-
logging.getLogger(DBGYM_LOGGER_NAME).debug("Shutting down postgres...")
201+
logging.debug("Shutting down postgres...")
207202
_, stdout, stderr = local[f"{self.pgbin_path}/pg_ctl"][
208203
"stop", "--wait", "-t", "180", "-D", self.dbdata_path
209204
].run(retcode=None)
210205
time.sleep(1)
211-
logging.getLogger(DBGYM_LOGGER_NAME).debug(
212-
"Stop message: (%s, %s)", stdout, stderr
213-
)
206+
logging.debug("Stop message: (%s, %s)", stdout, stderr)
214207

215208
# Wait until pg_isready fails.
216209
retcode, _, _ = local[f"{self.pgbin_path}/pg_isready"][
@@ -303,12 +296,10 @@ def restart_with_changes(
303296
if retcode == 0 or pid_lock.exists():
304297
break
305298

306-
logging.getLogger(DBGYM_LOGGER_NAME).warning(
307-
"startup encountered: (%s, %s)", stdout, stderr
308-
)
299+
logging.warning("startup encountered: (%s, %s)", stdout, stderr)
309300
attempts += 1
310301
if attempts >= 5:
311-
logging.getLogger(DBGYM_LOGGER_NAME).error(
302+
logging.error(
312303
"Number of attempts to start postgres has exceeded limit."
313304
)
314305
assert False, "Could not start postgres."
@@ -318,9 +309,7 @@ def restart_with_changes(
318309
while True:
319310
if num_cycles >= CONNECT_TIMEOUT:
320311
# In this case, we've failed to start postgres.
321-
logging.getLogger(DBGYM_LOGGER_NAME).error(
322-
"Failed to start postgres before timeout..."
323-
)
312+
logging.error("Failed to start postgres before timeout...")
324313
return False
325314

326315
retcode, _, _ = local[f"{self.pgbin_path}/pg_isready"][
@@ -336,9 +325,7 @@ def restart_with_changes(
336325

337326
time.sleep(1)
338327
num_cycles += 1
339-
logging.getLogger(DBGYM_LOGGER_NAME).debug(
340-
"Waiting for postgres to bootup but it is not..."
341-
)
328+
logging.debug("Waiting for postgres to bootup but it is not...")
342329

343330
# Set up Boot if we're told to do so
344331
if self.boot_config_path is not None:
@@ -384,7 +371,7 @@ def _set_up_boot(
384371
"""
385372
# If any of these commands fail, they'll throw a Python exception
386373
# Thus, if none of them throw an exception, we know they passed
387-
logging.getLogger(DBGYM_LOGGER_NAME).debug("Setting up boot")
374+
logging.debug("Setting up boot")
388375
self.conn().execute("DROP EXTENSION IF EXISTS boot")
389376
self.conn().execute("CREATE EXTENSION IF NOT EXISTS boot")
390377
self.conn().execute("SELECT boot_connect()")
@@ -399,7 +386,7 @@ def _set_up_boot(
399386
self.conn().execute(f"SET boot.mu_hyp_opt={mu_hyp_opt}")
400387
self.conn().execute(f"SET boot.mu_hyp_time={mu_hyp_time}")
401388
self.conn().execute(f"SET boot.mu_hyp_stdev={mu_hyp_stdev}")
402-
logging.getLogger(DBGYM_LOGGER_NAME).debug("Set up boot")
389+
logging.debug("Set up boot")
403390

404391
def psql(self, sql: str) -> tuple[int, Optional[str]]:
405392
"""
@@ -425,7 +412,7 @@ def cancel_fn(conn_str: str) -> None:
425412
]
426413

427414
for row in r:
428-
logging.getLogger(DBGYM_LOGGER_NAME).info(f"Killing process {row[0]}")
415+
logging.info(f"Killing process {row[0]}")
429416
try:
430417
psutil.Process(row[0]).kill()
431418
except:
@@ -447,17 +434,17 @@ def cancel_fn(conn_str: str) -> None:
447434
except ProgramLimitExceeded as e:
448435
timer.cancel()
449436
self.disconnect()
450-
logging.getLogger(DBGYM_LOGGER_NAME).debug(f"Action error: {e}")
437+
logging.debug(f"Action error: {e}")
451438
return -1, str(e)
452439
except QueryCanceled as e:
453440
timer.cancel()
454441
self.disconnect()
455-
logging.getLogger(DBGYM_LOGGER_NAME).debug(f"Action error: {e}")
442+
logging.debug(f"Action error: {e}")
456443
return -1, f"canceling statement: {sql}."
457444
except psycopg.OperationalError as e:
458445
timer.cancel()
459446
self.disconnect()
460-
logging.getLogger(DBGYM_LOGGER_NAME).debug(f"Action error: {e}")
447+
logging.debug(f"Action error: {e}")
461448
return -1, f"operational error: {sql}."
462449
except psycopg.errors.UndefinedTable:
463450
timer.cancel()

manage/cli.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import click
88

9-
from util.log import DBGYM_LOGGER_NAME, DBGYM_OUTPUT_LOGGER_NAME
109
from util.workspace import (
1110
DBGymWorkspace,
1211
get_runs_path_from_workspace_path,
@@ -47,7 +46,7 @@ def manage_clean(dbgym_workspace: DBGymWorkspace, mode: str) -> None:
4746
@click.pass_obj
4847
def manage_count(dbgym_workspace: DBGymWorkspace) -> None:
4948
num_files = _count_files_in_workspace(dbgym_workspace)
50-
logging.getLogger(DBGYM_OUTPUT_LOGGER_NAME).info(
49+
print(
5150
f"The workspace ({dbgym_workspace.dbgym_workspace_path}) has {num_files} total files/dirs/symlinks."
5251
)
5352

@@ -186,10 +185,10 @@ def clean_workspace(
186185
ending_num_files = _count_files_in_workspace(dbgym_workspace)
187186

188187
if verbose:
189-
logging.getLogger(DBGYM_LOGGER_NAME).info(
188+
logging.info(
190189
f"Removed {starting_num_files - ending_num_files} out of {starting_num_files} files"
191190
)
192-
logging.getLogger(DBGYM_LOGGER_NAME).info(
191+
logging.info(
193192
f"Workspace went from {starting_num_files - ending_num_files} to {starting_num_files}"
194193
)
195194

0 commit comments

Comments
 (0)