Skip to content

Commit f4b72c1

Browse files
committed
Prevent failutes in get_configuration_values
1 parent 78c6d35 commit f4b72c1

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

python/target_selection/utils.py

+21-8
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313

1414
import click
1515
import pandas
16-
from peewee import SQL, DoesNotExist, fn
17-
16+
from peewee import SQL, DoesNotExist, ProgrammingError, fn
1817

1918
__all__ = [
2019
"Timer",
@@ -54,7 +53,9 @@ def elapsed(self):
5453
return time.time() - self.start
5554

5655

57-
def sql_apply_pm(ra_field, dec_field, pmra_field, pmdec_field, epoch_delta, is_pmra_cos=True):
56+
def sql_apply_pm(
57+
ra_field, dec_field, pmra_field, pmdec_field, epoch_delta, is_pmra_cos=True
58+
):
5859
"""Constructs a SQL expression for applying proper motions to RA/Dec.
5960
6061
Parameters
@@ -221,7 +222,12 @@ def set_config_parameter(database, parameter, new_value, reset=True, log=None):
221222

222223

223224
def remove_version(
224-
database, plan, schema="catalogdb", table="catalog", delete_version=True, vacuum=True
225+
database,
226+
plan,
227+
schema="catalogdb",
228+
table="catalog",
229+
delete_version=True,
230+
vacuum=True,
225231
):
226232
"""Removes all rows in ``table`` and ``table_to_`` that match a version."""
227233

@@ -279,10 +285,14 @@ def remove_version(
279285
print("Removed entry in 'version'.")
280286

281287

282-
def vacuum_table(database, table_name, vacuum=True, analyze=True, maintenance_work_mem="50GB"):
288+
def vacuum_table(
289+
database, table_name, vacuum=True, analyze=True, maintenance_work_mem="50GB"
290+
):
283291
"""Vacuums and analyses a table."""
284292

285-
statement = ("VACUUM " if vacuum else "") + ("ANALYZE " if analyze else "") + table_name
293+
statement = (
294+
("VACUUM " if vacuum else "") + ("ANALYZE " if analyze else "") + table_name
295+
)
286296

287297
with database.atomic():
288298
# Change isolation level to allow executing commands such as VACUUM.
@@ -333,8 +343,11 @@ def get_configuration_values(database, parameters):
333343

334344
with database.atomic():
335345
for parameter in parameters:
336-
value = database.execute_sql(f"SHOW {parameter}").fetchone()[0]
337-
values[parameter] = value
346+
try:
347+
value = database.execute_sql(f"SHOW {parameter}").fetchone()[0]
348+
values[parameter] = value
349+
except ProgrammingError:
350+
pass
338351

339352
return values
340353

0 commit comments

Comments
 (0)