Skip to content

Commit f5c89e7

Browse files
committed
deleted more functions from workspace.py
1 parent e3ac705 commit f5c89e7

File tree

4 files changed

+8
-76
lines changed

4 files changed

+8
-76
lines changed

benchmark/tpch/cli.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import click
44
from gymlib.symlinks_paths import (
5+
get_scale_factor_string,
56
get_tables_dirname,
67
get_tables_symlink_path,
78
get_workload_suffix,
@@ -13,12 +14,7 @@
1314
from benchmark.tpch.constants import DEFAULT_TPCH_SEED, NUM_TPCH_QUERIES
1415
from util.log import DBGYM_LOGGER_NAME
1516
from util.shell import subprocess_run
16-
from util.workspace import (
17-
DBGymWorkspace,
18-
fully_resolve_path,
19-
get_scale_factor_string,
20-
is_fully_resolved,
21-
)
17+
from util.workspace import DBGymWorkspace, fully_resolve_path, is_fully_resolved
2218

2319
TPCH_KIT_DIRNAME = "tpch-kit"
2420

dbms/postgres/cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
WORKSPACE_PATH_PLACEHOLDER,
3939
DBGymWorkspace,
4040
fully_resolve_path,
41-
get_default_dbdata_parent_path,
41+
get_tmp_path_from_workspace_path,
4242
is_fully_resolved,
4343
is_ssd,
4444
)
@@ -118,7 +118,7 @@ def _postgres_build(dbgym_workspace: DBGymWorkspace, rebuild: bool) -> None:
118118
"--dbdata-parent-path",
119119
default=None,
120120
type=Path,
121-
help=f"The path to the parent directory of the dbdata which will be actively tuned. The default is {get_default_dbdata_parent_path(WORKSPACE_PATH_PLACEHOLDER)}.",
121+
help=f"The path to the parent directory of the dbdata which will be actively tuned. The default is {get_tmp_path_from_workspace_path(WORKSPACE_PATH_PLACEHOLDER)}.",
122122
)
123123
def postgres_dbdata(
124124
dbgym_workspace: DBGymWorkspace,
@@ -153,7 +153,7 @@ def _postgres_dbdata(
153153
if pgbin_path is None:
154154
pgbin_path = get_pgbin_symlink_path(dbgym_workspace.dbgym_workspace_path)
155155
if dbdata_parent_path is None:
156-
dbdata_parent_path = get_default_dbdata_parent_path(
156+
dbdata_parent_path = get_tmp_path_from_workspace_path(
157157
dbgym_workspace.dbgym_workspace_path
158158
)
159159

env/tests/gymlib_integtest_util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from util.workspace import (
1717
DBGymWorkspace,
1818
fully_resolve_path,
19-
get_default_dbdata_parent_path,
19+
get_tmp_path_from_workspace_path,
2020
get_workspace_path_from_config,
2121
)
2222

@@ -105,7 +105,7 @@ def get_default_metadata() -> TuningMetadata:
105105
),
106106
),
107107
dbdata_parent_path=fully_resolve_path(
108-
get_default_dbdata_parent_path(dbgym_workspace.dbgym_workspace_path),
108+
get_tmp_path_from_workspace_path(dbgym_workspace.dbgym_workspace_path),
109109
),
110110
pgbin_path=fully_resolve_path(
111111
get_pgbin_symlink_path(dbgym_workspace.dbgym_workspace_path),

util/workspace.py

Lines changed: 1 addition & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,10 @@
1111
from pathlib import Path
1212
from typing import IO, Any, Optional
1313

14-
import redis
1514
import yaml
1615

17-
from benchmark.tpch.constants import DEFAULT_TPCH_SEED
1816
from util.log import DBGYM_LOGGER_NAME
19-
from util.shell import subprocess_run
2017

21-
# Relative paths of different folders in the codebase
22-
DBMS_PATH = Path("dbms")
23-
POSTGRES_PATH = DBMS_PATH / "postgres"
24-
TUNE_PATH = Path("tune")
25-
26-
# Paths of different parts of the workspace
27-
# I made these Path objects even though they're not real paths just so they can work correctly with my other helper functions
2818
WORKSPACE_PATH_PLACEHOLDER = Path("[workspace]")
2919

3020

@@ -47,24 +37,7 @@ def get_latest_run_path_from_workspace_path(workspace_path: Path) -> Path:
4737

4838
# Paths of config files in the codebase. These are always relative paths.
4939
# The reason these can be relative paths instead of functions taking in codebase_path as input is because relative paths are relative to the codebase root
50-
DEFAULT_BOOT_CONFIG_PATH = POSTGRES_PATH / "default_boot_config.yaml"
51-
52-
53-
SCALE_FACTOR_PLACEHOLDER: str = "[scale_factor]"
54-
55-
56-
def get_scale_factor_string(scale_factor: float | str) -> str:
57-
if type(scale_factor) is str and scale_factor == SCALE_FACTOR_PLACEHOLDER:
58-
return scale_factor
59-
else:
60-
if float(int(scale_factor)) == scale_factor:
61-
return str(int(scale_factor))
62-
else:
63-
return str(scale_factor).replace(".", "point")
64-
65-
66-
def get_default_dbdata_parent_path(workspace_path: Path) -> Path:
67-
return get_tmp_path_from_workspace_path(workspace_path)
40+
DEFAULT_BOOT_CONFIG_PATH = Path("dbms") / "postgres" / "default_boot_config.yaml"
6841

6942

7043
class DBGymWorkspace:
@@ -508,43 +481,6 @@ def try_remove_file(path: Path) -> None:
508481
pass
509482

510483

511-
# TODO: move this stuff to shell.py
512-
def restart_ray(redis_port: int) -> None:
513-
"""
514-
Stop and start Ray.
515-
This is good to do between each stage to avoid bugs from carrying over across stages
516-
"""
517-
subprocess_run("ray stop -f")
518-
ncpu = os.cpu_count()
519-
# --disable-usage-stats avoids a Y/N prompt
520-
subprocess_run(
521-
f"OMP_NUM_THREADS={ncpu} ray start --head --port={redis_port} --num-cpus={ncpu} --disable-usage-stats"
522-
)
523-
524-
525-
def make_redis_started(port: int) -> None:
526-
"""
527-
Start Redis if it's not already started.
528-
Note that Ray uses Redis but does *not* use this function. It starts Redis on its own.
529-
One current use for this function to start/stop Redis for Boot.
530-
"""
531-
try:
532-
r = redis.Redis(port=port)
533-
r.ping()
534-
# This means Redis is running, so we do nothing
535-
do_start_redis = False
536-
except (redis.ConnectionError, redis.TimeoutError):
537-
# This means Redis is not running, so we start it
538-
do_start_redis = True
539-
540-
# I'm starting Redis outside of except so that errors in r.ping get propagated correctly
541-
if do_start_redis:
542-
subprocess_run(f"redis-server --port {port} --daemonize yes")
543-
# When you start Redis in daemon mode, it won't let you know if it's started, so we ping again to check
544-
r = redis.Redis(port=port)
545-
r.ping()
546-
547-
548484
def is_ssd(path: Path) -> bool:
549485
try:
550486
device = (

0 commit comments

Comments
 (0)