import papermill as pm
import os
from subprocess import Popen
def run_regression(input_file: str, target: str) -> None:

    pm.execute_notebook(f'ML/Regression_lazypredict.ipynb',
                        'ML/Regression_output.ipynb',
                        parameters=dict(file=rf'{input_file}', target=rf'{target}'))

    conversion_cmd = "jupyter nbconvert --TemplateExporter.exclude_input=True --to html ML/Regression_output.ipynb "

    process = Popen(conversion_cmd, shell=True)

    process.wait()

    print('execution and conversion complete...')

    move_cmd = "cp ML/Regression_output.html templates"

    process = Popen(move_cmd, shell=True)
    process.wait()
    print('template moved...')


def run_classification(input_file: str, target: str) -> None:
    pm.execute_notebook(f'ML/Classification_lazypredict.ipynb',
                        'ML/Classification_output.ipynb',
                        parameters=dict(file=rf'{input_file}', target=rf'{target}'))

    conversion_cmd = "jupyter nbconvert --TemplateExporter.exclude_input=True --to html ML/Classification_output.ipynb"

    process = Popen(conversion_cmd, shell=True)

    process.wait()

    print('execution and conversion complete...')

    move_cmd = "cp ML/Classification_output.html templates"

    process = Popen(move_cmd, shell=True)
    process.wait()
    print('template moved...')
