You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here's how the "thin layer" for programmatically invoking dbt works today, on the feature/click-cli feature branch:
# initializefromdbt.cli.mainimportdbtRunnerdbt=dbtRunner()
# need to pass CLI-style args as an ordered listcli_args= ['--fail-fast', 'run', '--select', 'tag:my_tag+2', 'another_model', '--exclude', 'not_this_model']
# 'results' is List[RunResult], 'success' is booleanresults, success=dbt.invoke(cli_args)
It's very very important that dbt-core's Python API is able to accept anything that you could also throw at its CLI. We should by no means take away this implementation; it works exactly in the ways it needs to. That said, it might not be in line what what community members are expecting the Python API to look & feel like.
Proposal
Another entry point could enable users to pass in structured data, and call a top-level method matching the desired command:
# initializefromdbt.mainimportdbtRunner# not dbt.cli.maindbt=dbtRunner()
# https://docs.getdbt.com/reference/global-configsglobal_configs= {"fail_fast": true}
# these could still be CLI-style stringsselect="tag:my_tag+ another_model"exclude="not_this_model"# top-level method matching the CLI subcommandresults, success=dbt.run(
select=select,
exclude=exclude,
global_configs=global_configs
)
For selection syntax, we could also mirror the data structure of yaml selectors:
Would we ever want users to import SelectionSpec and SelectorConfig, and construct a selector that way, using the Python objects directly...? We need to be very clear about what's part of the public API, and what are private internals.
github-actionsbot
changed the title
[Feature] Review programmatic entry point for top-level commands
[CT-1770] [Feature] Review programmatic entry point for top-level commands
Jan 8, 2023
A big part of this ticket is to discuss what using dbt as a "library" really looks like. We may need follow up tickets to this one after that discussion.
nathaniel-may
changed the title
[CT-1770] [Feature] Review programmatic entry point for top-level commands
[CT-1770] [Feature] [Spike] Review programmatic entry point for top-level commands
Jan 12, 2023
Status quo
Here's how the "thin layer" for programmatically invoking dbt works today, on the
feature/click-cli
feature branch:It's very very important that
dbt-core
's Python API is able to accept anything that you could also throw at its CLI. We should by no means take away this implementation; it works exactly in the ways it needs to. That said, it might not be in line what what community members are expecting the Python API to look & feel like.Proposal
Another entry point could enable users to pass in structured data, and call a top-level method matching the desired command:
For selection syntax, we could also mirror the data structure of yaml selectors:
Additional thoughts
global_configs
intodbtRunner
initialization:dbt = dbtRunner(global_configs = ...)
, with the ability to optionally override them for specific commands. This starts to feel a lot like settingUserConfig
([CT-1470] Whither UserConfig? #6207), or passing in env vars as "data" ([CT-1765] [Feature] Provide env vars as data during runtime #6545).SelectionSpec
andSelectorConfig
, and construct a selector that way, using the Python objects directly...? We need to be very clear about what's part of the public API, and what are private internals.The text was updated successfully, but these errors were encountered: