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-1621] [Feature] de-globalize things through contextvar #6399

Closed
3 tasks done
Tracked by #6356
ChenyuLInx opened this issue Dec 7, 2022 · 2 comments
Closed
3 tasks done
Tracked by #6356

[CT-1621] [Feature] de-globalize things through contextvar #6399

ChenyuLInx opened this issue Dec 7, 2022 · 2 comments
Assignees
Labels
enhancement New feature or request python_api Issues related to dbtRunner Python entry point Refinement Maintainer input needed

Comments

@ChenyuLInx
Copy link
Contributor

ChenyuLInx commented Dec 7, 2022

Is this your first time submitting a feature request?

  • I have read the expectations for open source contributors
  • I have searched the existing issues, and I could not find an existing issue for this feature
  • I am requesting a straightforward extension of existing dbt functionality, rather than a Big Idea better suited to a discussion

Describe the feature

We have a few things inside dbt-core that are python global objects. Some examples are active_user, EVENT_MANAGER. With the future of dbt-server running multiple dbt-core invocations at the same time, we should make sure those multiple invocation don't overwrite those objects.

In the example here, contextvars is a great way of dealing with global variables during concurrency.

We should make sure we move the usage of all global object in dbt-core into contextvars

@ChenyuLInx ChenyuLInx added enhancement New feature or request triage labels Dec 7, 2022
@github-actions github-actions bot changed the title [Feature] de-globalize things through contextvar [CT-1621] [Feature] de-globalize things through contextvar Dec 7, 2022
@ChenyuLInx ChenyuLInx added python_api Issues related to dbtRunner Python entry point Team:Execution and removed triage labels Dec 7, 2022
@jtcohen6
Copy link
Contributor

jtcohen6 commented Dec 7, 2022

Another funny one to add to the list of unnecessarily global objects: selected_resources. We already have an open issue for that here: #6009. Thoughts on keeping it as a separate issue/ticket, versus pulling it into this one?

And then, of course, there's the one singleton to rule them all: adapters (#5533 (comment)). I don't know if we'd want to take a contextvars-based approach there, rather than really reconsidering / refactoring how adapters are registered + initialized.

@MichelleArk
Copy link
Contributor

Another global flag to be aware of is USE_COLORS, which is initialized as part of GLOBAL_FLAGS Namespace in flags.py, and used in ui.color

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request python_api Issues related to dbtRunner Python entry point Refinement Maintainer input needed
Projects
None yet
Development

No branches or pull requests

5 participants