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-2375] [Bug] dbtRunner instances share the callbacks across instances when no callbacks are passed #7278

Closed
2 tasks done
chamini2 opened this issue Apr 5, 2023 · 1 comment · Fixed by #7279
Closed
2 tasks done
Labels
bug Something isn't working

Comments

@chamini2
Copy link
Contributor

chamini2 commented Apr 5, 2023

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

from dbt.cli.main import dbtRunner, list
from dbt.events.base_types import EventMsg

def print_callback(event: EventMsg):
    print("Got an event:", event.info.name)

dbt = dbtRunner()
dbt.callbacks.append(print_callback)

dbt2 = dbtRunner()
dbt2.invoke(['list'])   # this prints the event names

example run:

❯ python runner.py
16:32:42  Running with dbt=1.5.0-b5
Got an event: MainReportVersion
Got an event: MainReportArgs
16:32:42  [WARNING]: Deprecated functionality
The `target-path` config in `dbt_project.yml` has been deprecated, and will no
longer be supported in a future version of dbt-core. If you wish to write dbt
artifacts to a custom directory, please use the --target-path CLI flag or
DBT_TARGET_PATH env var instead.
Got an event: ConfigTargetPathDeprecation
Got an event: SendingEvent
Got an event: SendingEvent
Got an event: SendingEvent
Got an event: StateCheckVarsHash
Got an event: PartialParsingEnabled
Got an event: PartialParsingSkipParsing
Got an event: SendingEvent
Got an event: SendingEvent
16:32:42  Found 4 models, 0 tests, 0 snapshots, 0 analyses, 309 macros, 0 operations, 0 seed files, 0 sources, 0 exposures, 0 metrics, 0 groups
Got an event: FoundStats
Got an event: SendingEvent
simple_test.base.model_a
simple_test.base.model_b
simple_test.python.model_c
simple_test.model_d
Got an event: CommandCompleted
Got an event: SendingEvent
Got an event: FlushEvents

Expected Behavior

dbtRunner instances should be isolated from one another.

Steps To Reproduce

See current behavior

Relevant log output

No response

Environment

- OS: macOS Ventura
- Python: Python 3.8.13
- dbt: 1.5.0-b5

Which database adapter are you using with dbt?

postgres

Additional Context

https://stackoverflow.com/questions/366422/how-can-i-avoid-issues-caused-by-pythons-early-bound-default-parameters-e-g-m

@chamini2 chamini2 added bug Something isn't working triage labels Apr 5, 2023
@github-actions github-actions bot changed the title [Bug] dbtRunner instances share the callbacks across instances when no callbacks are passed [CT-2375] [Bug] dbtRunner instances share the callbacks across instances when no callbacks are passed Apr 5, 2023
@jtcohen6
Copy link
Contributor

jtcohen6 commented Apr 5, 2023

@chamini2 Thanks for best-testing, and for the quick PR !! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants