Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion augur/api/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def get_server_cache(cache_manager) -> Cache:

logger = AugurLogger("server").get_logger()
url = get_database_string()
engine = create_database_engine(url, poolclass=StaticPool)
engine = create_database_engine(url, poolclass=StaticPool, connect_args={"application_name": f"augur v{augur_code_version} api"})
db_session = DatabaseSession(logger, engine)
augur_config = AugurConfig(logger, db_session)

Expand Down
2 changes: 1 addition & 1 deletion augur/application/cli/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ def run_psql_command_in_database(target_type, target):
database_name = db_config["database_name"]

db_conn_string = f"postgresql+psycopg2://{db_config['user']}:{db_config['password']}@{db_config['host']}:{db_config['port']}/{db_config['database_name']}"
engine = s.create_engine(db_conn_string)
engine = s.create_engine(db_conn_string, connect_args={"application_name": f"augur cli"})

check_call(
[
Expand Down
4 changes: 2 additions & 2 deletions augur/application/db/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def get_engine():

if engine is None:
url = get_database_string()
engine = create_database_engine(url=url, poolclass=StaticPool)
engine = create_database_engine(url=url, poolclass=StaticPool, connect_args={"application_name": f"augur"})
Session = sessionmaker(bind=engine)

return engine
Expand Down Expand Up @@ -42,7 +42,7 @@ def get_session():
def temporary_database_engine():

url = get_database_string()
temporary_database_engine = create_database_engine(url=url, poolclass=StaticPool)
temporary_database_engine = create_database_engine(url=url, poolclass=StaticPool, connect_args={"application_name": f"augur v{__version__} temporary"})
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
W0621: Redefining name 'temporary_database_engine' from outer scope (line 44) (redefined-outer-name)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
W0621: Redefining name 'temporary_database_engine' from outer scope (line 42) (redefined-outer-name)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
E0602: Undefined variable 'version' (undefined-variable)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is __version__ defined or imported anywhere in this file? I don't see it. Wouldn't this raise a NameError at runtime?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh that should probably be removed if it hasn't already. I gave up importing the version except where already available because its in the metadata.py, outside the module structure and therefore hard to properly import

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah! Probably should remove this


try:
yield temporary_database_engine
Expand Down
4 changes: 2 additions & 2 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from augur.application.config import AugurConfig
from augur.application.db.engine import get_database_string, create_database_engine, parse_database_string, execute_sql_file


logger = logging.getLogger(__name__)

default_repo_id = "25430"
Expand Down Expand Up @@ -104,7 +103,8 @@ def generate_db_from_template(template_name):
create_database(conn, cursor, test_db_name, template_name)

# create engine to connect to db
engine = create_database_engine(test_db_string, poolclass=StaticPool)
engine = create_database_engine(test_db_string, poolclass=StaticPool, connect_args={"application_name": f"augur tests"})


yield engine

Expand Down
Loading