Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

Show line number for Python model errors in dbt run #771

Open
1 task done
kinghuang opened this issue Feb 25, 2023 · 1 comment
Open
1 task done

Show line number for Python model errors in dbt run #771

kinghuang opened this issue Feb 25, 2023 · 1 comment
Labels
feature request New feature or request

Comments

@kinghuang
Copy link
Contributor

Context

When an exception is raised in a Python model run via dbt, the error output shows the string representation of the exception, but not the error type or the line number of where the exception was raised. This makes it really hard to locate where the error occurred. The log message should include the error type and line number. And, perhaps there should be an option to show or capture an entire traceback.

Is your feature request related to a problem? Please describe.

I find it difficult to debug Python models because it is hard to pinpoint where in the code an exception was raised.

Describe the solution you'd like

The error message should include the exception class and the line number from the traceback.

So, instead of the following log message:

not enough values to unpack (expected 3, got 2)

I would like to see something like:

File "wells_index__keys.py", line 107: ValueError: not enough values to unpack (expected 3, got 2)

Describe alternatives you've considered

Run often to narrow the possible scope for an exception to occur.

Additional context

Here is an excerpted output from dbt run, showing an error occurred with the message "not enough values to unpack (expected 3, got 2)".

18:50:18  1 of 2 START python table model dbt_king_dibi_env.wells_index__keys ............ [RUN]
18:51:14  Unhandled error while executing target/run/dibi_env/models/foundations_wells/wells_index__keys.py
not enough values to unpack (expected 3, got 2)
18:51:14  1 of 2 ERROR creating python table model dbt_king_dibi_env.wells_index__keys ... [ERROR in 55.56s]
18:51:14  2 of 2 SKIP relation dbt_king_dibi_env.wells_index__full ....................... [SKIP]
18:51:15  
18:51:15  Finished running 2 table models in 0 hours 0 minutes and 59.85 seconds (59.85s).
18:51:15  
18:51:15  Completed with 1 error and 0 warnings:
18:51:15  
18:51:15  not enough values to unpack (expected 3, got 2)
18:51:15  
18:51:15  Done. PASS=0 WARN=0 ERROR=1 SKIP=1 TOTAL=2

The raised exception is a ValueError from code on line 107. But, without this information in the run output, it is very hard to figure out where the problem is in the Python model.

Is there an existing feature request for this?

  • I have searched the existing issues
@kinghuang kinghuang added the feature request New feature or request label Feb 25, 2023
@HlebKrah
Copy link

+1
It would be great if this functionality were implemented. Now it’s not clear where the error falls and you have to transfer the model to Jupiter notebook or put a bunch of loggers

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants