From 73b2e70e4c1cbcba1f8fb15ce34d3c5af41041aa Mon Sep 17 00:00:00 2001 From: Sai Ma Date: Thu, 19 Dec 2024 03:23:32 +0000 Subject: [PATCH] Fix FMC runtime error --- scripts/fmc_processing_script.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/scripts/fmc_processing_script.py b/scripts/fmc_processing_script.py index f76b6ce..3939ade 100644 --- a/scripts/fmc_processing_script.py +++ b/scripts/fmc_processing_script.py @@ -1,8 +1,12 @@ # import modules +import logging import os +import sys +import click import datacube import joblib +import requests import xarray as xr from datacube.utils.cog import write_cog from dea_tools.classification import sklearn_flatten, sklearn_unflatten @@ -121,6 +125,17 @@ def fmc_processing( ): logging_setup() + dc = datacube.Datacube( + app=f"fmc_processing", + config={ + "db_hostname": os.getenv("ODC_DB_HOSTNAME"), + "db_password": os.getenv("ODC_DB_PASSWORD"), + "db_username": os.getenv("ODC_DB_USERNAME"), + "db_port": 5432, + "db_database": os.getenv("ODC_DB_DATABASE"), + }, + ) + # need to set the AWS login so that we can access the data we need os.environ["AWS_NO_SIGN_REQUEST"] = "Yes" @@ -128,12 +143,10 @@ def fmc_processing( measurements_list = process_cfg["input_products"]["input_bands"] output_folder = process_cfg["output_folder"] - model_url = process_cfg["model_features"] + model_url = process_cfg["model_path"] product_name = process_cfg["product"]["name"] product_version = str(process_cfg["product"]["version"]).replace(".", "-") - dc = datacube.Datacube(app="fmc_processing") - # Define the path to the saved machine learning model file. model_path = "RF_AllBands_noLC_DEA_labeless.joblib" @@ -142,7 +155,7 @@ def fmc_processing( download_file_from_s3_public(model_url, model_path) # import model: move it to fmc processing cfg file - model = joblib.load(model_url) + model = joblib.load(model_path) # find a single S2 dataset: 26cce90f-c8f9-4234-835c-35005454f62b