<jupyter_start><jupyter_text>Setup
Scripts for one-time and package setup.<jupyter_code>import pandas as pd
from src.utilssrc.infrastructure.data.config import repository_credentials, Config
from src.infrastructure.data import DBA, ColumnSchema, TableAdmin<jupyter_output><empty_output><jupyter_text>Internal Setup Scripts
Internal scripts used to create configuration files.   Data Sources Configuration<jupyter_code>def setup_datasource_config(filepath):    
    df = pd.read_csv(filepath, index_col=0, parse_dates=['last_updated', 'last_extracted', 'last_staged'])
    sources  = df.to_dict(orient='index')
    config = Config(filepath)
    for section, configuration in sources.items():
        config.set_section(section, configuration)    
filepath = './data/metadata/datasources.csv'<jupyter_output><empty_output><jupyter_text>External Scripts  Build DrugApprovalAnalytics Database<jupyter_code># filepath = "./data/metadata/repository.csv"
# def build_schema(filepath):
#     df = pd.read_csv(filepath, index_col=0, usecols=[name, constraints])
#     config = df.to_dict('index')
#     columns = []
#     for col, properties in config.items():
#         schema = ColumnSchema(column=col,
#                               datatype=properties['constraints']
#         columns.append(schema)

#     return columns

# def build_table(columns):
#     admin = TableAdmin(repository_credentials)
#     admin.create('repository', columns)
# setup_repository_config(filepath)<jupyter_output>{'event_id': {'datatype': 'UUID', 'nullable': False, 'unique': True, 'primary': True}, 'event_name': {'datatype': 'varchar(40)', 'nullable': False, 'unique': True, 'primary': False}, 'event_description': {'datatype': 'varchar(256)', 'nullable': True, 'unique': False, 'primary': False}, 'event_version': {'datatype': 'integer', 'nullable': False, 'unique': False, 'primary': False}, 'event_created': {'datatype': 'timestamp', 'nullable': False, 'unique': False, 'primary': False}, 'event_updated': {'datatype': 'timestamp', 'nullable': False, 'unique': False, 'primary': False}, 'event_started': {'datatype': 'timestamp', 'nullable': False, 'unique': False, 'primary': False}, 'event_ended': {'datatype': 'timestamp', 'nullable': False, 'unique': False, 'primary': False}, 'event_response_code': {'datatype': 'integer', 'nullable': False, 'unique': False, 'primary': False}, 'event_response_description': {'datatype': 'varchar(256)', 'nullable': False, 'unique': False, 'primary': False}, 'pipeline_i[...]
{'fraction_non_alphanumeric': 0.16011124354390147, 'fraction_numerical': 0.003972983710766786, 'mean_word_length': 5.861035422343324, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '625521', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 759, 'n_tokens_neox': 763, 'n_words': 177, 'path': 'notebooks/0.0 setup.ipynb', 'repo_name': 'john-james-sf/predict-fda', 'size': '2517'}