Skip to content

Commit

Permalink
clean up create_pg_connection (#8165)
Browse files Browse the repository at this point in the history
  • Loading branch information
alangenfeld committed Jun 2, 2022
1 parent 5c35d39 commit 974af9f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def store_asset_event(self, event):
conn.execute(query)

def _connect(self):
return create_pg_connection(self._engine, pg_alembic_config(__file__), "event log")
return create_pg_connection(self._engine)

def run_connection(self, run_id=None):
return self._connect()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,7 @@ def create_clean_storage(postgres_url, should_autocreate_tables=True):
return PostgresRunStorage(postgres_url, should_autocreate_tables)

def connect(self):
return create_pg_connection(
self._engine,
pg_alembic_config(__file__),
"run",
)
return create_pg_connection(self._engine)

def upgrade(self):
with self.connect() as conn:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def create_clean_storage(postgres_url, should_autocreate_tables=True):
return PostgresScheduleStorage(postgres_url, should_autocreate_tables)

def connect(self, run_id=None): # pylint: disable=arguments-differ, unused-argument
return create_pg_connection(self._engine, pg_alembic_config(__file__), "schedule")
return create_pg_connection(self._engine)

def upgrade(self):
alembic_config = pg_alembic_config(__file__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,8 @@ def pg_alembic_config(dunder_file, script_location=None):


@contextmanager
def create_pg_connection(engine, _alembic_config, storage_type_desc=None):
def create_pg_connection(engine):
check.inst_param(engine, "engine", sqlalchemy.engine.Engine)
check.opt_str_param(storage_type_desc, "storage_type_desc", "")

if storage_type_desc:
storage_type_desc += " "
else:
storage_type_desc = ""

conn = None
try:
# Retry connection to gracefully handle transient connection issues
Expand Down

0 comments on commit 974af9f

Please sign in to comment.