Skip to content

Commit 1ea0c8d

Browse files
committed
feat: allow offline mode via disable-introspection, fix sort issue
1 parent a78514f commit 1ea0c8d

File tree

5 files changed

+98
-53
lines changed

5 files changed

+98
-53
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "dbt-osmosis"
7-
version = "1.1.4"
7+
version = "1.1.5"
88
description = "A dbt utility for managing YAML to make developing with dbt more delightful."
99
readme = "README.md"
1010
license = { text = "Apache-2.0" }

src/dbt_osmosis/cli/main.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,7 @@ def dbt_opts(func: t.Callable[P, T]) -> t.Callable[P, T]:
6666
"--project-dir",
6767
type=click.Path(exists=True, dir_okay=True, file_okay=False),
6868
default=discover_project_dir,
69-
help=(
70-
"Which directory to look in for the dbt_project.yml file. Default is the current"
71-
" working directory and its parents."
72-
),
69+
help="Which directory to look in for the dbt_project.yml file. Default is the current working directory and its parents.",
7370
)
7471
@click.option(
7572
"--profiles-dir",
@@ -105,24 +102,24 @@ def yaml_opts(func: t.Callable[P, T]) -> t.Callable[P, T]:
105102
"--fqn",
106103
multiple=True,
107104
type=click.STRING,
108-
help="Specify models based on dbt's FQN. Mostly useful when combined with dbt ls.",
105+
help="Specify models based on dbt's FQN. Mostly useful when combined with dbt ls and command interpolation.",
109106
)
110107
@click.option(
111108
"-d",
112109
"--dry-run",
113110
is_flag=True,
114-
help="If specified, no changes are committed to disk.",
111+
help="No changes are committed to disk. Works well with --check as check will still exit with a code.",
115112
)
116113
@click.option(
117114
"-C",
118115
"--check",
119116
is_flag=True,
120-
help="If specified, will return a non-zero exit code if any files are changed or would have changed.",
117+
help="Return a non-zero exit code if any files are changed or would have changed.",
121118
)
122119
@click.option(
123120
"--catalog-path",
124121
type=click.Path(exists=True),
125-
help="If specified, will read the list of columns from the catalog.json file instead of querying the warehouse.",
122+
help="Read the list of columns from the catalog.json file instead of querying the warehouse.",
126123
)
127124
@click.option(
128125
"--profile",
@@ -132,10 +129,19 @@ def yaml_opts(func: t.Callable[P, T]) -> t.Callable[P, T]:
132129
@click.option(
133130
"--vars",
134131
type=click.STRING,
135-
help='Supply variables to the project. This argument overrides variables defined in your dbt_project.yml file. This argument should be a YAML string, eg. \'{"foo": "bar"}\'',
132+
help='Supply variables to the project. Override variables defined in your dbt_project.yml file. This argument should be a YAML string, eg. \'{"foo": "bar"}\'',
133+
)
134+
@click.option(
135+
"--disable-introspection",
136+
is_flag=True,
137+
help="Allows running the program without a database connection, it is recommended to use the --catalog-path option if using this.",
136138
)
137139
@functools.wraps(func)
138140
def wrapper(*args: P.args, **kwargs: P.kwargs) -> T:
141+
if kwargs.get("disable_introspection") and not kwargs.get("catalog_path"):
142+
logger.warning(
143+
":construction: You have disabled introspection without providing a catalog path. This will result in some features not working as expected."
144+
)
139145
return func(*args, **kwargs)
140146

141147
return wrapper
@@ -225,6 +231,7 @@ def refactor(
225231
auto_apply: bool = False,
226232
check: bool = False,
227233
threads: int | None = None,
234+
disable_introspection: bool = False,
228235
synthesize: bool = False,
229236
**kwargs: t.Any,
230237
) -> None:
@@ -242,6 +249,7 @@ def refactor(
242249
target=target,
243250
profile=profile,
244251
threads=threads,
252+
disable_introspection=disable_introspection,
245253
)
246254
context = YamlRefactorContext(
247255
project=create_dbt_project_context(settings),
@@ -287,6 +295,7 @@ def organize(
287295
vars: str | None = None,
288296
auto_apply: bool = False,
289297
threads: int | None = None,
298+
disable_introspection: bool = False,
290299
**kwargs: t.Any,
291300
) -> None:
292301
"""Organizes schema ymls based on config and injects undocumented models
@@ -302,6 +311,7 @@ def organize(
302311
target=target,
303312
profile=profile,
304313
threads=threads,
314+
disable_introspection=disable_introspection,
305315
)
306316
context = YamlRefactorContext(
307317
project=create_dbt_project_context(settings),
@@ -404,6 +414,7 @@ def document(
404414
vars: str | None = None,
405415
check: bool = False,
406416
threads: int | None = None,
417+
disable_introspection: bool = False,
407418
synthesize: bool = False,
408419
**kwargs: t.Any,
409420
) -> None:
@@ -420,6 +431,7 @@ def document(
420431
target=target,
421432
profile=profile,
422433
threads=threads,
434+
disable_introspection=disable_introspection,
423435
)
424436
context = YamlRefactorContext(
425437
project=create_dbt_project_context(settings),

0 commit comments

Comments
 (0)