From e0996c20cdf12462884f1d8df606161dc91ebb8f Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 3 Jan 2024 11:30:54 -0500 Subject: [PATCH] =?UTF-8?q?Bqetl=20on=20rich-cli=20=E2=9C=A8=F0=9F=92=B8?= =?UTF-8?q?=20(#3775)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bigquery_etl/cli/__init__.py | 2 +- bigquery_etl/cli/alchemer.py | 2 +- bigquery_etl/cli/dag.py | 2 +- bigquery_etl/cli/dryrun.py | 2 +- bigquery_etl/cli/format.py | 2 +- bigquery_etl/cli/generate.py | 2 +- bigquery_etl/cli/query.py | 2 +- bigquery_etl/cli/routine.py | 2 +- bigquery_etl/cli/stage.py | 2 +- bigquery_etl/cli/view.py | 2 +- bigquery_etl/dependency.py | 2 +- bigquery_etl/docs/__init__.py | 2 +- bigquery_etl/glam/cli.py | 2 +- bigquery_etl/static.py | 2 +- bigquery_etl/stripe/__init__.py | 2 +- bigquery_etl/subplat/apple.py | 2 +- requirements.in | 1 + requirements.txt | 45 ++++++++++++++++++++++++++++----- tests/test_entrypoint.py | 2 +- 19 files changed, 56 insertions(+), 24 deletions(-) diff --git a/bigquery_etl/cli/__init__.py b/bigquery_etl/cli/__init__.py index 9d83a5424b..df078bbbf6 100644 --- a/bigquery_etl/cli/__init__.py +++ b/bigquery_etl/cli/__init__.py @@ -4,7 +4,7 @@ import logging import warnings from pathlib import Path -import click +import rich_click as click from .._version import __version__ diff --git a/bigquery_etl/cli/alchemer.py b/bigquery_etl/cli/alchemer.py index b6b605ba45..5e881bbe72 100644 --- a/bigquery_etl/cli/alchemer.py +++ b/bigquery_etl/cli/alchemer.py @@ -1,7 +1,7 @@ """bigquery-etl CLI alchemer command.""" from datetime import date, datetime, timedelta -import click +import rich_click as click from bigquery_etl.alchemer.survey import get_survey_data, insert_to_bq diff --git a/bigquery_etl/cli/dag.py b/bigquery_etl/cli/dag.py index b02adb513a..39b9cdfec0 100644 --- a/bigquery_etl/cli/dag.py +++ b/bigquery_etl/cli/dag.py @@ -4,7 +4,7 @@ import os import sys from pathlib import Path -import click +import rich_click as click import yaml from ..cli.utils import is_valid_dir, is_valid_file, sql_dir_option diff --git a/bigquery_etl/cli/dryrun.py b/bigquery_etl/cli/dryrun.py index 671f630ca8..3eae6ceaf0 100644 --- a/bigquery_etl/cli/dryrun.py +++ b/bigquery_etl/cli/dryrun.py @@ -9,7 +9,7 @@ from functools import partial from multiprocessing.pool import Pool from typing import List, Set -import click +import rich_click as click from google.cloud import bigquery from ..cli.utils import is_authenticated diff --git a/bigquery_etl/cli/format.py b/bigquery_etl/cli/format.py index 1635f79063..90d5be46bb 100644 --- a/bigquery_etl/cli/format.py +++ b/bigquery_etl/cli/format.py @@ -1,6 +1,6 @@ """bigquery-etl CLI format command.""" -import click +import rich_click as click from bigquery_etl.format_sql.format import format as format_sql diff --git a/bigquery_etl/cli/generate.py b/bigquery_etl/cli/generate.py index 8223b71940..9a13ba676c 100644 --- a/bigquery_etl/cli/generate.py +++ b/bigquery_etl/cli/generate.py @@ -3,7 +3,7 @@ import importlib.util from inspect import getmembers from pathlib import Path -import click +import rich_click as click from bigquery_etl.cli.utils import is_valid_project, use_cloud_function_option from bigquery_etl.config import ConfigLoader diff --git a/bigquery_etl/cli/query.py b/bigquery_etl/cli/query.py index 6d118d9755..079eb8ae76 100644 --- a/bigquery_etl/cli/query.py +++ b/bigquery_etl/cli/query.py @@ -18,7 +18,7 @@ from pathlib import Path from tempfile import NamedTemporaryFile from traceback import print_exc -import click +import rich_click as click import yaml from dateutil.rrule import MONTHLY, rrule from google.cloud import bigquery diff --git a/bigquery_etl/cli/routine.py b/bigquery_etl/cli/routine.py index e7bba24902..f4390418ca 100644 --- a/bigquery_etl/cli/routine.py +++ b/bigquery_etl/cli/routine.py @@ -9,8 +9,8 @@ import sys from fnmatch import fnmatchcase from pathlib import Path -import click import pytest +import rich_click as click import yaml from ..cli.format import format diff --git a/bigquery_etl/cli/stage.py b/bigquery_etl/cli/stage.py index 43d373d8be..ec62798136 100644 --- a/bigquery_etl/cli/stage.py +++ b/bigquery_etl/cli/stage.py @@ -7,7 +7,7 @@ from datetime import datetime from multiprocessing.pool import ThreadPool from pathlib import Path -import click +import rich_click as click from google.cloud import bigquery from ..cli.query import deploy as deploy_query_schema diff --git a/bigquery_etl/cli/view.py b/bigquery_etl/cli/view.py index d1fc78b986..5132fbcea2 100644 --- a/bigquery_etl/cli/view.py +++ b/bigquery_etl/cli/view.py @@ -8,7 +8,7 @@ from graphlib import TopologicalSorter from multiprocessing.pool import Pool, ThreadPool from traceback import print_exc -import click +import rich_click as click from ..cli.utils import ( no_dryrun_option, diff --git a/bigquery_etl/dependency.py b/bigquery_etl/dependency.py index d16b3ee3f6..2762901f8a 100644 --- a/bigquery_etl/dependency.py +++ b/bigquery_etl/dependency.py @@ -7,7 +7,7 @@ from pathlib import Path from subprocess import CalledProcessError from typing import Dict, Iterator, List, Tuple -import click +import rich_click as click import sqlglot import yaml diff --git a/bigquery_etl/docs/__init__.py b/bigquery_etl/docs/__init__.py index b68ca00011..772f52e4ca 100644 --- a/bigquery_etl/docs/__init__.py +++ b/bigquery_etl/docs/__init__.py @@ -7,7 +7,7 @@ import sys import tempfile from pathlib import Path -import click +import rich_click as click from bigquery_etl.config import ConfigLoader from bigquery_etl.dryrun import DryRun diff --git a/bigquery_etl/glam/cli.py b/bigquery_etl/glam/cli.py index 2dd3257ba9..dd525fa33b 100644 --- a/bigquery_etl/glam/cli.py +++ b/bigquery_etl/glam/cli.py @@ -2,7 +2,7 @@ import os from pathlib import Path -import click +import rich_click as click import yaml from google.cloud import bigquery diff --git a/bigquery_etl/static.py b/bigquery_etl/static.py index 07a114c2fd..62559e4c61 100644 --- a/bigquery_etl/static.py +++ b/bigquery_etl/static.py @@ -6,7 +6,7 @@ import json import logging import os -import click +import rich_click as click from google.cloud import bigquery from bigquery_etl.cli.utils import project_id_option diff --git a/bigquery_etl/stripe/__init__.py b/bigquery_etl/stripe/__init__.py index 5cd23fac30..0674bbcc3b 100644 --- a/bigquery_etl/stripe/__init__.py +++ b/bigquery_etl/stripe/__init__.py @@ -9,8 +9,8 @@ from tempfile import TemporaryFile from time import sleep from typing import Any, Dict, List, Optional -import click import requests +import rich_click as click import stripe import ujson from dateutil.relativedelta import relativedelta diff --git a/bigquery_etl/subplat/apple.py b/bigquery_etl/subplat/apple.py index e62c299374..200b7ce4da 100644 --- a/bigquery_etl/subplat/apple.py +++ b/bigquery_etl/subplat/apple.py @@ -9,8 +9,8 @@ from io import BytesIO from tempfile import TemporaryFile from typing import Optional -import click import requests +import rich_click as click from authlib.jose import jwt from google.cloud import bigquery diff --git a/requirements.in b/requirements.in index 3dc596cec2..cd785b3f02 100644 --- a/requirements.in +++ b/requirements.in @@ -33,6 +33,7 @@ pytest-pydocstyle==2.3.2 pytest-xdist==3.3.1 pytest==7.4.3 PyYAML==6.0.1 +rich-click==1.7.2 smart_open==6.4.0 sqlglot==20.4.0 sqlparse==0.4.4 diff --git a/requirements.txt b/requirements.txt index 8eb4e9404b..40605b43e3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -246,6 +246,7 @@ click==8.1.7 \ # mozilla-metric-config-parser # mozilla-schema-generator # pip-tools + # rich-click colorama==0.4.6 \ --hash=sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44 \ --hash=sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6 @@ -466,6 +467,7 @@ google-api-core[grpc]==2.11.0 \ --hash=sha256:4b9bb5d5a380a0befa0573b302651b8a9a89262c1730e37bf423cec511804c22 \ --hash=sha256:ce222e27b0de0d7bc63eb043b956996d6dccab14cc3b690aaea91c9cc99dc16e # via + # google-api-core # google-cloud-bigquery # google-cloud-bigquery-storage # google-cloud-core @@ -700,6 +702,10 @@ markdown-include==0.8.1 \ --hash=sha256:1d0623e0fc2757c38d35df53752768356162284259d259c486b4ab6285cdbbe3 \ --hash=sha256:32f0635b9cfef46997b307e2430022852529f7a5b87c0075c504283e7cc7db53 # via -r requirements.in +markdown-it-py==3.0.0 \ + --hash=sha256:355216845c60bd96232cd8d8c40e8f9765cc86f46880e43a8fd22dc1a1a8cab1 \ + --hash=sha256:e3f60a94fa066dc52ec76661e37c851cb232d92f9886b15cb560aaada2df8feb + # via rich markupsafe==2.1.2 \ --hash=sha256:0576fe974b40a400449768941d5d0858cc624e3249dfd1e0c33674e5c7ca7aed \ --hash=sha256:085fd3201e7b12809f9e6e9bc1e5c96a368c8523fad5afb02afe3c051ae4afcc \ @@ -758,6 +764,10 @@ mccabe==0.6.1 \ --hash=sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42 \ --hash=sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f # via flake8 +mdurl==0.1.2 \ + --hash=sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8 \ + --hash=sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba + # via markdown-it-py mdx-truly-sane-lists==1.3 \ --hash=sha256:b661022df7520a1e113af7c355c62216b384c867e4f59fb8ee7ad511e6e77f45 \ --hash=sha256:b9546a4c40ff8f1ab692f77cee4b6bfe8ddf9cccf23f0a24e71f3716fe290a37 @@ -1192,7 +1202,9 @@ pyflakes==2.4.0 \ pygments==2.16.1 \ --hash=sha256:13fc09fa63bc8d8671a6d247e1eb303c4b343eaee81d861f3404db2935653692 \ --hash=sha256:1daff0494820c69bc8941e407aa20f577374ee88364ee10a98fdbe0aece96e29 - # via mkdocs-material + # via + # mkdocs-material + # rich pymdown-extensions==10.3 \ --hash=sha256:77a82c621c58a83efc49a389159181d570e370fff9f810d3a4766a75fc678b66 \ --hash=sha256:94a0d8a03246712b64698af223848fd80aaf1ae4c4be29c8c61939b0467b5722 @@ -1253,7 +1265,9 @@ pytz==2022.7.1 \ # mozilla-metric-config-parser # pandas pyyaml==6.0.1 \ + --hash=sha256:04ac92ad1925b2cff1db0cfebffb6ffc43457495c9b3c39d3fcae417d7125dc5 \ --hash=sha256:062582fca9fabdd2c8b54a3ef1c978d786e0f6b3a1510e0ac93ef59e0ddae2bc \ + --hash=sha256:0d3304d8c0adc42be59c5f8a4d9e3d7379e6955ad754aa9d6ab7a398b59dd1df \ --hash=sha256:1635fd110e8d85d55237ab316b5b011de701ea0f29d07611174a1b42f1444741 \ --hash=sha256:184c5108a2aca3c5b3d3bf9395d50893a7ab82a38004c8f61c258d4428e80206 \ --hash=sha256:18aeb1bf9a78867dc38b259769503436b7c72f7a1f1f4c93ff9a17de54319b27 \ @@ -1261,7 +1275,10 @@ pyyaml==6.0.1 \ --hash=sha256:1e2722cc9fbb45d9b87631ac70924c11d3a401b2d7f410cc0e3bbf249f2dca62 \ --hash=sha256:1fe35611261b29bd1de0070f0b2f47cb6ff71fa6595c077e42bd0c419fa27b98 \ --hash=sha256:28c119d996beec18c05208a8bd78cbe4007878c6dd15091efb73a30e90539696 \ + --hash=sha256:326c013efe8048858a6d312ddd31d56e468118ad4cdeda36c719bf5bb6192290 \ + --hash=sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9 \ --hash=sha256:42f8152b8dbc4fe7d96729ec2b99c7097d656dc1213a3229ca5383f973a5ed6d \ + --hash=sha256:49a183be227561de579b4a36efbb21b3eab9651dd81b1858589f796549873dd6 \ --hash=sha256:4fb147e7a67ef577a588a0e2c17b6db51dda102c71de36f8549b6816a96e1867 \ --hash=sha256:50550eb667afee136e9a77d6dc71ae76a44df8b3e51e41b77f6de2932bfe0f47 \ --hash=sha256:510c9deebc5c0225e8c96813043e62b680ba2f9c50a08d3724c7f28a747d1486 \ @@ -1269,9 +1286,12 @@ pyyaml==6.0.1 \ --hash=sha256:596106435fa6ad000c2991a98fa58eeb8656ef2325d7e158344fb33864ed87e3 \ --hash=sha256:6965a7bc3cf88e5a1c3bd2e0b5c22f8d677dc88a455344035f03399034eb3007 \ --hash=sha256:69b023b2b4daa7548bcfbd4aa3da05b3a74b772db9e23b982788168117739938 \ + --hash=sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0 \ --hash=sha256:704219a11b772aea0d8ecd7058d0082713c3562b4e271b849ad7dc4a5c90c13c \ --hash=sha256:7e07cbde391ba96ab58e532ff4803f79c4129397514e1413a7dc761ccd755735 \ --hash=sha256:81e0b275a9ecc9c0c0c07b4b90ba548307583c125f54d5b6946cfee6360c733d \ + --hash=sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28 \ + --hash=sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4 \ --hash=sha256:9046c58c4395dff28dd494285c82ba00b546adfc7ef001486fbf0324bc174fba \ --hash=sha256:9eb6caa9a297fc2c2fb8862bc5370d0303ddba53ba97e71f08023b6cd73d16a8 \ --hash=sha256:a0cd17c15d3bb3fa06978b4e8958dcdc6e0174ccea823003a106c7d4d7899ac5 \ @@ -1286,7 +1306,9 @@ pyyaml==6.0.1 \ --hash=sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43 \ --hash=sha256:c8098ddcc2a85b61647b2590f825f3db38891662cfc2fc776415143f599bb859 \ --hash=sha256:d2b04aac4d386b172d5b9692e2d2da8de7bfb6c387fa4f801fbf6fb2e6ba4673 \ + --hash=sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54 \ --hash=sha256:d858aa552c999bc8a8d57426ed01e40bef403cd8ccdd0fc5f6f04a00414cac2a \ + --hash=sha256:e7d73685e87afe9f3b36c799222440d6cf362062f78be1013661b00c5c6f678b \ --hash=sha256:f003ed9ad21d6a4713f0a9b5a7a0a79e08dd0f221aff4525a2be4c346ee60aab \ --hash=sha256:f22ac1c3cac4dbc50079e965eba2c1058622631e526bd9afd45fedd49ba781fa \ --hash=sha256:faca3bdcf85b2fc05d06ff3fbc1f83e1391b3e724afa3feba7d13eeab355484c \ @@ -1418,6 +1440,14 @@ requests-oauthlib==1.3.1 \ --hash=sha256:2577c501a2fb8d05a304c09d090d6e47c306fef15809d102b327cf8364bddab5 \ --hash=sha256:75beac4a47881eeb94d5ea5d6ad31ef88856affe2332b9aafb52c6452ccf0d7a # via google-auth-oauthlib +rich==13.7.0 \ + --hash=sha256:5cb5123b5cf9ee70584244246816e9114227e0b98ad9176eede6ad54bf5403fa \ + --hash=sha256:6da14c108c4866ee9520bbffa71f6fe3962e193b7da68720583850cd4548e235 + # via rich-click +rich-click==1.7.2 \ + --hash=sha256:22f93439a3d65f4a04e07cd584f4d01d132d96899766af92ed287618156abbe2 \ + --hash=sha256:a42bcdcb8696c4ca7a3b1a39e1aba3d2cb64ad00690b4c022fdcb2cbccebc3fc + # via -r requirements.in rpds-py==0.8.10 \ --hash=sha256:08166467258fd0240a1256fce272f689f2360227ee41c72aeea103e9e4f63d2b \ --hash=sha256:083df0fafe199371206111583c686c985dddaf95ab3ee8e7b24f1fda54515d09 \ @@ -1618,6 +1648,7 @@ typing-extensions==4.4.0 \ # mypy # polyfactory # pydantic + # rich-click # stripe tzdata==2023.3 \ --hash=sha256:11ef1e08e54acb0d4f95bdb1be05da659673de4acbd21bf9c69e94cc5e907a3a \ @@ -1816,13 +1847,13 @@ yarl==1.8.2 \ # via aiohttp # The following packages are considered to be unsafe in a requirements file: -pip==23.3 \ - --hash=sha256:bb7d4f69f488432e4e96394612f43ab43dd478d073ef7422604a570f7157561e \ - --hash=sha256:bc38bb52bc286514f8f7cb3a1ba5ed100b76aaef29b521d48574329331c5ae7b +pip==23.3.2 \ + --hash=sha256:5052d7889c1f9d05224cd41741acb7c5d6fa735ab34e339624a614eaaa7e7d76 \ + --hash=sha256:7fd9972f96db22c8077a1ee2691b172c8089b17a5652a44494a9ecb0d78f9149 # via pip-tools -setuptools==67.1.0 \ - --hash=sha256:a7687c12b444eaac951ea87a9627c4f904ac757e7abdc5aac32833234af90378 \ - --hash=sha256:e261cdf010c11a41cb5cb5f1bf3338a7433832029f559a6a7614bd42a967c300 +setuptools==69.0.3 \ + --hash=sha256:385eb4edd9c9d5c17540511303e39a147ce2fc04bc55289c322b9e5904fe2c05 \ + --hash=sha256:be1af57fc409f93647f2e8e4573a142ed38724b8cdd389706a867bb4efcf1e78 # via # nodeenv # pip-tools diff --git a/tests/test_entrypoint.py b/tests/test_entrypoint.py index 438c731ed1..2f05d8cd05 100644 --- a/tests/test_entrypoint.py +++ b/tests/test_entrypoint.py @@ -137,4 +137,4 @@ class TestEntrypoint: check=True, capture_output=True, ) - assert b"No queries matching" in e.value.stderr + assert b"No queries matching" in e.value.stderr