add pre-commit hook, no customisation on black

This commit is contained in:
Michael Duong 2023-08-29 17:28:48 +01:00
parent 4a73ebfb74
commit 6956a80707
5 changed files with 20 additions and 5 deletions

View file

@ -0,0 +1,11 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black

View file

@ -54,6 +54,7 @@ class MLModel(Protocol):
Perfomance post processing on Model to ensure ready for deployment
"""
def generate_meta_data(self):
def model_metadata(self) -> dict:
"""
Extract out model metadata as dictionary
"""

View file

@ -135,6 +135,12 @@ class AutogluonModel:
# This will return a string path of the location
return self.model.clone_for_deployment(deployment_path)
def model_metadata(self) -> dict:
"""
For Autogluon model, use the inbuilt model info method
"""
return self.model.info()

View file

@ -112,13 +112,12 @@ def prediction(target_column: str = "RDSAP_CHANGE", model_path: str = None, data
output_base = PREDICTION_LOCATION / target_column / uprn / TIMESTAMP
output_base.mkdir(parents=True, exist_ok=True)
# TODO: change model.model.info to a class method for MLModel
json_prediction = prediction.to_json(output_base / PREDICTION_FILE)
prediction_metadata = {
"model_type": model_type,
"model_name": model_name,
"model_location": model_location,
"model_settings": model.model.info()
"model_settings": model.model_metadata()
}
pd.DataFrame([prediction_metadata]).to_json(output_base / METADATA_FILE)

View file

@ -1,10 +1,8 @@
import argparse
# import boto3
import os
from pathlib import Path
from datetime import datetime
from typing import List
from core.Logger import logger
from core.DataLoader import DataLoader
from core.FeatureProcessor import FeatureProcessor