Python script depot - getting a KeyError when inputing key valuesI got a python score script generated by the JMP depot ,
When I send a dict of values (taken from a json file) to the score formula, I t ends up with KeyError (as if the key doesn’t exist , but it is )Could that be a backspace issue?
I attached the JMP file and the json file
thanks
Eran
Data TableOtherScriptingRe: Python script depot - getting a KeyError when inputing key valuesHi @eranraz100,
Glad to see you deploying our models to production!
The KeyError is about a string used as key in the input dictionary, that in turn is generated from the JMP column names used as input in your model. JMP supports spaces in column names, and the strings used as keys in the generated Python code also have embedded spaces:
def getInputMetadata():
return {
# ...
u"SURFACE FINISH CS": "str",
}
It looks like the process that is generating the JSON input data is replacing these spaces with underscores:
{
"SURFACE_FINISH_CS":"FULL_HGLD",
}
I hope this is easy to fix on the JSON generation side, but if not, changing the column names to replace the spaces with underscores and regenerating the model would do the trick.
Re: Python script depot - getting a KeyError when inputing key valuesHi, thank you for the quick response
as you mention , I used a function to alter the json generated - and it worked.
you can mark the issue as solved
thanks again
Eran
Re: Python script depot - getting a KeyError when inputing key valuesHi again @eranraz100,
Welcome to the JMP Community, looks like you just joined.
I am curious about your usage of our Python scoring code - you are the first customer who asked about using JSON as input.
I always thought this would be a prime usage scenario as it makes it easier for our models to consume data from web-based processes.
For example, this is a web application created for a JMP Discovery 2017 conference tutorial.
The frontend is a static app based on Leaflet and the backend is one of our models exported to Python and running on AWS Lambda.
Are you doing something along those lines?