38
38
WORKSPACE_PATH_PLACEHOLDER ,
39
39
DBGymWorkspace ,
40
40
fully_resolve_path ,
41
- get_default_dbdata_parent_dpath ,
41
+ get_default_dbdata_parent_path ,
42
42
is_fully_resolved ,
43
43
is_ssd ,
44
44
)
@@ -68,30 +68,30 @@ def _postgres_build(dbgym_workspace: DBGymWorkspace, rebuild: bool) -> None:
68
68
"""
69
69
This function exists as a hook for integration tests.
70
70
"""
71
- expected_repo_symlink_dpath = get_repo_symlink_path (
71
+ expected_repo_symlink_path = get_repo_symlink_path (
72
72
dbgym_workspace .dbgym_workspace_path
73
73
)
74
- if not rebuild and expected_repo_symlink_dpath .exists ():
74
+ if not rebuild and expected_repo_symlink_path .exists ():
75
75
logging .getLogger (DBGYM_LOGGER_NAME ).info (
76
- f"Skipping _postgres_build: { expected_repo_symlink_dpath } "
76
+ f"Skipping _postgres_build: { expected_repo_symlink_path } "
77
77
)
78
78
return
79
79
80
80
logging .getLogger (DBGYM_LOGGER_NAME ).info (
81
- f"Setting up repo in { expected_repo_symlink_dpath } "
81
+ f"Setting up repo in { expected_repo_symlink_path } "
82
82
)
83
- repo_real_dpath = dbgym_workspace .dbgym_this_run_path / "repo"
84
- repo_real_dpath .mkdir (parents = False , exist_ok = False )
83
+ repo_real_path = dbgym_workspace .dbgym_this_run_path / "repo"
84
+ repo_real_path .mkdir (parents = False , exist_ok = False )
85
85
subprocess_run (
86
- f"./_build_repo.sh { repo_real_dpath } " ,
87
- cwd = dbgym_workspace .base_dbgym_repo_dpath / "dbms" / "postgres" ,
86
+ f"./_build_repo.sh { repo_real_path } " ,
87
+ cwd = dbgym_workspace .base_dbgym_repo_path / "dbms" / "postgres" ,
88
88
)
89
89
90
90
# only link at the end so that the link only ever points to a complete repo
91
- repo_symlink_dpath = dbgym_workspace .link_result (repo_real_dpath )
92
- assert expected_repo_symlink_dpath .samefile (repo_symlink_dpath )
91
+ repo_symlink_path = dbgym_workspace .link_result (repo_real_path )
92
+ assert expected_repo_symlink_path .samefile (repo_symlink_path )
93
93
logging .getLogger (DBGYM_LOGGER_NAME ).info (
94
- f"Set up repo in { expected_repo_symlink_dpath } "
94
+ f"Set up repo in { expected_repo_symlink_path } "
95
95
)
96
96
97
97
@@ -112,29 +112,29 @@ def _postgres_build(dbgym_workspace: DBGymWorkspace, rebuild: bool) -> None:
112
112
"--intended-dbdata-hardware" ,
113
113
type = click .Choice (["hdd" , "ssd" ]),
114
114
default = "hdd" ,
115
- help = f"The intended hardware dbdata should be on. Used as a sanity check for --dbdata-parent-dpath ." ,
115
+ help = f"The intended hardware dbdata should be on. Used as a sanity check for --dbdata-parent-path ." ,
116
116
)
117
117
@click .option (
118
- "--dbdata-parent-dpath " ,
118
+ "--dbdata-parent-path " ,
119
119
default = None ,
120
120
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_dpath (WORKSPACE_PATH_PLACEHOLDER )} ." ,
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 )} ." ,
122
122
)
123
123
def postgres_dbdata (
124
124
dbgym_workspace : DBGymWorkspace ,
125
125
benchmark_name : str ,
126
126
scale_factor : float ,
127
127
pgbin_path : Optional [Path ],
128
128
intended_dbdata_hardware : str ,
129
- dbdata_parent_dpath : Optional [Path ],
129
+ dbdata_parent_path : Optional [Path ],
130
130
) -> None :
131
131
_postgres_dbdata (
132
132
dbgym_workspace ,
133
133
benchmark_name ,
134
134
scale_factor ,
135
135
pgbin_path ,
136
136
intended_dbdata_hardware ,
137
- dbdata_parent_dpath ,
137
+ dbdata_parent_path ,
138
138
)
139
139
140
140
@@ -144,38 +144,38 @@ def _postgres_dbdata(
144
144
scale_factor : float ,
145
145
pgbin_path : Optional [Path ],
146
146
intended_dbdata_hardware : str ,
147
- dbdata_parent_dpath : Optional [Path ],
147
+ dbdata_parent_path : Optional [Path ],
148
148
) -> None :
149
149
"""
150
150
This function exists as a hook for integration tests.
151
151
"""
152
152
# Set args to defaults programmatically (do this before doing anything else in the function)
153
153
if pgbin_path is None :
154
154
pgbin_path = get_pgbin_symlink_path (dbgym_workspace .dbgym_workspace_path )
155
- if dbdata_parent_dpath is None :
156
- dbdata_parent_dpath = get_default_dbdata_parent_dpath (
155
+ if dbdata_parent_path is None :
156
+ dbdata_parent_path = get_default_dbdata_parent_path (
157
157
dbgym_workspace .dbgym_workspace_path
158
158
)
159
159
160
160
# Fully resolve all input paths.
161
161
pgbin_path = fully_resolve_path (pgbin_path )
162
- dbdata_parent_dpath = fully_resolve_path (dbdata_parent_dpath )
162
+ dbdata_parent_path = fully_resolve_path (dbdata_parent_path )
163
163
164
164
# Check assertions on args
165
165
if intended_dbdata_hardware == "hdd" :
166
166
assert not is_ssd (
167
- dbdata_parent_dpath
168
- ), f"Intended hardware is HDD but dbdata_parent_dpath ({ dbdata_parent_dpath } ) is an SSD"
167
+ dbdata_parent_path
168
+ ), f"Intended hardware is HDD but dbdata_parent_path ({ dbdata_parent_path } ) is an SSD"
169
169
elif intended_dbdata_hardware == "ssd" :
170
170
assert is_ssd (
171
- dbdata_parent_dpath
172
- ), f"Intended hardware is SSD but dbdata_parent_dpath ({ dbdata_parent_dpath } ) is an HDD"
171
+ dbdata_parent_path
172
+ ), f"Intended hardware is SSD but dbdata_parent_path ({ dbdata_parent_path } ) is an HDD"
173
173
else :
174
174
assert False
175
175
176
176
# Create dbdata
177
177
_create_dbdata (
178
- dbgym_workspace , benchmark_name , scale_factor , pgbin_path , dbdata_parent_dpath
178
+ dbgym_workspace , benchmark_name , scale_factor , pgbin_path , dbdata_parent_path
179
179
)
180
180
181
181
@@ -184,7 +184,7 @@ def _create_dbdata(
184
184
benchmark_name : str ,
185
185
scale_factor : float ,
186
186
pgbin_path : Path ,
187
- dbdata_parent_dpath : Path ,
187
+ dbdata_parent_path : Path ,
188
188
) -> None :
189
189
"""
190
190
If you change the code of _create_dbdata(), you should also delete the symlink so that the next time you run
@@ -202,13 +202,13 @@ def _create_dbdata(
202
202
return
203
203
204
204
# It's ok for the dbdata/ directory to be temporary. It just matters that the .tgz is saved in a safe place.
205
- dbdata_path = dbdata_parent_dpath / "dbdata_being_created"
206
- # We might be reusing the same dbdata_parent_dpath , so delete dbdata_path if it already exists
205
+ dbdata_path = dbdata_parent_path / "dbdata_being_created"
206
+ # We might be reusing the same dbdata_parent_path , so delete dbdata_path if it already exists
207
207
if dbdata_path .exists ():
208
208
shutil .rmtree (dbdata_path )
209
209
210
210
# Call initdb.
211
- # Save any script we call from pgbin_symlink_dpath because they are dependencies generated from another task run.
211
+ # Save any script we call from pgbin_symlink_path because they are dependencies generated from another task run.
212
212
dbgym_workspace .save_file (pgbin_path / "initdb" )
213
213
subprocess_run (f'./initdb -D "{ dbdata_path } "' , cwd = pgbin_path )
214
214
@@ -242,23 +242,23 @@ def _create_dbdata(
242
242
243
243
def _generic_dbdata_setup (dbgym_workspace : DBGymWorkspace ) -> None :
244
244
# get necessary vars
245
- pgbin_real_dpath = get_pgbin_symlink_path (
245
+ pgbin_real_path = get_pgbin_symlink_path (
246
246
dbgym_workspace .dbgym_workspace_path
247
247
).resolve ()
248
- assert pgbin_real_dpath .exists ()
248
+ assert pgbin_real_path .exists ()
249
249
dbgym_pguser = DBGYM_POSTGRES_USER
250
250
dbgym_pgpass = DBGYM_POSTGRES_PASS
251
251
pgport = DEFAULT_POSTGRES_PORT
252
252
253
253
# Create user
254
- dbgym_workspace .save_file (pgbin_real_dpath / "psql" )
254
+ dbgym_workspace .save_file (pgbin_real_path / "psql" )
255
255
subprocess_run (
256
256
f"./psql -c \" create user { dbgym_pguser } with superuser password '{ dbgym_pgpass } '\" { DEFAULT_POSTGRES_DBNAME } -p { pgport } -h localhost" ,
257
- cwd = pgbin_real_dpath ,
257
+ cwd = pgbin_real_path ,
258
258
)
259
259
subprocess_run (
260
260
f'./psql -c "grant pg_monitor to { dbgym_pguser } " { DEFAULT_POSTGRES_DBNAME } -p { pgport } -h localhost' ,
261
- cwd = pgbin_real_dpath ,
261
+ cwd = pgbin_real_path ,
262
262
)
263
263
264
264
# Load shared preload libraries
@@ -267,14 +267,14 @@ def _generic_dbdata_setup(dbgym_workspace: DBGymWorkspace) -> None:
267
267
# You have to use TO and you can't put single quotes around the libraries (https://postgrespro.com/list/thread-id/2580120)
268
268
# The method I wrote here works for both one library and multiple libraries
269
269
f'./psql -c "ALTER SYSTEM SET shared_preload_libraries TO { SHARED_PRELOAD_LIBRARIES } ;" { DEFAULT_POSTGRES_DBNAME } -p { pgport } -h localhost' ,
270
- cwd = pgbin_real_dpath ,
270
+ cwd = pgbin_real_path ,
271
271
)
272
272
273
273
# Create the dbgym database. Since one dbdata dir maps to one benchmark, all benchmarks will use the same database
274
274
# as opposed to using databases named after the benchmark.
275
275
subprocess_run (
276
276
f"./psql -c \" create database { DBGYM_POSTGRES_DBNAME } with owner = '{ dbgym_pguser } '\" { DEFAULT_POSTGRES_DBNAME } -p { pgport } -h localhost" ,
277
- cwd = pgbin_real_dpath ,
277
+ cwd = pgbin_real_path ,
278
278
)
279
279
280
280
0 commit comments