Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/datakind/Data-Observation-Toolkit
/ functions
Functions
117 in github.com/datakind/Data-Observation-Toolkit
⨍
Functions
117
◇
Types & classes
16
↳
Endpoints
17
↓ 16 callers
Function
get_db_params_from_config
Parses dbt yaml file to get db credentials. Also substitutes environment variables. Parameters ---------- config_file: DbParamsConfig
dot/utils/connection_utils.py:98
↓ 7 callers
Function
setup_custom_logger
Sets up a custom logger which logs to file as well as console Parameters ---------- log_name : str Location of log file, eg './lo
dot/utils/utils.py:21
↓ 6 callers
Method
create_self_tests_db_schema
Creates the self tests' schema and runs the queries in `additional_query` if provided Parameters ----------
dot/self_tests/self_tests_utils/base_self_test_class.py:177
↓ 6 callers
Function
get_dbt_config_model_paths
Gets project-dependent path of `models-paths` (i.e. where DBT models are located) from dbt_project.yml config file items Parameter
dot/utils/configuration_utils.py:182
↓ 6 callers
Function
run_sub_process
Helper to run sub-process, sending output to logger. Parameters ---------- cmd : str Command to be run by subprocess, eg 'ls'
dot/utils/utils.py:73
↓ 5 callers
Function
_get_filename_safely
Internal function - checks if the path exists Parameters ---------- path : str path of the file Retu
dot/utils/configuration_utils.py:26
↓ 5 callers
Function
get_configured_tests_row
Gets the full row of configured_tests fields by finding the corresponding record in dot.configured_tests Parameters ---------- test_t
dot/utils/utils.py:199
↓ 5 callers
Method
get_self_tests_db_conn
Obtains the db connection for the self tests db Parameters ---------- mock_get_filename_safely connection: D
dot/self_tests/self_tests_utils/base_self_test_class.py:74
↓ 5 callers
Function
write_config_from_template
Writes a config file from a template
dot/utils/configuration_management.py:103
↓ 4 callers
Function
_get_test_type
Figures out test type from the dbt logs INTERNAL function, do not use Parameters ---------- node: dict json from dbt man
dot/utils/dbt_logs.py:97
↓ 4 callers
Function
format_uuid_list
formats the list of uuids if equals to a string of {'id1', 'id2'} gives back a list of ['id1', 'id2'] Parameters ---------- uuid
dot/utils/utils.py:749
↓ 4 callers
Function
get_dbt_config_custom_schema_output_objects
Get schema suffix for test objects generated by dbt Parameters ---------- dot_config : Optional[dict]
dot/utils/configuration_utils.py:246
↓ 4 callers
Function
get_test_rows
Generates a test_results dataframe using the test_summary dataframe and associated test results DB views Parameters ----------
dot/utils/utils.py:430
↓ 4 callers
Function
read_dbt_logs
Read generated json files. Assumes the cleanup has run and most recent results are in _archive files TODO maybe dbt output _test.json is
dot/utils/dbt_logs.py:27
↓ 3 callers
Function
_get_dbt_config_key
Gets key from dbt_project.yml config file items Converts the result from list to str, assuming the list has only one element Param
dot/utils/configuration_utils.py:216
↓ 3 callers
Method
drop_self_tests_db_schema
Drops the self tests' schema Parameters ---------- schema: str schema for self tests conn: Optio
dot/self_tests/self_tests_utils/base_self_test_class.py:105
↓ 3 callers
Method
get_test_summary
Get sample test summary DF + run id Returns ------- Tuple[pd.DataFrame, uuid.UUID] test_summary
dot/self_tests/unit/test_dot_utils.py:31
↓ 3 callers
Function
process_dbt_logs_row
Figures out parameters from each of the tests of the dbt output rows Parameters ---------- row: dict json from dbt logs & ma
dot/utils/dbt_logs.py:120
↓ 2 callers
Method
_cleanup_schema_name
Cleans up schema from self_tests_dot to dot
dot/self_tests/unit/test_dbt_logs_safe.py:31
↓ 2 callers
Function
_get_dbt_config_original_path
Gets original (i.e. project_independent) path of `key` (can be anything, but refers to either dbt models or tests) from dbt_project.yml confi
dot/utils/configuration_utils.py:268
↓ 2 callers
Function
_get_test_parameters
Figures out test parameters from the dbt logs INTERNAL function, do not use Parameters ---------- node: dict json from d
dot/utils/dbt_logs.py:58
↓ 2 callers
Function
add_ge_schema_parameters
Regardless of the parameters for any of the GE tests in db, some extra parameters for config need to be added,e.g. schema in which the core m
dot/utils/connection_utils.py:147
↓ 2 callers
Function
archive_previous_dbt_results
Archived previous dbt results Parameters ---------- logger : logger Logger
dot/utils/dbt.py:138
↓ 2 callers
Method
cleanup_dbt_output_dir
()
dot/self_tests/self_tests_utils/dbt_base_safe_test_class.py:21
↓ 2 callers
Function
create_core_entities
Reads configured_entities from the DOT schema and writes them as sql files for dbt Parameters ---------- schema_dot: str DOT
dot/utils/dbt.py:299
↓ 2 callers
Function
create_failed_dbt_test_models
Generates custom dbt models Parameters ---------- project_id : str Project id for run, eg 'Muso' logger : logger Logg
dot/utils/dbt.py:49
↓ 2 callers
Function
create_sqlalchemy_engine
Default configs for creating engine Parameters ---------- db_credentials : dict db credentials dictiontay Returns --
dot/utils/connection_utils.py:43
↓ 2 callers
Function
extract_dbt_config_env_variable
Takes a dbt config file and replaces any environment variable syntax with the environment variable. Syntax looks like this ... pass: "{{ env_
dot/utils/configuration_management.py:80
↓ 2 callers
Function
extract_df_from_dbt_test_results_json
Function to parse GE csv results file (that was created by parse_results) to form a test_summaries standard dataframe. Parameters
dot/utils/dbt.py:218
↓ 2 callers
Function
generate_row_results_df
Generates a test_results dataframe, one row per row of data tested Parameters ---------- id_column_values : list List of values f
dot/utils/utils.py:315
↓ 2 callers
Function
generate_tests_from_db
Function to generate dbt test yml files and Great Expectation .json files based on the contents of database table dot.configured_tests. Par
dot/utils/configuration_management.py:226
↓ 2 callers
Function
get_dbt_config_test_paths
Gets project-dependent path of `tests-paths` (i.e. where DBT tests are located) from dbt_project.yml config file items Parameters
dot/utils/configuration_utils.py:199
↓ 2 callers
Method
get_queries_from_file
Gets queries from file Parameters ---------- f: file file object schema: str schema
dot/self_tests/self_tests_utils/base_self_test_class.py:152
↓ 2 callers
Function
get_short_test_name
Figures out a human readable test_name, and a shorten version that can become a view name Parameters ---------- node : dict D
dot/utils/utils.py:101
↓ 2 callers
Function
get_test_id
Generates test UUID based on configured_test fields by finding the corresponding record in dot.configured_tests Parameters ----------
dot/utils/utils.py:161
↓ 2 callers
Function
get_view_definition
Figures out the view definition of a failing test Parameters ---------- project_id: str e.g. Muso, for obtaining credentials
dot/utils/dbt.py:193
↓ 2 callers
Function
load_config_file
Reads config file safely Returns ------- config: str content of config file
dot/utils/configuration_utils.py:112
↓ 2 callers
Function
load_credentials
Loads credentials and transforms password for project id and connection Parameters ---------- project_id : str
dot/utils/configuration_utils.py:92
↓ 2 callers
Function
parse_unexpected_list
Converts a pandas Series or a string representation into a list, or pass on the list if it already was one. This is to make sure we can read the r
dot/utils/great_expectations.py:92
↓ 2 callers
Method
prepare_failing_test_view
()
dot/self_tests/unit/test_dot_utils.py:57
↓ 2 callers
Function
print_test_results_for_df
(df, title="")
dot/utils/utils.py:707
↓ 2 callers
Function
remove_ge_schema_parameters
Remove extra paramets added by `add_ge_schema_parameters` so that test parameters correspond to the ones stored in the DOT configuration data
dot/utils/connection_utils.py:198
↓ 2 callers
Function
run_dbt_core
Runs the main set of dbt tests as defined (generated from db) in dbt/core/*.yml Parameters ---------- logger : logger Logger
dot/utils/dbt.py:30
↓ 2 callers
Function
run_dbt_test
Runs dbt custom sql tests Parameters ---------- logger : logger Logger
dot/utils/dbt.py:155
↓ 2 callers
Function
run_dot_tests
Wrapper around the DOT pipeline which will set status, start and end times in dot.run_status. Also catches exception and updates dot.run_log t
dot/utils/run_management.py:142
↓ 2 callers
Function
save_tests_to_db
Saves test results to the DOT DB into dot.test_results. Parameters ---------- test_rows : Pandas dataframe Dataframe of test resu
dot/utils/utils.py:272
↓ 1 callers
Function
_get_credentials
Internal function - gets credentials either for the project or the DOT Parameters ---------- db_config : dict
dot/utils/configuration_utils.py:44
↓ 1 callers
Function
adapt_core_entities
Adapts core entities definition to point the schema Jinja statement to the project schema Parameters ---------- schema_project:
dot/utils/configuration_utils.py:293
↓ 1 callers
Method
check_output_recursive
check outputs recursively for dbt logs
dot/self_tests/unit/test_dbt_logs_safe.py:37
↓ 1 callers
Function
create_project_directories
Function to generate project_directories if they don't exist. Creates ... |dot | | config | | |<project_id> | | | | dbt
dot/utils/configuration_management.py:31
↓ 1 callers
Function
create_views
Creates a failed tests view for Great Expectations tests Parameters ---------- project_id: str Current run project ID
dot/utils/great_expectations.py:118
↓ 1 callers
Method
dbt_test_setup
setup for dbt tests - dbt_project config file - entities to be tested
dot/self_tests/self_tests_utils/dbt_base_safe_test_class.py:41
↓ 1 callers
Function
default_config
Sets configuration to determine how the DAG will run from Airflow config. Used if called didn't provide configuration. Returns file handle.
docker/airflow/dags/run_dot_project.py:314
↓ 1 callers
Function
extract_dbt_config_env_variable
Takes a dbt config file and replaces any environment variable syntax with the environment variable. Syntax looks like this ... pass: "{{ env_
dot/utils/configuration_utils.py:125
↓ 1 callers
Function
extract_df_from_ge_test_results_csv
Function to parse GE csv results file (that was created by parse_results) to form a test_summaries standard dataframe. Parameters -
dot/utils/great_expectations.py:239
↓ 1 callers
Function
generate_dbt_test_coverage_report
Generates test coverage report Parameters ---------- logger : logger Logger project_id : str Project ID, eg 'Muso'. M
dot/utils/utils.py:664
↓ 1 callers
Function
generate_failing_passing_dfs
Generates a test_results dataframe, one row per row of data tested Parameters ---------- failing_ids : list List of unique ids in
dot/utils/utils.py:373
↓ 1 callers
Function
generate_master_config_files
Function to generate master configuration files using the entries in config/dot_config.yml and also to set up required output directories (per pr
dot/utils/configuration_management.py:120
↓ 1 callers
Function
get_metadata
Gets the metadata local object to this module Returns ------- MetaData
dot/utils/connection_utils.py:16
↓ 1 callers
Function
get_object
Extracts data from object in source Postgres DB and saves to target DOT database in data schema. Parameters ---------- object_name_
docker/airflow/dags/run_dot_project.py:22
↓ 1 callers
Function
log_subprocess_output
Runs a subprocess, but captures output to the logger Parameters ---------- pipe : Popen pipe Subprocess POpen object, for example
dot/utils/utils.py:53
↓ 1 callers
Function
parse_results
Creates a csv file parsed from great expectations results json object Parameters ---------- results: Pandas dataframe Returns
dot/utils/great_expectations.py:198
↓ 1 callers
Function
refresh_db_metadata
Refresh ddbb metadata. Slow operation! Can be called from anywhere and refreshes the object local object to this module @param engine: e
dot/utils/connection_utils.py:27
↓ 1 callers
Method
run_dbt_steps
Runs all the actions for dbt
dot/self_tests/self_tests_utils/dbt_base_safe_test_class.py:60
↓ 1 callers
Function
run_dot_stages
Runs the full pipeline of DOT: - dbt tests - great expectation tests - report generation and save of results to the database Paramete
dot/utils/run_management.py:33
↓ 1 callers
Function
run_ge_tests
Runs Great Expectations tests Parameters ---------- logger : logger Logger project_id : str Project ID, eg 'Muso'. Mu
dot/utils/great_expectations.py:29
↓ 1 callers
Function
save_object
Saves data to target DOT database in data schema. Parameters ---------- object_name_in: String The Postgres db object to syn
docker/airflow/dags/run_dot_project.py:138
↓ 1 callers
Function
set_summary_stats
Generates tests summary stats for total, failed and passed test rows Parameters ---------- tests_summary : pandas datafram Test s
dot/utils/utils.py:769
↓ 1 callers
Function
update_db_config_from_os
Overrides password with environment variable if db_config has environment variable syntax Parameters ---------- db_config : json
dot/utils/connection_utils.py:76
Function
_get_entity
Gets entity name from entity_id Parameters ---------- project_id Returns -------
dot/utils/utils.py:845
Method
bootstrap_p
(g)
dot/great_expectations/plugins/custom_expectations/custom_dataset.py:66
Function
drop_tables_in_dot_tests_schema
We are syncing new data where new columns and columns types might change. Postgres will prevent ALTER TABLE if any views exist, so we will dr
docker/airflow/dags/run_dot_project.py:272
Method
expect_proper_form_sequence_across_tables
custom expectation
dot/great_expectations/plugins/custom_expectations/custom_dataset.py:98
Method
expect_similar_means_across_reporters
Compares distributions of measurements across CHWs to detect ouliers. This expectation produces warnings rather than pointing out errors due t
dot/great_expectations/plugins/custom_expectations/custom_dataset.py:30
Method
fake_expectation_for_test_purposes
Fake expectation for test purpuses. The test takes the first 5 rows of the entity and considers them failed rows Paramet
dot/great_expectations/plugins/custom_expectations/custom_dataset.py:332
Method
get_bs_p_scores
( table, col, grouping_key, N_samp )
dot/great_expectations/plugins/custom_expectations/custom_dataset.py:53
Function
get_dbt_config_original_model_paths
Gets original (i.e. project_independent) path of `model-paths` (i.e. where DBT models are located) from dbt_project.yml config file items
dot/utils/configuration_utils.py:148
Function
get_dbt_config_original_test_paths
Gets original (i.e. project_independent) path of `test-paths` (i.e. where DBT tests are located) from dbt_project.yml config file items
dot/utils/configuration_utils.py:165
Method
immunization_opv_given_too_early
notebooks/MT - Immunization Exploration Patients are given OPV 1, 2, or 3 immunizations too early Parameters -------
dot/great_expectations/plugins/custom_expectations/custom_dataset.py:158
Method
mock_get_filename_safely
Mock paths of config files Parameters ---------- path Returns -------
dot/self_tests/self_tests_utils/base_self_test_class.py:45
Function
run_dbt_chv_tests
Runs chv-specific tests TODO: Needs more work, chv tests were important in previous projects. Check run_everything as this function might be
dot/utils/dbt.py:174
Function
run_dot_app
Method to run the DOT.
docker/airflow/dags/run_dot_project.py:306
Method
setUp
( self, dummy=None, # pylint: disable=unused-argument )
dot/self_tests/integration/test_run_dot_tests.py:24
Method
setUp
(self)
dot/self_tests/unit/test_dbt_logs_safe.py:24
Method
setUp
(self)
dot/self_tests/unit/test_dbt.py:24
Method
setUp
(self)
dot/self_tests/unit/test_dot_utils_schema_improved.py:21
Method
setUp
( self, mock_get_filename_safely )
dot/self_tests/self_tests_utils/dbt_base_safe_test_class.py:30
Method
setUp
creates DB schema for the demo dataset by default
dot/self_tests/self_tests_utils/base_self_test_class.py:65
Method
setUpClass
(cls)
dot/self_tests/self_tests_utils/base_self_test_class.py:37
Function
sync_object
Extracts data from object in source Postgres DB and saves to target DOT database in data schema. Parameters ---------- object_name_
docker/airflow/dags/run_dot_project.py:230
Method
tearDown
( self, debug=False, # pylint: disable=unused-argument )
dot/self_tests/integration/test_run_dot_tests.py:33
Method
tearDown
(self)
dot/self_tests/unit/test_dot_utils_schema_improved.py:33
Method
tearDown
drops the DB schema for the demo dataset by default
dot/self_tests/self_tests_utils/base_self_test_class.py:69
Method
test_add_ge_schema_parameters
test function add_ge_schema_parameters
dot/self_tests/unit/test_connection_utils.py:41
Method
test_custom_sql_test_malformed
test a possible_duplicate_forms w missing parameters
dot/self_tests/unit/test_dot_utils.py:163
Method
test_dbt_config_custom_schema_output_objects
test get_dbt_config_custom_schema_output_objects
dot/self_tests/unit/test_configuration_utils.py:16
Method
test_extract_df_from_dbt_test_results_json
test output df generated from dbt results in json format (dbt target directory)
dot/self_tests/unit/test_dbt.py:29
Method
test_format_uuid_list
Formats `uuid_list` from postgres as actually a list Returns -------
dot/self_tests/unit/test_dbt.py:80
Method
test_generate_tests_from_db
test yaml file creation for 1 core entity -see file in filename below
dot/self_tests/unit/test_generate_tests_from_db.py:17
Method
test_get_configured_tests_row
test yaml file creation for 1 core entity -see file in filename below
dot/self_tests/unit/test_dot_utils.py:212
next →
1–100 of 117, ranked by callers