<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Python script depot - getting a KeyError  when inputing key values in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Python-script-depot-getting-a-KeyError-when-inputing-key-values/m-p/338620#M58669</link>
    <description>&lt;P&gt;Hi, thank you&amp;nbsp; for the quick response&lt;/P&gt;&lt;P&gt;as you mention ,&amp;nbsp;I used a function to alter the json&amp;nbsp;generated &amp;nbsp;- and it worked.&lt;/P&gt;&lt;P&gt;you can mark the issue as solved&lt;/P&gt;&lt;P&gt;thanks again&lt;/P&gt;&lt;P&gt;Eran&lt;/P&gt;</description>
    <pubDate>Wed, 02 Dec 2020 06:03:13 GMT</pubDate>
    <dc:creator>eranraz100</dc:creator>
    <dc:date>2020-12-02T06:03:13Z</dc:date>
    <item>
      <title>Python script depot - getting a KeyError  when inputing key values</title>
      <link>https://community.jmp.com/t5/Discussions/Python-script-depot-getting-a-KeyError-when-inputing-key-values/m-p/338476#M58638</link>
      <description>&lt;P&gt;&lt;SPAN style="font-family: 'Arial',sans-serif; font-size: 11pt;"&gt;&lt;FONT color="#000000"&gt;I got a python score script generated by the JMP depot ,&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Arial',sans-serif; font-size: 11pt;"&gt;&lt;FONT color="#000000"&gt;When I send a dict of values (taken from a json file)&amp;nbsp; to the score formula, I t ends up with KeyError (as if the key doesn’t exist , but it is )&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial',sans-serif; font-size: 11pt;"&gt;&lt;FONT color="#000000"&gt;Could that be&amp;nbsp; a backspace issue?&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Arial',sans-serif; font-size: 11pt;"&gt;&lt;FONT color="#000000"&gt;I&amp;nbsp; attached the JMP file and the json file &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Arial',sans-serif; font-size: 11pt;"&gt;&lt;FONT color="#000000"&gt;thanks&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Arial',sans-serif; font-size: 11pt;"&gt;&lt;FONT color="#000000"&gt;Eran&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:23:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Python-script-depot-getting-a-KeyError-when-inputing-key-values/m-p/338476#M58638</guid>
      <dc:creator>eranraz100</dc:creator>
      <dc:date>2023-06-10T23:23:07Z</dc:date>
    </item>
    <item>
      <title>Re: Python script depot - getting a KeyError  when inputing key values</title>
      <link>https://community.jmp.com/t5/Discussions/Python-script-depot-getting-a-KeyError-when-inputing-key-values/m-p/338557#M58656</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/22248"&gt;@eranraz100&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Glad to see you deploying our models to production!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;def getInputMetadata():
    return {
        # ...
        u"SURFACE FINISH CS": "str",
	}&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It looks like the process that is generating the JSON input data is replacing these spaces with underscores:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;{
  "SURFACE_FINISH_CS":"FULL_HGLD",
}&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Dec 2020 16:17:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Python-script-depot-getting-a-KeyError-when-inputing-key-values/m-p/338557#M58656</guid>
      <dc:creator>nascif_jmp</dc:creator>
      <dc:date>2020-12-01T16:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: Python script depot - getting a KeyError  when inputing key values</title>
      <link>https://community.jmp.com/t5/Discussions/Python-script-depot-getting-a-KeyError-when-inputing-key-values/m-p/338620#M58669</link>
      <description>&lt;P&gt;Hi, thank you&amp;nbsp; for the quick response&lt;/P&gt;&lt;P&gt;as you mention ,&amp;nbsp;I used a function to alter the json&amp;nbsp;generated &amp;nbsp;- and it worked.&lt;/P&gt;&lt;P&gt;you can mark the issue as solved&lt;/P&gt;&lt;P&gt;thanks again&lt;/P&gt;&lt;P&gt;Eran&lt;/P&gt;</description>
      <pubDate>Wed, 02 Dec 2020 06:03:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Python-script-depot-getting-a-KeyError-when-inputing-key-values/m-p/338620#M58669</guid>
      <dc:creator>eranraz100</dc:creator>
      <dc:date>2020-12-02T06:03:13Z</dc:date>
    </item>
    <item>
      <title>Re: Python script depot - getting a KeyError  when inputing key values</title>
      <link>https://community.jmp.com/t5/Discussions/Python-script-depot-getting-a-KeyError-when-inputing-key-values/m-p/338752#M58681</link>
      <description>&lt;P&gt;Hi again &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/22248"&gt;@eranraz100&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Welcome to the JMP Community, looks like you just joined.&lt;/P&gt;
&lt;P&gt;I am curious about your usage of our Python scoring code - you are the first customer who asked about using JSON as input.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, this is a &lt;A href="http://&amp;nbsp;https://s3.amazonaws.com/stlouishousing.web/index.html" target="_self"&gt;web application&lt;/A&gt;&amp;nbsp;created for a JMP Discovery 2017 conference &lt;A href="https://community.jmp.com/t5/Discovery-Summit-2017/Sharing-the-Ultimate-Boon-A-Journey-From-Modeling-to-Scoring/ta-p/46020" target="_self"&gt;tutorial&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;Are you doing something along those lines?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Dec 2020 14:46:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Python-script-depot-getting-a-KeyError-when-inputing-key-values/m-p/338752#M58681</guid>
      <dc:creator>nascif_jmp</dc:creator>
      <dc:date>2020-12-02T14:46:25Z</dc:date>
    </item>
    <item>
      <title>Re: Python script depot - getting a KeyError  when inputing key values</title>
      <link>https://community.jmp.com/t5/Discussions/Python-script-depot-getting-a-KeyError-when-inputing-key-values/m-p/355917#M60581</link>
      <description>&lt;P&gt;Hi, yes that’s the sort of solution we are trying to implement&lt;/P&gt;&lt;P&gt;I’m using Flask web-framework as REST API, the purpose is to let SAP consume that API during price quotation- calculation &amp;nbsp;&lt;/P&gt;&lt;P&gt;The API does some data validation and conversion, and then address the score function with parameters&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for your help and the useful data you attached&amp;nbsp;&lt;/P&gt;&lt;P&gt;cheers&lt;/P&gt;&lt;P&gt;Eran&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 14:07:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Python-script-depot-getting-a-KeyError-when-inputing-key-values/m-p/355917#M60581</guid>
      <dc:creator>eranraz1</dc:creator>
      <dc:date>2021-02-04T14:07:25Z</dc:date>
    </item>
  </channel>
</rss>

