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 27 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 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
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
Prev Previous commit
Next Next commit
passing tests and printing the number of tests to console
  • Loading branch information
jaybythebay committed Jun 4, 2024
commit 9c2c5cc6d7eb143660c9c451f75237b068823ea3
39 changes: 26 additions & 13 deletions tableau_utilities/scripts/apply_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,38 @@
from tableau_utilities.tableau_file.tableau_file import Datasource
from tableau_utilities.scripts.gen_config import build_configs
from tableau_utilities.scripts.datasource import add_metadata_records_as_columns
#
# class ApplyConfigs:
# """Applies a set of configs to a datasource. Configs prefixed with target_ will be applied to the datasource.
# Configs prefixed with datasource_ represent the current state of the datasource before changes.
# """
#
# def __init__(self,
# datasource_name: str,
# datasource_path: str,
# target_column_config: Dict[str, Any],
# target_calculated_column_config: Dict[str, Any],
# debugging_logs: bool) -> None:
# self.datasource_name: str = datasource_name
# self.datasource_path: str = datasource_path
# self.target_column_config: Dict[str, Any] = target_column_config
# self.target_calculated_column_config: Dict[str, Any] = target_calculated_column_config
# self.debugging_logs: bool = debugging_logs

class ApplyConfigs:
"""Applies a set of configs to a datasource. Configs prefixed with target_ will be applied to the datasource.
Configs prefixed with datasource_ represent the current state of the datasource before changes.
"""

def __init__(self,
datasource_name: str,
datasource_path: str,
target_column_config: Dict[str, Any],
target_calculated_column_config: Dict[str, Any],
debugging_logs: bool) -> None:
self.datasource_name: str = datasource_name
self.datasource_path: str = datasource_path
self.target_column_config: Dict[str, Any] = target_column_config
self.target_calculated_column_config: Dict[str, Any] = target_calculated_column_config
self.debugging_logs: bool = debugging_logs

def invert_config(self, config: Dict[str, Any]) -> Dict[str, Any]:
def __init__(self, datasource_name, datasource_path, target_column_config, target_calculated_column_config, debugging_logs):
self.datasource_name = datasource_name
self.datasource_path = datasource_path
self.target_column_config = target_column_config
self.target_calculated_column_config = target_calculated_column_config
self.debugging_logs = debugging_logs

def invert_config(self, config):
# def invert_config(self, config: Dict[str, Any]) -> Dict[str, Any]:
"""Helper function to invert the column config and calc config.
Output -> {datasource: {column: info}}

Expand Down
25 changes: 25 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import pytest

file_test_count = {}

@pytest.hookimpl(tryfirst=True)
def pytest_sessionstart(session):
global file_test_count
file_test_count = {}

@pytest.hookimpl(tryfirst=True)
def pytest_runtestloop(session):
global file_test_count
for item in session.items:
file_path = str(item.fspath)
if file_path not in file_test_count:
file_test_count[file_path] = 0
file_test_count[file_path] += 1

@pytest.hookimpl(trylast=True)
def pytest_terminal_summary(terminalreporter, exitstatus):
terminalreporter.write_sep("=", "test count summary")
for file_path, count in file_test_count.items():
terminalreporter.write_line(f"{file_path}: {count} test(s)")
terminalreporter.write_line(f"Total number of test files: {len(file_test_count)}")
terminalreporter.write_line(f"Total number of tests: {sum(file_test_count.values())}")
Loading