From 1c731a60a8918e4ea06a5f11174e95f9e9c16ea4 Mon Sep 17 00:00:00 2001 From: yousefsalhamoud Date: Fri, 13 Mar 2026 14:15:55 +0100 Subject: [PATCH 1/3] draft pr as a user input --- readme.md | 1 + src/dwh2looker/cli/commands.py | 6 ++++++ src/dwh2looker/lookml_generator/lookml_generator.py | 3 +++ src/dwh2looker/vc_client/vc_client.py | 4 ++-- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 64a1d8c..4dec9fd 100644 --- a/readme.md +++ b/readme.md @@ -238,6 +238,7 @@ This command created the LookML base views. - `--token` (type: str, required: False): GitHub Token. - `--github-app` (action: Boolean, default: False): Run as GitHub App (omit this flag if running with PAT). - `--push-lookml-to-looker` (action: Boolean, default: False): Push generated LookML to Looker via GitHub. +- `--draft-pr` (action: Boolean, default: False): Create the Pull Request as a Draft. #### Examples diff --git a/src/dwh2looker/cli/commands.py b/src/dwh2looker/cli/commands.py index de42330..9c2380b 100644 --- a/src/dwh2looker/cli/commands.py +++ b/src/dwh2looker/cli/commands.py @@ -77,6 +77,11 @@ def cli(): action="store_true", help="Push generated LookML to Looker via GitHub", ) + generate_lookml_parser.add_argument( + "--draft-pr", + action="store_true", + help="Create the Pull Request as a Draft", + ) args = parser.parse_args() if args.command == "diff_tracker": @@ -124,6 +129,7 @@ def cli(): push_lookml_to_looker=args.push_lookml_to_looker, github_token=args.token, github_app=args.github_app, + draft_pr=args.draft_pr, ) lookml.generate_batch_lookml_views( override_dataset_id=args.override_dataset_id, diff --git a/src/dwh2looker/lookml_generator/lookml_generator.py b/src/dwh2looker/lookml_generator/lookml_generator.py index f157dc5..4e8e47f 100644 --- a/src/dwh2looker/lookml_generator/lookml_generator.py +++ b/src/dwh2looker/lookml_generator/lookml_generator.py @@ -31,11 +31,13 @@ def __init__( push_lookml_to_looker: bool = False, github_token: str = None, github_app: bool = False, + draft_pr: bool = False, ): self.db_type = db_type self.push_lookml_to_looker = push_lookml_to_looker self.github_token = github_token self.github_app = github_app + self.draft_pr = draft_pr self.config = Config(os.getenv("dwh2looker_CONFIG_FILE")) self.primary_key_prefixes = self.config.get_property("primary_key_prefixes", []) self.foreign_key_prefixes = self.config.get_property( @@ -392,6 +394,7 @@ def _push_lookml_to_repo(self): target_branch=branch_name, pr_title="dwh2looker ʕ•ᴥ•ʔ: Automated LookML Update", pr_body="This PR was automatically generated by dwh2looker the bear. Please review before merging, bears are bears after all.", + draft=self.draft_pr, ) def generate_batch_lookml_views(self, override_dataset_id: str = None): diff --git a/src/dwh2looker/vc_client/vc_client.py b/src/dwh2looker/vc_client/vc_client.py index 53718fe..98f858c 100644 --- a/src/dwh2looker/vc_client/vc_client.py +++ b/src/dwh2looker/vc_client/vc_client.py @@ -172,7 +172,7 @@ def update_files( return def create_pull_request( - self, base_branch: str, target_branch: str, pr_title: str, pr_body: str + self, base_branch: str, target_branch: str, pr_title: str, pr_body: str, draft: bool = False ): # Create a pull request if it does not exist pulls = self.repo.get_pulls(state="open", sort="created", base=base_branch) @@ -188,7 +188,7 @@ def create_pull_request( body=pr_body, base=base_branch, head=f"{target_branch}", - draft=True, + draft=draft, ) CONSOLE_LOGGER.info(f"Pull request created: {pull_request.html_url}") From 391ccf3c5a2f2d1fcea608579582578f5da0548e Mon Sep 17 00:00:00 2001 From: yousefsalhamoud Date: Fri, 13 Mar 2026 14:18:14 +0100 Subject: [PATCH 2/3] pre-commit run --- .github/pull_request_template.md | 2 +- .github/workflows/ci.yaml | 2 +- CONTRIBUTING.md | 2 +- readme.md | 6 +++--- src/dwh2looker/vc_client/vc_client.py | 7 ++++++- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index c7e662c..b110062 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -25,4 +25,4 @@ Fixes # (issue) - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings (I have run `ruff check .` and `ruff format .`) - [ ] I have added tests that prove my fix is effective or that my feature works -- [ ] New and existing unit tests pass locally with my changes \ No newline at end of file +- [ ] New and existing unit tests pass locally with my changes diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 191fce2..9b2548c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -37,4 +37,4 @@ jobs: python -m pip install --upgrade pip pip install .[all] - name: Run tests - run: pytest \ No newline at end of file + run: pytest diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d1f80a3..ad67933 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -74,4 +74,4 @@ Currently, we strongly support Google BigQuery. If you want to add support for S 2. You will need to implement a new client class that inherits from the base class or implements the necessary interface to extract schema information. 3. Ensure you add the necessary dependencies to `pyproject.toml` as optional dependencies. -Thank you for contributing! \ No newline at end of file +Thank you for contributing! diff --git a/readme.md b/readme.md index 4dec9fd..792d63c 100644 --- a/readme.md +++ b/readme.md @@ -110,7 +110,7 @@ Example `tables_env` configuration for Workload Identity in GitHub Actions: "env": "cprod", "dataset_id": "dataset_id", "project_id": "project_id", - "credentials_path": "./gcp_creds_cprod.json" + "credentials_path": "./gcp_creds_cprod.json" }, { "env": "prod", @@ -163,7 +163,7 @@ Example `tables_env` configuration for Workload Identity in GitHub Actions: "env": "cprod", "dataset_id": "dataset_id", "project_id": "project_id", - "credentials_path": "./gcp_creds_cprod.json" + "credentials_path": "./gcp_creds_cprod.json" }, { "env": "prod", @@ -265,4 +265,4 @@ We welcome contributions to dwh2looker! Please see our [Contributing Guide](CONT --- -dwh2looker was inspired by Optician \ No newline at end of file +dwh2looker was inspired by Optician diff --git a/src/dwh2looker/vc_client/vc_client.py b/src/dwh2looker/vc_client/vc_client.py index 98f858c..23a60c4 100644 --- a/src/dwh2looker/vc_client/vc_client.py +++ b/src/dwh2looker/vc_client/vc_client.py @@ -172,7 +172,12 @@ def update_files( return def create_pull_request( - self, base_branch: str, target_branch: str, pr_title: str, pr_body: str, draft: bool = False + self, + base_branch: str, + target_branch: str, + pr_title: str, + pr_body: str, + draft: bool = False, ): # Create a pull request if it does not exist pulls = self.repo.get_pulls(state="open", sort="created", base=base_branch) From 23356fb7d3409956a5832548a2be0c60989a0fa7 Mon Sep 17 00:00:00 2001 From: yousefsalhamoud Date: Fri, 13 Mar 2026 14:21:17 +0100 Subject: [PATCH 3/3] fix precommit to not affect templates --- .pre-commit-config.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 479782b..3e2265a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,9 @@ repos: rev: v4.5.0 hooks: - id: trailing-whitespace + exclude: ^src/dwh2looker/lookml_generator/templates/ - id: end-of-file-fixer + exclude: ^src/dwh2looker/lookml_generator/templates/ - id: check-yaml - id: check-added-large-files @@ -13,5 +15,7 @@ repos: # Run the linter. - id: ruff args: [ --fix ] + exclude: ^src/dwh2looker/lookml_generator/templates/ # Run the formatter. - id: ruff-format + exclude: ^src/dwh2looker/lookml_generator/templates/