Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling database engines in the CLI #2721

Merged
merged 4 commits into from
Feb 27, 2024
Merged

Handling database engines in the CLI #2721

merged 4 commits into from
Feb 27, 2024

Conversation

ABrain7710
Copy link
Contributor

Description

  • Define cli engine in database folder
  • Define click decorator that automatically cleans up database engine after command completes

Signed commits

  • Yes, I signed my commits.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

pylint

augur/application/cli/db.py|396| C0116: Missing function or method docstring (missing-function-docstring)
augur/application/cli/user.py|15 col 1| W0511: TODO: Update these commands to use cli DatabaseContext so this engine is cleaned up (fixme)

@@ -72,6 +73,22 @@ def new_func(ctx, *args, **kwargs):

return update_wrapper(new_func, function_db_connection)


class DatabaseContext(object):

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
C0115: Missing class docstring (missing-class-docstring)

@@ -72,6 +73,22 @@ def new_func(ctx, *args, **kwargs):

return update_wrapper(new_func, function_db_connection)


class DatabaseContext(object):

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
R0205: Class 'DatabaseContext' inherits from object, can be safely removed from bases in python3 (useless-object-inheritance)

@@ -72,6 +73,22 @@ def new_func(ctx, *args, **kwargs):

return update_wrapper(new_func, function_db_connection)


class DatabaseContext(object):

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
R0903: Too few public methods (0/2) (too-few-public-methods)

def __init__(self):
self.engine = None

def with_database(f):

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
C0116: Missing function or method docstring (missing-function-docstring)

def cli():
pass
@click.pass_context
def cli(ctx):

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
C0116: Missing function or method docstring (missing-function-docstring)

def add_github_org(organization_name):
@with_database
@click.pass_context
def add_github_org(ctx, organization_name):
"""
Create new repo groups in Augur's database
"""
from augur.tasks.github.util.github_task_session import GithubTaskSession
from augur.util.repo_load_controller import RepoLoadController

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
C0415: Import outside toplevel (augur.util.repo_load_controller.RepoLoadController) (import-outside-toplevel)

def get_api_key():
@with_database
@click.pass_context
def get_api_key(ctx):

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
C0116: Missing function or method docstring (missing-function-docstring)

@test_db_connection
@with_database
@click.pass_context
def reset_repo_age(ctx):

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
C0116: Missing function or method docstring (missing-function-docstring)


session.execute(update_query)
session.commit()

@cli.command("test-connection")
@test_connection
@test_db_connection
def test_db_connection():

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
C0116: Missing function or method docstring (missing-function-docstring)


session.execute(update_query)
session.commit()

@cli.command("test-connection")
@test_connection
@test_db_connection
def test_db_connection():

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
E0102: function already defined line 15 (function-redefined)

@@ -72,6 +73,22 @@ def new_func(ctx, *args, **kwargs):

return update_wrapper(new_func, function_db_connection)


class DatabaseContext():

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
C0115: Missing class docstring (missing-class-docstring)

@@ -72,6 +73,22 @@ def new_func(ctx, *args, **kwargs):

return update_wrapper(new_func, function_db_connection)


class DatabaseContext():

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
R0903: Too few public methods (0/2) (too-few-public-methods)

@cli.command("test-connection")
@test_connection
@test_db_connection
def test_db_connection():
pass
print("Successful db connection")


# TODO: Fix this function
def run_psql_command_in_database(target_type, target):

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
C0116: Missing function or method docstring (missing-function-docstring)

@@ -12,7 +12,7 @@
from augur.application.db.engine import DatabaseEngine
from sqlalchemy.orm import sessionmaker


# TODO: Update these commands to use cli DatabaseContext so this engine is cleaned up

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
W0511: TODO: Update these commands to use cli DatabaseContext so this engine is cleaned up (fixme)

Copy link
Contributor

@IsaacMilarky IsaacMilarky left a comment

Choose a reason for hiding this comment

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

LGTM

@IsaacMilarky IsaacMilarky merged commit ad437c7 into dev Feb 27, 2024
5 checks passed
@ABrain7710 ABrain7710 deleted the cli-engine-cleanup branch March 15, 2024 00:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants