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

[CT-1591] [Bug] New python files .py cause parsing and compilation errors #6367

Closed
2 tasks done
hope-wat opened this issue Dec 2, 2022 · 3 comments · Fixed by #6433
Closed
2 tasks done

[CT-1591] [Bug] New python files .py cause parsing and compilation errors #6367

hope-wat opened this issue Dec 2, 2022 · 3 comments · Fixed by #6433
Assignees
Labels
bug Something isn't working paper_cut A small change that impacts lots of users in their day-to-day python_models support_rotation A good task to pick up during support rotation
Milestone

Comments

@hope-wat
Copy link

hope-wat commented Dec 2, 2022

Is this a new bug in dbt-core?

  • I believe this is a new bug in dbt-core
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

When you open a new python file .py it causes a parsing and compilation error until the model code is inputted.

def model(dbt, session):
 ...
    return df

This is not great for mid development experience and blocks the ability to run any of your other models simply because you started working on a .py file.
https://www.loom.com/share/cea560725928459cb896a398289369e2

Expected Behavior

No error compilation for new and empty python files.
Allow you to run other models in your pipeline during python development.

Steps To Reproduce

  1. In dbt cloud on v1.3
  2. Create a new .py file without any code

Relevant log output

No response

Environment

- OS:
- Python:
- dbt:

Which database adapter are you using with dbt?

No response

Additional Context

No response

@hope-wat hope-wat added bug Something isn't working triage labels Dec 2, 2022
@github-actions github-actions bot changed the title [Bug] New python files .py cause parsing and compilation errors [CT-1591] [Bug] New python files .py cause parsing and compilation errors Dec 2, 2022
@dbeatty10 dbeatty10 added python_models paper_cut A small change that impacts lots of users in their day-to-day labels Dec 2, 2022
@dbeatty10
Copy link
Contributor

Thanks for discovering and reporting this @hope-wat !

Per your initial convo with @jtcohen6 in internal Slack the fix would just be:

avoid parsing the file at all / raising that error if the file is totally empty


Side not

In your screenshot, it contains a phrase which isn't the most clear:

dbt only allow one model defined per python file

Thankfully an update to that piece was merged just yesterday in #6251. The new message will read:

dbt allows exactly one model defined per python file, found {x}

@dbeatty10 dbeatty10 removed the triage label Dec 3, 2022
@jtcohen6 jtcohen6 added Team:Language support_rotation A good task to pick up during support rotation labels Dec 6, 2022
@jtcohen6
Copy link
Contributor

jtcohen6 commented Dec 6, 2022

This should be a really quick fix, and a nontrivial quality-of-life improvement! Let's try to make it happen.

@jtcohen6 jtcohen6 added this to the v1.4 milestone Dec 6, 2022
@ChenyuLInx
Copy link
Contributor

Talked about this live with @aranke
Acceptance criteria:
This is where the error being raised. We should make sure we add another unittest similar to this one but with empty file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working paper_cut A small change that impacts lots of users in their day-to-day python_models support_rotation A good task to pick up during support rotation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants