mirror of
https://github.com/Hestia-Homes/ML.git
synced 2026-07-12 13:28:58 +00:00
add dummy invoke
This commit is contained in:
parent
e0fc65ec8a
commit
a20d0e6762
2 changed files with 23 additions and 10 deletions
2
.github/workflows/MLPipelinePullRequest.yml
vendored
2
.github/workflows/MLPipelinePullRequest.yml
vendored
|
|
@ -88,7 +88,7 @@ jobs:
|
||||||
sleep 2
|
sleep 2
|
||||||
curl -X POST "http://localhost:9000/2015-03-31/functions/function/invocations" \
|
curl -X POST "http://localhost:9000/2015-03-31/functions/function/invocations" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{\"body\": \"{\\\"file_location\\\": \\\"s3://retrofit-data-dev/sap_change_model/sample_data_for_cicd/${timestamp}/sample_test.parquet\\\", \\\"property_id\\\": 1, \\\"portfolio_id\\\": 4, \\\"created_at\\\": \\\"now\\\", \\\"testing\\\": true}\"}"
|
-d "{\"body\": \"{\\\"file_location\\\": \\\"s3://retrofit-data-dev/sap_change_model/sample_data_for_cicd/${timestamp}/sample_test.parquet\\\", \\\"property_id\\\": 1, \\\"portfolio_id\\\": 4, \\\"created_at\\\": \\\"now\\\", \\\"testing\\\": true, \\\"warm\\\": true}\"}"
|
||||||
|
|
||||||
- name: Get Lambda logs
|
- name: Get Lambda logs
|
||||||
run: |
|
run: |
|
||||||
|
|
|
||||||
|
|
@ -66,14 +66,6 @@ def handler(event, context):
|
||||||
created_at = body["created_at"]
|
created_at = body["created_at"]
|
||||||
|
|
||||||
# TODO: Implement the loading of the model and prediction
|
# TODO: Implement the loading of the model and prediction
|
||||||
|
|
||||||
if "testing" in body:
|
|
||||||
storage_filepath = body["file_location"].replace(
|
|
||||||
".parquet", "_output.parquet"
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
storage_filepath = f"s3://{PREDICTIONS_BUCKET}/{portfolio_id}/{property_id}/{created_at}.parquet"
|
|
||||||
|
|
||||||
logger.info(f"--- Initiate MLModel ---")
|
logger.info(f"--- Initiate MLModel ---")
|
||||||
|
|
||||||
build_model_params = settings.build_model
|
build_model_params = settings.build_model
|
||||||
|
|
@ -83,6 +75,27 @@ def handler(event, context):
|
||||||
|
|
||||||
model = model_factory(build_model_params["model_type"])
|
model = model_factory(build_model_params["model_type"])
|
||||||
|
|
||||||
|
model_filepath = build_model_params["model_save_filepath"]
|
||||||
|
|
||||||
|
if "testing" in body:
|
||||||
|
storage_filepath = body["file_location"].replace(
|
||||||
|
".parquet", "_output.parquet"
|
||||||
|
)
|
||||||
|
elif "warm" in body:
|
||||||
|
logger.info("Warm up invocation - skipping prediction")
|
||||||
|
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
model.load_model(model_filepath)
|
||||||
|
return {
|
||||||
|
"statusCode": 200,
|
||||||
|
"body": json.dumps(
|
||||||
|
{"message": f"{model.predict(data=pd.DataFrame({'a': [1]}))}"}
|
||||||
|
),
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
storage_filepath = f"s3://{PREDICTIONS_BUCKET}/{portfolio_id}/{property_id}/{created_at}.parquet"
|
||||||
|
|
||||||
logger.info(f"--- Initiate Input DataClient ---")
|
logger.info(f"--- Initiate Input DataClient ---")
|
||||||
input_dataclient = dataclient_factory(
|
input_dataclient = dataclient_factory(
|
||||||
dataclient_type="aws-s3",
|
dataclient_type="aws-s3",
|
||||||
|
|
@ -100,7 +113,7 @@ def handler(event, context):
|
||||||
output_dataclient=output_dataclient,
|
output_dataclient=output_dataclient,
|
||||||
model=model,
|
model=model,
|
||||||
target=feature_process_params["feature_processor_config"]["target"],
|
target=feature_process_params["feature_processor_config"]["target"],
|
||||||
model_filepath=build_model_params["model_save_filepath"],
|
model_filepath=model_filepath,
|
||||||
test_data_filepath=body["file_location"],
|
test_data_filepath=body["file_location"],
|
||||||
predictions_output_filepath=storage_filepath,
|
predictions_output_filepath=storage_filepath,
|
||||||
predictions_column_name=generate_predictions_params[
|
predictions_column_name=generate_predictions_params[
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue