Skip to content Skip to sidebar Skip to footer

Using Python To Put Pmml

I have a simple PMML file that I would like to PUT to a scoring server. Here is the curl call: curl -X PUT --data-binary @DecisionTreeIris.pmml -H 'Content-type: text/xml' http://l

Solution 1:

I'd recommend using the requests library by Kenneth Reitz (GitHub and Docs).

Specifically, there's an example on how to POST files. Use that to construct what you would need.

I'm just assuming here but I would try the following:

importrequestsurl='http://localhost:8080/openscoring/model/DecisionTreeIris'
files = {'file': open('/path/to/file/DecisionTreeIris.pmml', 'rb')}

response = requests.post(url, files=files)

You can also set the headers or anything else you need. requests is dead simple to use and a boon to the Python community. The documentation is excellent and you can usually find examples with a Google/Bing/DuckDuckGo search easily.

I hope that helps!

Post a Comment for "Using Python To Put Pmml"