Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
- [ ] New and existing unit tests pass locally with my changes
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ jobs:
python -m pip install --upgrade pip
pip install .[all]
- name: Run tests
run: pytest
run: pytest
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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/
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Thank you for contributing!
7 changes: 4 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand All @@ -264,4 +265,4 @@ We welcome contributions to dwh2looker! Please see our [Contributing Guide](CONT

---

dwh2looker was inspired by Optician
dwh2looker was inspired by Optician
6 changes: 6 additions & 0 deletions src/dwh2looker/cli/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions src/dwh2looker/lookml_generator/lookml_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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):
Expand Down
9 changes: 7 additions & 2 deletions src/dwh2looker/vc_client/vc_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
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)
Expand All @@ -188,7 +193,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}")

Expand Down
Loading