<jupyter_start><jupyter_text>Command Line Interface - Library Rebuilding  Imports<jupyter_code>#exports
import typer
import shutil
import pandas as pd
from fastcore.foundation import Config

from ElexonDataPortal.dev import nbdev, specgen, rawgen, clientgen
#exports
app = typer.Typer()
#exports
@app.command()
def rebuild_library():
    lib_path = str(Config().path('lib_path'))
    dir_root = f'{lib_path}/..'
    endpoints_fp = f'{dir_root}/data/endpoints.csv'
    
    shutil.rmtree(lib_path)
    nbdev.prepare_nbdev_module()
    nbdev.notebook2script()
    
    df_endpoints = specgen.load_endpoints_df(endpoints_fp)
    API_spec = specgen.construct_spec(df_endpoints)
    
    specgen.save_spec(
        API_spec,
        in_fp=f'{dir_root}/templates/open_api_spec.yaml',
        out_fp=f'{dir_root}/data/BMRS_API.yaml'
    )
    
    rawgen.save_methods(
        functions=rawgen.construct_all_functions(specgen.load_API_yaml(fp=f'{dir_root}/data/BMRS_API.yaml')),
        in_fp=f'{dir_root}/templates/raw_methods.py',
        out_fp=f'{dir_root}/ElexonDataPortal/dev/raw.py'
    )
    
    clientgen.save_api_client(
        API_yaml_fp=f'{dir_root}/data/BMRS_API.yaml',
        in_fp=f'{dir_root}/templates/api.py',
        out_fp=f'{dir_root}/ElexonDataPortal/api.py'
    )
    
    nbdev.add_extra_code_desc_to_mod()
    
    return
rebuild_library()
#exports
if __name__ == '__main__' and '__file__' in globals():
    app()
#hide
from ElexonDataPortal.dev.nbdev import notebook2script
notebook2script('07-cli-rebuild.ipynb')<jupyter_output>Converted 07-cli-rebuild.ipynb.
{'fraction_non_alphanumeric': 0.11939355653821858, 'fraction_numerical': 0.004421983575489577, 'mean_word_length': 3.9345794392523366, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '279203', 'license': 'MIT', 'n_tokens_mistral': 615, 'n_tokens_neox': 604, 'n_words': 76, 'path': 'nbs/07-cli-rebuild.ipynb', 'repo_name': 'AyrtonB/ElexonDataPortal', 'size': '1583'}