Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI to Compare and Apply Configs, Base Datasource Feature Additions #92

Draft
wants to merge 53 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
aaf7a63
add where functions go
jaybythebay May 31, 2024
6478902
bump version to include in 2.2.12
jaybythebay Jun 2, 2024
1645ec2
removing empty folder works
jaybythebay Jun 2, 2024
d1f664d
mock test works
jaybythebay Jun 2, 2024
8de989c
3 tests passed
jaybythebay Jun 2, 2024
a747c19
rename
jaybythebay Jun 2, 2024
de1ade3
rename
jaybythebay Jun 2, 2024
803aeed
add new testing to the ci
jaybythebay Jun 2, 2024
acc1d27
move generate config dics to their own function to make it resuavble
jaybythebay Jun 2, 2024
20daaf7
add comments and delete duplicate code
jaybythebay Jun 2, 2024
292546c
getting args validation error as expected
jaybythebay Jun 2, 2024
57e63a8
wip
jaybythebay Jun 2, 2024
835402b
Move column_init to finction
jaybythebay Jun 3, 2024
71559be
clean comments and docs
jaybythebay Jun 3, 2024
0924b79
define color and symbols as globals so it will all work in functions
jaybythebay Jun 3, 2024
1b774f9
define color and symbols as globals so it will all work in functions …
jaybythebay Jun 3, 2024
ccb8c59
more code
jaybythebay Jun 4, 2024
779781d
Clean naming
jaybythebay Jun 4, 2024
10921fe
Add lots of stuff
jaybythebay Jun 4, 2024
9c2c5cc
passing tests and printing the number of tests to console
jaybythebay Jun 4, 2024
04ffd52
works with typing
jaybythebay Jun 4, 2024
0582861
invert configs working with typing
jaybythebay Jun 4, 2024
5f56687
invert configs working with typing
jaybythebay Jun 4, 2024
30cb25e
invert configs working with typing
jaybythebay Jun 4, 2024
f49bc3e
still getting attribute errors:
jaybythebay Jun 4, 2024
856aba0
ignoring getting that test to work for now
jaybythebay Jun 4, 2024
ebd6e96
WIP
jaybythebay Jun 4, 2024
ceed55d
readme and wip
jaybythebay Aug 11, 2024
1a0bf36
read the files
jaybythebay Aug 11, 2024
2de0544
combined the configs:
jaybythebay Aug 11, 2024
2d0133e
getting attribute error on the test but otherwise seems ok
jaybythebay Aug 11, 2024
93264e5
got changes list:
jaybythebay Aug 11, 2024
f6e50c3
working on the executre:
jaybythebay Aug 11, 2024
7b82ed6
added execute
jaybythebay Aug 12, 2024
e759932
run execute
jaybythebay Aug 12, 2024
edca368
looks like it ran:
jaybythebay Aug 12, 2024
d7d4e60
Edited the file
jaybythebay Aug 12, 2024
d56bb4a
altering the file
jaybythebay Aug 12, 2024
b6c0124
fixed tests - 6 passing
jaybythebay Aug 17, 2024
165ea75
fixed datasouce select test
jaybythebay Aug 17, 2024
fef03fc
spacing
jaybythebay Aug 17, 2024
2db4a56
prepare configs test
jaybythebay Aug 18, 2024
2fbdae8
add verbose logging to workflow
jaybythebay Aug 18, 2024
42c30ee
logging
jaybythebay Sep 10, 2024
0a6a6dd
adjusted the definitions mapping to match any locakl name
jaybythebay Sep 10, 2024
3fb502c
working
jaybythebay Sep 10, 2024
ffea88a
comments
jaybythebay Sep 11, 2024
a7657ae
passing in empty config to debug
jaybythebay Sep 11, 2024
69e096f
handle empty calculation set
jaybythebay Sep 11, 2024
f93df65
something
jaybythebay Sep 20, 2024
9233293
working again. Edge case of generated names = target config but there…
jaybythebay Sep 20, 2024
f89aa67
fixed the oauth-config-id error
jaybythebay Oct 30, 2024
937a3bb
Merge pull request #17 from jaybythebay/compare-configs-oauth
jaybythebay Oct 30, 2024
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
4 changes: 4 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ jobs:
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Run Pytest on the tests in tests/
run:
pytest tests/ -p no:warnings -vv
- name: Run pytest on tableau-utilities
run: |
cd tableau_utilities && pytest -v

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ sheets.googleapis.com-python.json
.idea
.DS_Store
tmp_tdsx_and_config/
development_test_files/

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ This extra package depends on the tableauhyperapi which is incompatible with App
#### Locally using pip
- `cd tableau-utilities`
- `pip install ./`
- `pip install --upgrade ./` to overwrite the existing installation without having to uninstall first

#### Confirm installation
- `which tableau_utilities`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,54 +314,54 @@ def __compare_folders(self, datasource_id, tds_folders, cfg_folders):
def execute(self, context):
""" Update Tableau datasource according to config. """

github_conn = BaseHook.get_connection(self.github_conn_id)
config = cfg.Config(
githup_token=github_conn.password,
repo_name=github_conn.extra_dejson.get('repo_name'),
repo_branch=github_conn.extra_dejson.get('repo_branch'),
subfolder=github_conn.extra_dejson.get('subfolder')
)

ts = get_tableau_server(self.tableau_conn_id)
expected_conn_attrs = self.__set_connection_attributes()

# Get the ID for each datasource in the config
for ds in ts.get.datasources():
if ds not in config.datasources:
continue
config.datasources[ds].id = ds.id

for datasource in config.datasources:
if not datasource.id:
logging.error('!! Datasource not found in Tableau Online: %s / %s',
datasource.project_name, datasource.name)
continue
dsid = datasource.id
# github_conn = BaseHook.get_connection(self.github_conn_id)
# config = cfg.Config(
# githup_token=github_conn.password,
# repo_name=github_conn.extra_dejson.get('repo_name'),
# repo_branch=github_conn.extra_dejson.get('repo_branch'),
# subfolder=github_conn.extra_dejson.get('subfolder')
# )
#
# ts = get_tableau_server(self.tableau_conn_id)
# expected_conn_attrs = self.__set_connection_attributes()
#
# # Get the ID for each datasource in the config
# for ds in ts.get.datasources():
# if ds not in config.datasources:
# continue
# config.datasources[ds].id = ds.id
#
# # for datasource in config.datasources:
# if not datasource.id:
# logging.error('!! Datasource not found in Tableau Online: %s / %s',
# datasource.project_name, datasource.name)
# continue
# dsid = datasource.id
# Set default dict attributes for tasks, for each datasource
self.tasks[dsid] = {a: [] for a in UPDATE_ACTIONS}
self.tasks[dsid]['project'] = datasource.project_name
self.tasks[dsid]['datasource_name'] = datasource.name
if not config.in_maintenance_window and AIRFLOW_ENV not in ['STAGING', 'DEV']:
self.tasks[dsid]['skip'] = 'Outside maintenance window'
logging.info('(SKIP) Outside maintenance window: %s', datasource.name)
continue
elif datasource.name in EXCLUDED_DATASOURCES:
self.tasks[dsid]['skip'] = 'Marked to exclude'
logging.info('(SKIP) Marked to exclude: %s', datasource.name)
continue
logging.info('Checking Datasource: %s', datasource.name)
# Download the Datasource for comparison
dl_path = f"downloads/{dsid}/"
os.makedirs(dl_path, exist_ok=True)
ds_path = ts.download.datasource(dsid, file_dir=dl_path, include_extract=False)
tds = Datasource(ds_path)
# Cleanup downloaded file after assigning the Datasource
shutil.rmtree(dl_path, ignore_errors=True)
# Add connection task, if there is a difference
self.__compare_connection(dsid, datasource.name, tds.connection, expected_conn_attrs)
# Add folder tasks, if folders need to be added/deleted
self.__compare_folders(dsid, tds.folders_common, datasource.folders)
# Add Column tasks, if there are missing columns, or columns need to be updated
# if not config.in_maintenance_window and AIRFLOW_ENV not in ['STAGING', 'DEV']:
# self.tasks[dsid]['skip'] = 'Outside maintenance window'
# logging.info('(SKIP) Outside maintenance window: %s', datasource.name)
# continue
# elif datasource.name in EXCLUDED_DATASOURCES:
# self.tasks[dsid]['skip'] = 'Marked to exclude'
# logging.info('(SKIP) Marked to exclude: %s', datasource.name)
# continue
# logging.info('Checking Datasource: %s', datasource.name)
# # Download the Datasource for comparison
# dl_path = f"downloads/{dsid}/"
# os.makedirs(dl_path, exist_ok=True)
# ds_path = ts.download.datasource(dsid, file_dir=dl_path, include_extract=False)
# tds = Datasource(ds_path)
# # Cleanup downloaded file after assigning the Datasource
# shutil.rmtree(dl_path, ignore_errors=True)
# # Add connection task, if there is a difference
# self.__compare_connection(dsid, datasource.name, tds.connection, expected_conn_attrs)
# # Add folder tasks, if folders need to be added/deleted
# self.__compare_folders(dsid, tds.folders_common, datasource.folders)
# # Add Column tasks, if there are missing columns, or columns need to be updated
for column in datasource.columns:
# Check if the column metadata needs to be updated
self.__compare_column_metadata(dsid, tds, column)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
long_description=readme,
long_description_content_type='text/markdown',
name="tableau_utilities",
version="2.2.11",
version="2.2.12",
requires_python=">=3.8",
packages=[
'tableau_utilities',
Expand Down
Loading