def generate_html_table()

in apps/cloudwatch-dashboard/lambdas/list-models/handler.py [0:0]


def generate_html_table(list_models):
    header = (
        '<br /><div>Last <b>50 models</b> trained in the selected period (3 months by default):</div>'
        '<table>\n'
            '<thead>'
                '<tr>'
                    '<th>Dataset</th>'
                    '<th>Model</th>'
                    '<th>Training status</th>'
                    '<th>Model dashboard</th>'
                '</tr>'
            '</thead>\n'
    )
    
    footer = '</table>'
    
    body = '<tbody>\n'
    last_dataset = ''
    last_asset = ''
    
    # Loops through the model list to build the parameters we want to display:
    for model in list_models:
        model_params = dict()
        current_model = model['ModelName']
        current_dataset = model['DatasetName']
        
        # When we hit a new dataset we print its name:
        if current_dataset != last_dataset:
            model_params.update({'dataset': current_dataset})
            last_asset = ''

        # Otherwise we discard it:
        else:
            model_params.update({'dataset': '-'})
            model_params.update({'fleet_actions': ''})

        model_params.update({'model': current_model})
        
        current_status, model_actions = build_status_action(
            status=model['Status'],
            model_name=current_model
        )
        model_params.update({'status': current_status})
        model_params.update({'model_actions': model_actions})
        
        # We can now use the model_params we have
        # assembled to build an HTML row for this model:
        body += generate_html_row(model_params)
        last_dataset = current_dataset

        
    body += '</tbody>\n'
    
    html = header + body + footer
    
    return html