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

feat(ingest): prettify stack traces in CLI #2845

Merged
merged 1 commit into from
Jul 8, 2021
Merged
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
1 change: 1 addition & 0 deletions metadata-ingestion/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def get_long_description():
"avro-gen3==0.5.0",
"avro-python3>=1.8.2",
"python-dateutil",
"stackprinter",
}

kafka_common = {
Expand Down
18 changes: 17 additions & 1 deletion metadata-ingestion/src/datahub/entrypoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import sys

import click
import stackprinter
from pydantic import ValidationError

import datahub as datahub_package
Expand All @@ -25,12 +26,14 @@
)
logging.basicConfig(format=BASE_LOGGING_FORMAT)

MAX_CONTENT_WIDTH = 120


@click.group(
context_settings=dict(
# Avoid truncation of help text.
# See https://github.com/pallets/click/issues/486.
max_content_width=120,
max_content_width=MAX_CONTENT_WIDTH,
)
)
@click.option("--debug/--no-debug", default=False)
Expand Down Expand Up @@ -66,6 +69,7 @@ def version() -> None:
)
def ingest(config: str) -> None:
"""Ingest metadata into DataHub."""
logger.debug("DataHub CLI version: %s", datahub_package.nice_version_name())

config_file = pathlib.Path(config)
pipeline_config = load_config_file(config_file)
Expand All @@ -77,7 +81,9 @@ def ingest(config: str) -> None:
click.echo(e, err=True)
sys.exit(1)

logger.info("Starting metadata ingestion")
pipeline.run()
logger.info("Finished metadata ingestion")
ret = pipeline.pretty_print_summary()
sys.exit(ret)

Expand All @@ -96,3 +102,13 @@ def main(**kwargs):
except click.ClickException as error:
error.show()
sys.exit(1)
except Exception as exc:
logger.error(
stackprinter.format(
exc,
line_wrap=MAX_CONTENT_WIDTH,
truncate_vals=10 * MAX_CONTENT_WIDTH,
suppressed_paths=[r"lib/python.*/site-packages/click/"],
)
)
sys.exit(1)