From 9d8bc309aa5d67772ca66da405d3b2535fd1493f Mon Sep 17 00:00:00 2001 From: z3z1ma Date: Thu, 2 Jan 2025 05:00:25 -0700 Subject: [PATCH] chore: small repetition decrease in cli and remove test pypi for now --- .github/workflows/release.yml | 14 ++--- src/dbt_osmosis/cli/main.py | 97 ++++----------------------------- src/dbt_osmosis/core/osmosis.py | 6 +- 3 files changed, 21 insertions(+), 96 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index de5166d..495a4bd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -60,13 +60,13 @@ jobs: user: __token__ password: ${{ secrets.PYPI_TOKEN }} - - name: Publish package on TestPyPI - if: "! steps.check-version.outputs.tag" - uses: pypa/gh-action-pypi-publish@v1.12.3 - 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/gh-action-pypi-publish@v1.12.3 + # with: + # user: __token__ + # password: ${{ secrets.TEST_PYPI_TOKEN }} + # repository_url: https://test.pypi.org/legacy/ - name: Publish the release notes uses: release-drafter/release-drafter@v5.23.0 diff --git a/src/dbt_osmosis/cli/main.py b/src/dbt_osmosis/cli/main.py index b0b7a24..6dc4a28 100644 --- a/src/dbt_osmosis/cli/main.py +++ b/src/dbt_osmosis/cli/main.py @@ -1,4 +1,4 @@ -# pyright: reportUnreachable=false +# pyright: reportUnreachable=false, reportAny=false import functools import io import subprocess @@ -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 @@ -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] @@ -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 @@ -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] @@ -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( @@ -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] diff --git a/src/dbt_osmosis/core/osmosis.py b/src/dbt_osmosis/core/osmosis.py index b6f2080..c7b8ae3 100644 --- a/src/dbt_osmosis/core/osmosis.py +++ b/src/dbt_osmosis/core/osmosis.py @@ -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.""" @@ -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