mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-30 13:10:47 +00:00
got the dockerfile working completely
This commit is contained in:
parent
058194fc14
commit
17b5464acf
3 changed files with 12 additions and 13 deletions
|
|
@ -2,14 +2,14 @@ FROM public.ecr.aws/lambda/python:3.10
|
||||||
|
|
||||||
# Set the working directory
|
# Set the working directory
|
||||||
WORKDIR ${LAMBDA_TASK_ROOT}/simulation_system
|
WORKDIR ${LAMBDA_TASK_ROOT}/simulation_system
|
||||||
|
ENV PYTHONPATH "${PYTHONPATH}:${LAMBDA_TASK_ROOT}/simulation_system"
|
||||||
|
|
||||||
# Install necessary build tools - required to test locally
|
# Install necessary build tools - required to test locally
|
||||||
RUN yum install -y gcc python3-devel
|
RUN yum install -y gcc python3-devel
|
||||||
|
|
||||||
# Install python packages
|
# Install python packages
|
||||||
COPY requirements/predictions/predictions.txt ./simulation_system/requirements.txt
|
COPY requirements/predictions/predictions.txt ./requirements.txt
|
||||||
COPY requirements/predictions/predictions-dev.txt ./simulation_system/requirements.txt
|
RUN pip install --no-cache-dir -r ./requirements.txt
|
||||||
RUN pip install --no-cache-dir -r ./simulation_system/requirements.txt
|
|
||||||
|
|
||||||
# Copy the project code to the working directory
|
# Copy the project code to the working directory
|
||||||
COPY ./core ./core
|
COPY ./core ./core
|
||||||
|
|
@ -19,4 +19,4 @@ COPY ./handlers/predictions_app.py ./predictions_app.py
|
||||||
COPY ./__init__.py ./__init__.py
|
COPY ./__init__.py ./__init__.py
|
||||||
|
|
||||||
# Run off a lambda trigger
|
# Run off a lambda trigger
|
||||||
CMD [ "predictions_app.handler" ]
|
CMD [ "simulation_system.predictions_app.handler" ]
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,10 @@ from predictions import prediction
|
||||||
RUNTIME_ENVIRONMENT = os.environ.get("RUNTIME_ENVIRONMENT", "dev")
|
RUNTIME_ENVIRONMENT = os.environ.get("RUNTIME_ENVIRONMENT", "dev")
|
||||||
|
|
||||||
|
|
||||||
def handler():
|
def handler(event, context):
|
||||||
"""
|
"""
|
||||||
Take in event and trigger the prediction pipeline
|
Take in event and trigger the prediction pipeline
|
||||||
"""
|
"""
|
||||||
print("HIHIHI")
|
|
||||||
event = {}
|
|
||||||
|
|
||||||
# Assuming a file in a bucket landing for now?
|
# Assuming a file in a bucket landing for now?
|
||||||
# Assuming we have a model to use
|
# Assuming we have a model to use
|
||||||
|
|
@ -19,7 +17,6 @@ def handler():
|
||||||
# key = urllib.parse.unquote_plus(
|
# key = urllib.parse.unquote_plus(
|
||||||
# event["Records"][0]["s3"]["bucket"]["key"], encoding="utf-8"
|
# event["Records"][0]["s3"]["bucket"]["key"], encoding="utf-8"
|
||||||
# )
|
# )
|
||||||
|
|
||||||
payload = event["body"]
|
payload = event["body"]
|
||||||
data_path = payload["file_location"]
|
data_path = payload["file_location"]
|
||||||
property_id = payload["property_id"]
|
property_id = payload["property_id"]
|
||||||
|
|
@ -32,7 +29,7 @@ def handler():
|
||||||
# model_path = os.environ.get("MODEL_PATH", "http://minio:9000/data/model_directory/")
|
# model_path = os.environ.get("MODEL_PATH", "http://minio:9000/data/model_directory/")
|
||||||
model_path = os.environ.get(
|
model_path = os.environ.get(
|
||||||
"MODEL_PATH",
|
"MODEL_PATH",
|
||||||
"s3://retrofit-model-directory-{RUNTIME_ENVIRONMENT}/RDSAP_CHANGE/autogluon/rdsap_change-medium_quality-30"
|
f"s3://retrofit-model-directory-{RUNTIME_ENVIRONMENT}/RDSAP_CHANGE/autogluon/rdsap_change-medium_quality-30"
|
||||||
"-2023-08-30_11-43-41/deployment/",
|
"-2023-08-30_11-43-41/deployment/",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ from core.Settings import (
|
||||||
TIMESTAMP = datetime.now().strftime(TIMESTAMP_FORMAT)
|
TIMESTAMP = datetime.now().strftime(TIMESTAMP_FORMAT)
|
||||||
RUNTIME_ENVIRONMENT = os.environ.get("RUNTIME_ENVIRONMENT", "dev")
|
RUNTIME_ENVIRONMENT = os.environ.get("RUNTIME_ENVIRONMENT", "dev")
|
||||||
|
|
||||||
|
|
||||||
# FOR TESTING
|
# FOR TESTING
|
||||||
# For now just loading data first and then passing into function (i.e. as if we receive json data and convert to
|
# For now just loading data first and then passing into function (i.e. as if we receive json data and convert to
|
||||||
# DataFrame)
|
# DataFrame)
|
||||||
|
|
@ -76,7 +77,7 @@ def prediction(
|
||||||
exit(1)
|
exit(1)
|
||||||
elif RUNTIME_ENVIRONMENT == "dev":
|
elif RUNTIME_ENVIRONMENT == "dev":
|
||||||
registry_path = (
|
registry_path = (
|
||||||
"s3://retrofit-model-directory-dev/RDSAP_CHANGE/model_registry.csv"
|
"s3://retrofit-model-directory-dev/model_directory/RDSAP_CHANGE/model_registry.csv"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
raise NotImplemented("TO be implemented")
|
raise NotImplemented("TO be implemented")
|
||||||
|
|
@ -108,7 +109,7 @@ def prediction(
|
||||||
if data_path and data is None:
|
if data_path and data is None:
|
||||||
logger.info("Loading data from provided path")
|
logger.info("Loading data from provided path")
|
||||||
dataloader = dataloader_factory(runtime_environment=RUNTIME_ENVIRONMENT)
|
dataloader = dataloader_factory(runtime_environment=RUNTIME_ENVIRONMENT)
|
||||||
data = dataloader.load(filepath=data_path, index_col="UPRN")
|
data = dataloader.load(filepath=data_path, index_col="id")
|
||||||
|
|
||||||
if data is None:
|
if data is None:
|
||||||
raise ValueError("No data loaded")
|
raise ValueError("No data loaded")
|
||||||
|
|
@ -134,7 +135,7 @@ def prediction(
|
||||||
|
|
||||||
logger.info("--- Generating Predictions ---")
|
logger.info("--- Generating Predictions ---")
|
||||||
prediction = model.generate_predictions(data=data)
|
prediction = model.generate_predictions(data=data)
|
||||||
return pd.concat([data["recommendation_id"], prediction], axis=1)
|
return pd.concat([data["id"], prediction], axis=1)
|
||||||
|
|
||||||
# Save prediction some where?
|
# Save prediction some where?
|
||||||
# prediction.to_csv("s3?")
|
# prediction.to_csv("s3?")
|
||||||
|
|
@ -167,7 +168,8 @@ if __name__ == "__main__":
|
||||||
args = ingest_arguments()
|
args = ingest_arguments()
|
||||||
|
|
||||||
# Data can be passed in as JSON string: python3 predictions.py --data '{"TOTAL_FLOOR_AREA": 1}'
|
# Data can be passed in as JSON string: python3 predictions.py --data '{"TOTAL_FLOOR_AREA": 1}'
|
||||||
# Data path can be passed as so: python3 predictions.py --data-path ./model_build_data/change_data/rdsap_full/test_data.parquet
|
# Data path can be passed as so: python3 predictions.py --data-path
|
||||||
|
# ./model_build_data/change_data/rdsap_full/test_data.parquet
|
||||||
prediction(
|
prediction(
|
||||||
target_column=args.target_column,
|
target_column=args.target_column,
|
||||||
model_path=args.model_path,
|
model_path=args.model_path,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue