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-1928] Support passing event callbacks to EventManager via dbtRunner #6763

Closed
Tracked by #7162 ...
MichelleArk opened this issue Jan 26, 2023 · 2 comments · Fixed by #7214
Closed
Tracked by #7162 ...

[CT-1928] Support passing event callbacks to EventManager via dbtRunner #6763

MichelleArk opened this issue Jan 26, 2023 · 2 comments · Fixed by #7214
Assignees
Labels
logging python_api Issues related to dbtRunner Python entry point

Comments

@MichelleArk
Copy link
Contributor

MichelleArk commented Jan 26, 2023

Accept event callbacks as part of dbtRunner's constructor and use them to setup the EventManager for programmatic invocations of dbt.

@MichelleArk MichelleArk added python_api Issues related to dbtRunner Python entry point Team:Execution labels Jan 26, 2023
@github-actions github-actions bot changed the title Support passing event callbacks to EventManager via dbtRunner [CT-1928] Support passing event callbacks to EventManager via dbtRunner Jan 26, 2023
@stu-k
Copy link
Contributor

stu-k commented Feb 28, 2023

My have to add a method to add a callback to EventManager, and use the ctx to carry the callbacks from dbtRunner's constructor to preflight where we setup the logger.

@chamini2
Copy link
Contributor

chamini2 commented Apr 5, 2023

Hey, the current implementation in #7214 seems to wait for the callbacks to be processed before continuing with the invocation. Let me share an example:

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

import time

def print_callback(event: EventMsg):
    print("Sleeping")
    time.sleep(2)
    print("Got an event:", event.info.name, event)

dbt = dbtRunner(callbacks=[print_callback])
dbt.invoke(['list'])

This takes 30 seconds to run because it waits for the time.sleep(2) to finish befor continuing.

Is this an implementation detail that may change in the future or as intended?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
logging python_api Issues related to dbtRunner Python entry point
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants