-
Notifications
You must be signed in to change notification settings - Fork 996
Add a starter CLI for a self-check script #3778
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # SPDX-License-Identifier: MIT | ||
| import logging | ||
| import click | ||
| import sqlalchemy as s | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pylint] reported by reviewdog 🐶 |
||
| from sqlalchemy import select, func | ||
|
|
||
| from augur.application.cli import ( | ||
| test_connection, | ||
| test_db_connection, | ||
| with_database, | ||
| DatabaseContext, | ||
| ) | ||
| from augur.application.db.models.augur_data import Commit | ||
|
|
||
| # from augur.application.db.session import DatabaseSession | ||
| from datetime import datetime | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pylint] reported by reviewdog 🐶 |
||
| from augur.application.db.models import Repo | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pylint] reported by reviewdog 🐶 |
||
|
|
||
| from ._cli_util import get_db_version | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pylint] reported by reviewdog 🐶 |
||
|
|
||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| @click.group("selftest", short_help="Augur self-testing utilities") | ||
| @click.pass_context | ||
| def cli(ctx): | ||
| ctx.obj = DatabaseContext() | ||
|
|
||
|
|
||
| @cli.command("report") | ||
| @test_connection | ||
| @test_db_connection | ||
| @with_database | ||
| @click.pass_context | ||
| def run_selftest_report(ctx): | ||
| """ | ||
| Run queries to evaluate various aspects of the augur system's functioning and produce a report | ||
| """ | ||
| click.echo('Generating Augur selftest report....') | ||
|
|
||
| cmt_author_name_issue_3740_query = ( | ||
| select(func.count()) | ||
| .select_from(Commit) | ||
| .where(Commit.cmt_author_name == '') | ||
| ) | ||
| cmt_author_name_issue_3740_count = None | ||
|
|
||
| with ctx.obj.engine.begin() as connection: | ||
| cmt_author_name_issue_3740_count = connection.execute(cmt_author_name_issue_3740_query).scalar_one() | ||
| click.echo(f'Issue 3740 count: {cmt_author_name_issue_3740_count} commit files in the `commits` table contain authors with an empty string as their name') | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pylint] reported by reviewdog 🐶
W0611: Unused get_db_version imported from _cli_util (unused-import)