name:runtime-parameter-exampletype:inferencetargetType:regressionruntimeParameterDefinitions:-fieldName:endpointtype:stringdescription:The name of the endpoint.-fieldName:API_KEYtype:credentialdescription:The HTTP basic credential containing the endpoint's API key in the password field (the username field is ignored).
# Import modules required to make a prediction request.importjsonimportsslimporturllib.requestimportpandasaspd# Import SimpleNamespace to create an object to store runtime parameter variables.fromtypesimportSimpleNamespace# Import RuntimeParameters to use the runtime parameters set in the model metadata.fromdatarobot_drumimportRuntimeParameters# Override the default load_model hook to read the runtime parameters.defload_model(code_dir):# Assign runtime parameters to variables.api_key=RuntimeParameters.get("API_KEY")["password"]endpoint=RuntimeParameters.get("endpoint")# Create scoring endpoint URL.url=f"https://{endpoint}.example.com/score"# Return an object containing the variables necessary to make a prediction request.returnSimpleNamespace(**locals())# Write proxy code to request and convert scoring data from the external model.defscore(data,model,**kwargs):# Call make_remote_prediction_request.# Convert prediction data as necessary.defmake_remote_prediction_request(payload,url,api_key):# Connect to the scoring endpoint URL.# Request predictions from the external model.