-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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-2124] [Feature] --no-connection
flag for dbt docs generate
#6980
Comments
--no-connection
flag for dbt docs generate
--no-connection
flag for dbt docs generate
+1 to this feature request... there was a similar discussion as back as 2021. |
@jaypeedevlin Thanks for opening! This feels totally reasonable to me. I agree with your take that:
ImplementationsI believe such a flag could conditionally wrap the logic here in the # this should go at the top of the file
import agate
...
# initialize empty typed objects, based on return types of get_catalog
catalog_table: agate.Table = agate.Table([])
exceptions: List[Exception] = []
if not self.args.no_connection: # or whatever we call this -- see below
adapter = get_adapter(self.config)
with adapter.connection_named("generate_catalog"):
fire_event(BuildingCatalog())
catalog_table, exceptions = adapter.get_catalog(self.manifest)
# otherwise, use the empty objects, and proceed What should the flag be called?
Then:
Would produce a Going to mark this as a good first issue! Incidentally, I think we could also solve for this via:
Just sharing as an observation — I don't think that's a reason to not also offer this flag! In the meantime, here's a fun hack, as a treat: # write manifest.json -- starting in v1.5, no need to pass this flag, 'parse' always writes
$ dbt parse --write-manifest
# write an empty catalog.json
$ echo '{"metadata": {}, "nodes": {}, "sources": {}, "errors": null}' > target/catalog.json
$ dbt docs serve
|
FYI, providing the ability to bypass connection would also be very helpful for linting with sqlfluff, right now, in order to lint and test the sql/macros before actually running them it requires an active connection (which is an antipattern in my opinion) sqlfluff/sqlfluff#4397 |
@manugarri this issue is about generating artifacts for docs, not for compilation. At the risk of derailing this issue, the reason dbt needs a connection to compile is because jinja-sql supports functions like Disclosure, I don't work for dbt Labs and this is just my personal opinion |
@jaypeedevlin thanks for the clarification, I would argue that just because we want to support run_query (which might or might not be used in individual dbt projects) we are forcing everyone to setup a connection on their ci/cd. IMHO it should be the other way around, optional connection, and if a user wants to use something like |
I would encourage you to open a issue (or maybe a discussion is more appropriate) around this and/or find an existing one to continue the conversation! |
Hey there! Unsure if issue still high in demand, but I've made a linked draft with changes discussed here. Let me know if it makes sense and I'll carry on. |
I would be interested in this |
@manugarri @jaypeedevlin Regarding the other conversation, about compiling models without an active connection, this will be newly supported in v1.5:
Note that this will fail if you have
Not very graceful, but it's a first cut. What really happened is, the connection was never opened! |
@AndyBys I haven't started work on this yet so consider it yours! |
@jtcohen6 great! does that mean we will be able to generate docs without an active connection in the future? |
Big plus one to this. |
If this goes ahead, then |
@dwolfeu A valid profile is still required for project parsing today, because users may access values of |
@jtcohen6 Thank you for your quick reply! From the perspective of an end user (who knows nothing of the inner workings of *We are not the only ones: see this workaround, for instance. |
@dwolfeu To clarify my message above: |
@jtcohen6 We are using this dummy profile-name:
target: docs
outputs:
docs:
type: postgres
host: foo
database: foo
schema: foo
port: 00
threads: 1
user: foo
password: foo It works, but it's hacky. It would be nicer not to have to include a profile at all. Some context (so you don't think I'm crazy!): We of course have a "real" |
Is this --no-connection flag available in the latest version of dbt-core? I couldn't get it work. I'm using dbt-databricks. |
Is this your first time submitting a feature request?
Describe the feature
Provide an optional flag to be used with doc generation that skips the metadata queries and generates
catalog.json
based only off what it can get from compilation (and/or the existingmanifest.json
if--no-compile
is also passed).The problem I am solving for is around enabling the docs to be used locally for exploratory purposes during local development in large projects where building the catalog would otherwise take a long time — in the case of our project building the catalog without compile takes >30 minutes (11k nodes, Snowflake, 8 threads, 2XL).
This problem and solution is actually described exactly in #3947 (comment):
The intention would be that it's not recommended to use this flag for building production-quality docs, but it would unlock quick exploration in large projects.
Describe alternatives you've considered
Who will this benefit?
Developers of large projects.
Are you interested in contributing this feature?
Provided it is within my capabilities, then yes!
Anything else?
I imagine this feature would be (ab)used by many folks who want to build their docs in CI without a DB connection. I'm not sure that this is behaviour we should actually be preventing though, as long as they understand the tradeoffs.
The text was updated successfully, but these errors were encountered: