Skip to content

Commit

Permalink
chore: small repetition decrease in cli and remove test pypi for now
Browse files Browse the repository at this point in the history
  • Loading branch information
z3z1ma committed Jan 2, 2025
1 parent 3df7627 commit 9d8bc30
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 96 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ jobs:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}

- name: Publish package on TestPyPI
if: "! steps.check-version.outputs.tag"
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.TEST_PYPI_TOKEN }}
repository_url: https://test.pypi.org/legacy/
# - name: Publish package on TestPyPI
# if: "! steps.check-version.outputs.tag"
# uses: pypa/[email protected]
# with:
# user: __token__
# password: ${{ secrets.TEST_PYPI_TOKEN }}
# repository_url: https://test.pypi.org/legacy/

- name: Publish the release notes
uses: release-drafter/[email protected]
Expand Down
97 changes: 11 additions & 86 deletions src/dbt_osmosis/cli/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pyright: reportUnreachable=false
# pyright: reportUnreachable=false, reportAny=false
import functools
import io
import subprocess
Expand Down Expand Up @@ -200,27 +200,13 @@ def wrapper(*args: P.args, **kwargs: P.kwargs) -> T:
@click.argument("models", nargs=-1)
def refactor(
target: str | None = None,
profile: str | None = None,
project_dir: str | None = None,
profiles_dir: str | None = None,
catalog_path: str | None = None,
fqn: list[str] | None = None,
force_inherit_descriptions: bool = False,
dry_run: bool = False,
check: bool = False,
skip_add_columns: bool = False,
skip_add_tags: bool = False,
skip_add_data_types: bool = False,
numeric_precision: bool = False,
char_length: bool = False,
skip_merge_meta: bool = False,
add_progenitor_to_meta: bool = False,
models: list[str] | None = None,
profile: str | None = None,
vars: str | None = None,
use_unrendered_descriptions: bool = False,
add_inheritance_for_specified_keys: list[str] | None = None,
output_to_lower: bool = False,
auto_apply: bool = False,
check: bool = False,
**kwargs: t.Any,
) -> None:
"""Executes organize which syncs yaml files with database schema and organizes the dbt models
directory, reparses the project, then executes document passing down inheritable documentation
Expand All @@ -238,24 +224,7 @@ def refactor(
)
context = YamlRefactorContext(
project=create_dbt_project_context(settings),
settings=YamlRefactorSettings(
fqns=fqn or [],
models=models or [],
dry_run=dry_run,
skip_add_columns=skip_add_columns,
skip_add_tags=skip_add_tags,
skip_merge_meta=skip_merge_meta,
skip_add_data_types=skip_add_data_types,
numeric_precision=numeric_precision,
char_length=char_length,
add_progenitor_to_meta=add_progenitor_to_meta,
use_unrendered_descriptions=use_unrendered_descriptions,
add_inheritance_for_specified_keys=add_inheritance_for_specified_keys or [],
output_to_lower=output_to_lower,
force_inherit_descriptions=force_inherit_descriptions,
catalog_path=catalog_path,
create_catalog_if_not_exists=False, # TODO: allow enabling if ready
),
settings=YamlRefactorSettings(**kwargs, create_catalog_if_not_exists=False),
)
if vars:
settings.vars = context.yaml_handler.load(io.StringIO(vars)) # pyright: ignore[reportUnknownMemberType]
Expand Down Expand Up @@ -288,14 +257,11 @@ def organize(
target: str | None = None,
project_dir: str | None = None,
profiles_dir: str | None = None,
catalog_path: str | None = None,
fqn: list[str] | None = None,
dry_run: bool = False,
check: bool = False,
models: list[str] | None = None,
profile: str | None = None,
vars: str | None = None,
auto_apply: bool = False,
**kwargs: t.Any,
) -> None:
"""Organizes schema ymls based on config and injects undocumented models
Expand All @@ -312,13 +278,7 @@ def organize(
)
context = YamlRefactorContext(
project=create_dbt_project_context(settings),
settings=YamlRefactorSettings(
fqns=fqn or [],
models=models or [],
dry_run=dry_run,
catalog_path=catalog_path,
create_catalog_if_not_exists=False,
),
settings=YamlRefactorSettings(**kwargs, create_catalog_if_not_exists=False),
)
if vars:
settings.vars = context.yaml_handler.load(io.StringIO(vars)) # pyright: ignore[reportUnknownMemberType]
Expand Down Expand Up @@ -395,37 +355,18 @@ def organize(
@click.argument("models", nargs=-1)
def document(
target: str | None = None,
profile: str | None = None,
project_dir: str | None = None,
profiles_dir: str | None = None,
models: list[str] | None = None,
fqn: list[str] | None = None,
dry_run: bool = False,
check: bool = False,
skip_merge_meta: bool = False,
skip_add_tags: bool = False,
skip_add_data_types: bool = False,
skip_add_columns: bool = False,
add_progenitor_to_meta: bool = False,
add_inheritance_for_specified_keys: list[str] | None = None,
use_unrendered_descriptions: bool = False,
force_inherit_descriptions: bool = False,
output_to_lower: bool = False,
char_length: bool = False,
numeric_precision: bool = False,
catalog_path: str | None = None,
vars: str | None = None,
profile: str | None = None,
check: bool = False,
**kwargs: t.Any,
) -> None:
"""Column level documentation inheritance for existing models
\f
This command will conform schema ymls in your project as outlined in `dbt_project.yml` &
bootstrap undocumented dbt models
Args:
target (Optional[str]): Profile target. Defaults to default target set in profile yml
project_dir (Optional[str], optional): Dbt project directory. Defaults to working directory.
profiles_dir (Optional[str], optional): Dbt profile directory. Defaults to ~/.dbt
"""
logger.info(":water_wave: Executing dbt-osmosis\n")
settings = DbtConfiguration(
Expand All @@ -436,23 +377,7 @@ def document(
)
context = YamlRefactorContext(
project=create_dbt_project_context(settings),
settings=YamlRefactorSettings(
fqns=fqn or [],
models=models or [],
dry_run=dry_run,
skip_add_tags=skip_add_tags,
skip_merge_meta=skip_merge_meta,
skip_add_data_types=skip_add_data_types,
skip_add_columns=skip_add_columns,
numeric_precision=numeric_precision,
char_length=char_length,
add_progenitor_to_meta=add_progenitor_to_meta,
use_unrendered_descriptions=use_unrendered_descriptions,
add_inheritance_for_specified_keys=add_inheritance_for_specified_keys or [],
output_to_lower=output_to_lower,
force_inherit_descriptions=force_inherit_descriptions,
catalog_path=catalog_path,
),
settings=YamlRefactorSettings(**kwargs, create_catalog_if_not_exists=False),
)
if vars:
settings.vars = context.yaml_handler.load(io.StringIO(vars)) # pyright: ignore[reportUnknownMemberType]
Expand Down
6 changes: 3 additions & 3 deletions src/dbt_osmosis/core/osmosis.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ class RestructureDeltaPlan:
class YamlRefactorSettings:
"""Settings for yaml based refactoring operations."""

fqns: list[str] = field(default_factory=list)
fqn: list[str] = field(default_factory=list)
"""Filter models to action via a fully qualified name match such as returned by `dbt ls`."""
models: list[str] = field(default_factory=list)
"""Filter models to action via a file path match."""
Expand Down Expand Up @@ -639,8 +639,8 @@ def f(node: ResultNode) -> bool:
if context.settings.models:
if not _is_file_match(node, context.settings.models):
return False
if context.settings.fqns:
if not _is_fqn_match(node, context.settings.fqns):
if context.settings.fqn:
if not _is_fqn_match(node, context.settings.fqn):
return False
logger.debug(":white_check_mark: Node => %s passed filtering logic.", node.unique_id)
return True
Expand Down

0 comments on commit 9d8bc30

Please sign in to comment.