openscoring / openscoring-python

Python client library for the Openscoring REST web service
GNU Affero General Public License v3.0
32 stars 9 forks source link

ConnectionError: HTTPConnectionPool(host='localhost', port=8080) #13

Closed chinyii closed 3 years ago

chinyii commented 3 years ago

Hello, I am trying to use Openscoring as a web service to get APIs. I am very new to this so I do hope to get some help.

from openscoring import Openscoring

os = Openscoring(base_url = "http://localhost:8080/openscoring")

This part runs on Jupyter Notebook without issue, however attempting to go to the base url, results in the site not being able to be reached. The main error will be in the next line of code for deploying the pmml file.

os.deployFile("Traffic", "lr_model.pmml")

The full error message is as stated:

ConnectionRefusedError                    Traceback (most recent call last)
D:\anaconda3\lib\site-packages\urllib3\connection.py in _new_conn(self)
    168         try:
--> 169             conn = connection.create_connection(
    170                 (self._dns_host, self.port), self.timeout, **extra_kw

D:\anaconda3\lib\site-packages\urllib3\util\connection.py in create_connection(address, timeout, source_address, socket_options)
     95     if err is not None:
---> 96         raise err
     97 

D:\anaconda3\lib\site-packages\urllib3\util\connection.py in create_connection(address, timeout, source_address, socket_options)
     85                 sock.bind(source_address)
---> 86             sock.connect(sa)
     87             return sock

ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

During handling of the above exception, another exception occurred:

NewConnectionError                        Traceback (most recent call last)
D:\anaconda3\lib\site-packages\urllib3\connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    698             # Make the request on the httplib connection object.
--> 699             httplib_response = self._make_request(
    700                 conn,

D:\anaconda3\lib\site-packages\urllib3\connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
    393             else:
--> 394                 conn.request(method, url, **httplib_request_kw)
    395 

D:\anaconda3\lib\site-packages\urllib3\connection.py in request(self, method, url, body, headers)
    233             headers["User-Agent"] = _get_default_user_agent()
--> 234         super(HTTPConnection, self).request(method, url, body=body, headers=headers)
    235 

D:\anaconda3\lib\http\client.py in request(self, method, url, body, headers, encode_chunked)
   1254         """Send a complete request to the server."""
-> 1255         self._send_request(method, url, body, headers, encode_chunked)
   1256 

D:\anaconda3\lib\http\client.py in _send_request(self, method, url, body, headers, encode_chunked)
   1300             body = _encode(body, 'body')
-> 1301         self.endheaders(body, encode_chunked=encode_chunked)
   1302 

D:\anaconda3\lib\http\client.py in endheaders(self, message_body, encode_chunked)
   1249             raise CannotSendHeader()
-> 1250         self._send_output(message_body, encode_chunked=encode_chunked)
   1251 

D:\anaconda3\lib\http\client.py in _send_output(self, message_body, encode_chunked)
   1009         del self._buffer[:]
-> 1010         self.send(msg)
   1011 

D:\anaconda3\lib\http\client.py in send(self, data)
    949             if self.auto_open:
--> 950                 self.connect()
    951             else:

D:\anaconda3\lib\site-packages\urllib3\connection.py in connect(self)
    199     def connect(self):
--> 200         conn = self._new_conn()
    201         self._prepare_conn(conn)

D:\anaconda3\lib\site-packages\urllib3\connection.py in _new_conn(self)
    180         except SocketError as e:
--> 181             raise NewConnectionError(
    182                 self, "Failed to establish a new connection: %s" % e

NewConnectionError: <urllib3.connection.HTTPConnection object at 0x0000014AB7CBFEB0>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it

During handling of the above exception, another exception occurred:

MaxRetryError                             Traceback (most recent call last)
D:\anaconda3\lib\site-packages\requests\adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
    438             if not chunked:
--> 439                 resp = conn.urlopen(
    440                     method=request.method,

D:\anaconda3\lib\site-packages\urllib3\connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    754 
--> 755             retries = retries.increment(
    756                 method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]

D:\anaconda3\lib\site-packages\urllib3\util\retry.py in increment(self, method, url, response, error, _pool, _stacktrace)
    573         if new_retry.is_exhausted():
--> 574             raise MaxRetryError(_pool, url, error or ResponseError(cause))
    575 

MaxRetryError: HTTPConnectionPool(host='localhost', port=8080): Max retries exceeded with url: /openscoring/model/Traffic (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x0000014AB7CBFEB0>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it'))

During handling of the above exception, another exception occurred:

ConnectionError                           Traceback (most recent call last)
<ipython-input-3-38aa5e890439> in <module>
----> 1 os.deployFile("Traffic", "lr_model.pmml")

D:\anaconda3\lib\site-packages\openscoring\__init__.py in deployFile(self, id, file, **kwargs)
     77         def deployFile(self, id, file, **kwargs):
     78                 with open(file, "rb") as instream:
---> 79                         return self.deploy(id, instream, **kwargs)
     80 
     81         def evaluate(self, id, payload = {}, **kwargs):

D:\anaconda3\lib\site-packages\openscoring\__init__.py in deploy(self, id, pmml, **kwargs)
     71         def deploy(self, id, pmml, **kwargs):
     72                 kwargs = _merge_dicts(kwargs, data = pmml, json = None, auth = self.auth, headers = {"content-type" : "application/xml"})
---> 73                 response = self._check_response(requests.put(self._model_url(id), **kwargs))
     74                 modelResponse = ModelResponse(**json.loads(response.text))
     75                 return modelResponse.ensureSuccess()

D:\anaconda3\lib\site-packages\requests\api.py in put(url, data, **kwargs)
    132     """
    133 
--> 134     return request('put', url, data=data, **kwargs)
    135 
    136 

D:\anaconda3\lib\site-packages\requests\api.py in request(method, url, **kwargs)
     59     # cases, and look like a memory leak in others.
     60     with sessions.Session() as session:
---> 61         return session.request(method=method, url=url, **kwargs)
     62 
     63 

D:\anaconda3\lib\site-packages\requests\sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
    540         }
    541         send_kwargs.update(settings)
--> 542         resp = self.send(prep, **send_kwargs)
    543 
    544         return resp

D:\anaconda3\lib\site-packages\requests\sessions.py in send(self, request, **kwargs)
    653 
    654         # Send the request
--> 655         r = adapter.send(request, **kwargs)
    656 
    657         # Total elapsed time of the request (approximately)

D:\anaconda3\lib\site-packages\requests\adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
    514                 raise SSLError(e, request=request)
    515 
--> 516             raise ConnectionError(e, request=request)
    517 
    518         except ClosedPoolError as e:

ConnectionError: HTTPConnectionPool(host='localhost', port=8080): Max retries exceeded with url: /openscoring/model/Traffic (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x0000014AB7CBFEB0>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it'))

I sincerely apologize if this is a dumb issue, but I do not know why or what is wrong. I have also ran spark-shell --jars D:\spark-3.0.2-bin-hadoop2.7\bin\jpmml-sparkml-executable-${1.6.5}.jar with no issues. I am currently using Spark 3.0.2 and Python 3.8.8. Thank you for your time and considerations. Please do let me know if more information is required from me.

vruusmann commented 3 years ago

os = Openscoring(base_url = "http://localhost:8080/openscoring") This part runs on Jupyter Notebook without issue

This should always run OK, because the Openscoring constructor does not do any networking - it simply stores the base URL for making more specialized API calls.

os.deployFile("Traffic", "lr_model.pmml") attempting to go to the base url, results in the site not being able to be reached. The full error message is as stated: .. [WinError 10061] No connection could be made because the target machine actively refused it

Now you're about to perform the first network operation, but it fails, because you don't have an Openscoring server application running.

Are you sure you have Openscoring server running at http://localhost:8080/openscoring? What do you see if you copy&paste this URL to a web browser?

You're saying that you're working with a Jupyter notebook. Is it a local or remote Jupyter netbook? If it's a remote one, then http://localhost:8080/openscoring is relative to this remote server machine. You can't connect from remote machine to a local machine just like that.

vruusmann commented 3 years ago

If you didn't have Openscoring server running, then see here: https://github.com/openscoring/openscoring#usage

chinyii commented 3 years ago

If you didn't have Openscoring server running, then see here: https://github.com/openscoring/openscoring#usage

Oh dear, I thought all I had to do was just use it through Jupyter Notebook. I did the steps and launched the server. However, through Jupyter Notebook, I ran into another error. ValueError: User not authorized. I think it has something to do with the advanced configuration for Openscoring, but the system can't seem to find the application.conf file.

It produced this error when trying to run "java -Dconfig.file=application.conf -jar openscoring-server-executable-2.0.4.jar" I have included some screenshots for reference. Thank you once again for your time! I am so sorry about these issues, as I am very new to this.

error

appconfigfile

appconfig

servererror

Edit: Oh and this is what shows when I start the Openscoring server with defaults. This is what I got when going to http://localhost:8080/openscoring

defaultconfigserver

vruusmann commented 3 years ago

It produced this error when trying to run java -Dconfig.file=application.conf -jar openscoring-server-executable-2.0.4.jar ValueError: User not authorized

You have Openscoring server running now, and your Jupyter notebook is able to connect to it, because this what you're seeing is a proper Openscoring server-generated error message!

This message - "User not authorized" - means that you're trying to invoke an admin action (here: deploying a new model) without having provided any admin credentials.

I have included some screenshots for reference.

I can see that you've edited the default application.conf, and tweaked access control section.

I can also see that the edited config file now contains a parse error - there is an unbalanced right curly brace character (}) at the end of networkSecurityConfigFilter section.

Perhaps the Openscoring server is loading the config file only partially, and therefore fails to grant admin access?

See the Openscoring server log file, which should contain more detailed information about the active configuration and any admin grant/deny decision.

Edit: Oh and this is what shows when I start the Openscoring server with defaults. Message: Not found

That counts as a success.

You're actually accessing a non-existent endpoint. There's nothing mapped to the root path (/openscoring/). Try adding a /model suffix to it (/openscoring/model/) to actually get the list of deployed models (should be an empty list initially).

vruusmann commented 3 years ago

If you're very new to this, then I'd suggest you to avoid editing the application.conf file.

Start the Openscoring server with the default (built-in) configuration, and see if you can invoke admin-level actions (deploy a model, undeploy a model) or not. IIRC, it should be possible in localhost mode.

chinyii commented 3 years ago

@vruusmann I changed the application.conf as you said about the curly brace and I realized why it does not detect the application.conf file. I had to add a .txt at the back as for some reason it could not recognize it with just application.conf. I think I had to do a application.conf as the default server just does not authorize me to deploy the file.

After successfully running with the application.conf file, the error evolved into another error in Jupyter Notebook. Every step forward seems to have an error, I am so sorry for causing you trouble :(

ValueError                                Traceback (most recent call last)
<ipython-input-2-38aa5e890439> in <module>
----> 1 os.deployFile("Traffic", "lr_model.pmml")

D:\anaconda3\lib\site-packages\openscoring\__init__.py in deployFile(self, id, file, **kwargs)
     77         def deployFile(self, id, file, **kwargs):
     78                 with open(file, "rb") as instream:
---> 79                         return self.deploy(id, instream, **kwargs)
     80 
     81         def evaluate(self, id, payload = {}, **kwargs):

D:\anaconda3\lib\site-packages\openscoring\__init__.py in deploy(self, id, pmml, **kwargs)
     73                 response = self._check_response(requests.put(self._model_url(id), **kwargs))
     74                 modelResponse = ModelResponse(**json.loads(response.text))
---> 75                 return modelResponse.ensureSuccess()
     76 
     77         def deployFile(self, id, file, **kwargs):

D:\anaconda3\lib\site-packages\openscoring\common.py in ensureSuccess(self)
     24         def ensureSuccess(self):
     25                 if hasattr(self, "message") and self.message is not None:
---> 26                         raise ValueError(self.message)
     27                 return self
     28 

ValueError: Required element PMML/<Model>@isScorable=true is not defined

Just in case, I will show the pmml file that I generated to deploy for context.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<PMML xmlns="http://www.dmg.org/PMML-4_4" xmlns:data="http://jpmml.org/jpmml-model/InlineTable" version="4.4">
    <Header>
        <Application name="JPMML-SparkML" version="1.6.5"/>
        <Timestamp>2021-06-26T07:34:12Z</Timestamp>
    </Header>
    <DataDictionary>
        <DataField name="traffic_count" optype="continuous" dataType="double"/>
        <DataField name="road_name" optype="categorical" dataType="string">
            <Value value="Newell Highway"/>
            <Value value="Great Western Highway"/>
            <Value value="New England Highway"/>
            <Value value="Hume Highway"/>
            <Value value="Pacific Highway"/>
            <Value value="Galston Road"/>
            <Value value="Sturt Highway"/>
            <Value value="Pacific Motorway"/>
            <Value value="Great Western Highway Hvcs"/>
            <Value value="Hume Highway Hvcs"/>
            <Value value="Oxley Highway"/>
            <Value value="Victoria Road"/>
            <Value value="Monaro Highway"/>
            <Value value="Barrier Highway"/>
            <Value value="Gwydir Highway"/>
            <Value value="Mona Vale Road"/>
            <Value value="Summerland Way"/>
            <Value value="Windsor Road"/>
            <Value value="Pittwater Road"/>
            <Value value="Hunter Expressway"/>
            <Value value="Kingsway"/>
            <Value value="Princes Highway"/>
            <Value value="Hume Motorway"/>
            <Value value="Pennant Hills Road"/>
            <Value value="Cambridge Street"/>
            <Value value="Canterbury Road"/>
            <Value value="New South Head Road"/>
            <Value value="Picton Road"/>
            <Value value="Ryde Road"/>
            <Value value="Warringah Road"/>
            <Value value="Silverwater Road"/>
            <Value value="Newbridge Road"/>
            <Value value="Alfords Point Road"/>
            <Value value="Avon Dam Road"/>
            <Value value="Beecroft Road"/>
            <Value value="Bells Line Of Road"/>
            <Value value="Broughton Street"/>
            <Value value="Burns Bay Road"/>
            <Value value="Campbelltown Road"/>
            <Value value="Centenary Drive"/>
            <Value value="Concord Road"/>
            <Value value="Eastern Valley Way"/>
            <Value value="Elizabeth Drive"/>
            <Value value="Fairfield Street"/>
            <Value value="Federal Highway"/>
            <Value value="Forest Way"/>
            <Value value="Georges River Road"/>
            <Value value="Golden Highway"/>
            <Value value="Hawkesbury Road"/>
            <Value value="Lawrence Hargrave Drive"/>
            <Value value="Macleay Valley Way"/>
            <Value value="Melbourne Street"/>
            <Value value="Merriwa Road"/>
            <Value value="Mitchell Highway"/>
            <Value value="Mount Ousley Road Hvcs"/>
            <Value value="New Line Road"/>
            <Value value="Pacific Motorway Hvcs"/>
            <Value value="Pages Road"/>
            <Value value="Remembrance Driveway"/>
            <Value value="Sydney Road"/>
            <Value value="The Boulevarde"/>
            <Value value="Epping Road"/>
            <Value value="Parramatta Road"/>
            <Value value="Appin Road"/>
            <Value value="Eastern Distributor"/>
            <Value value="Lane Cove Road"/>
            <Value value="Pacific Highway Hvcs"/>
            <Value value="South Dowling Street"/>
            <Value value="King Georges Road"/>
            <Value value="Western Distributor"/>
            <Value value="Barrenjoey Road"/>
            <Value value="Briens Road"/>
            <Value value="Cahill Expressway"/>
            <Value value="Camden Valley Way"/>
            <Value value="Canal Road"/>
            <Value value="City-West Link Road"/>
            <Value value="Craig Street"/>
            <Value value="Donald Street"/>
            <Value value="Edgar Street"/>
            <Value value="Enmore Road"/>
            <Value value="Francis Road"/>
            <Value value="Freemans Drive"/>
            <Value value="General Holmes Drive"/>
            <Value value="Gladstone Avenue"/>
            <Value value="Heathcote Road"/>
            <Value value="Jersey Road"/>
            <Value value="King Street"/>
            <Value value="Lancaster Street"/>
            <Value value="Lily Lane"/>
            <Value value="Liverpool Road"/>
            <Value value="M2 Motorway"/>
            <Value value="Main Road"/>
            <Value value="Marsden Road"/>
            <Value value="Memorial Drive"/>
            <Value value="Military Road"/>
            <Value value="NULL"/>
            <Value value="O'riordan Street"/>
            <Value value="Old Hume Highway"/>
            <Value value="Olympic Drive"/>
            <Value value="Ourimbah Road"/>
            <Value value="Penshurst Street"/>
            <Value value="Prospect Highway"/>
            <Value value="Showground Road"/>
            <Value value="Snowy Mountains Highway"/>
            <Value value="Spit Road"/>
            <Value value="Stacey Street"/>
            <Value value="Stewart Avenue"/>
            <Value value="Stoney Creek Road"/>
            <Value value="Strathallen Avenue"/>
            <Value value="Sunnyholt Road"/>
            <Value value="Syd Einfeld Drive"/>
            <Value value="Sydney Harbour Tunnel"/>
            <Value value="Taren Point Road"/>
            <Value value="Thomas Street"/>
            <Value value="Windang Road"/>
            <Value value="Jaorimin Road"/>
            <Value value="Cleveland Street"/>
            <Value value="Fairford Road"/>
            <Value value="Allen Street"/>
            <Value value="Burnt Bridge Creek Deviation"/>
            <Value value="Church Street"/>
            <Value value="Newcastle Street"/>
            <Value value="Old Windsor Road"/>
            <Value value="Red Head Road"/>
            <Value value="Regent Street"/>
            <Value value="Rutledge Street"/>
            <Value value="Freame Street"/>
        </DataField>
        <DataField name="suburb" optype="categorical" dataType="string">
            <Value value="Marulan"/>
            <Value value="Tomingley"/>
            <Value value="Bargo"/>
            <Value value="Blackheath"/>
            <Value value="Boggabilla"/>
            <Value value="Hartley"/>
            <Value value="Ryde"/>
            <Value value="Balranald"/>
            <Value value="Bendemeer"/>
            <Value value="Broken Hill"/>
            <Value value="Caragabal"/>
            <Value value="Casino"/>
            <Value value="Dundee"/>
            <Value value="Eumungerie"/>
            <Value value="Euroley"/>
            <Value value="Forbes"/>
            <Value value="Galston"/>
            <Value value="Gilgandra"/>
            <Value value="Jerilderie"/>
            <Value value="Little Hartley"/>
            <Value value="Mount White"/>
            <Value value="Muswellbrook"/>
            <Value value="Tannabar"/>
            <Value value="Wyalong"/>
            <Value value="South Wentworthville"/>
            <Value value="Beacon Hill"/>
            <Value value="Belrose"/>
            <Value value="Canley Heights"/>
            <Value value="Miranda"/>
            <Value value="West Pymble"/>
            <Value value="Milperra"/>
            <Value value="Wiley Park"/>
            <Value value="Aberdeen"/>
            <Value value="Baulkham Hills"/>
            <Value value="Bective"/>
            <Value value="Bell"/>
            <Value value="Biddon"/>
            <Value value="Blacktown"/>
            <Value value="Bowning"/>
            <Value value="Bredbo"/>
            <Value value="Buchanan"/>
            <Value value="Calga"/>
            <Value value="Campbelltown"/>
            <Value value="Castlecrag"/>
            <Value value="Casula"/>
            <Value value="Cheltenham"/>
            <Value value="Cherrybrook"/>
            <Value value="Clifton"/>
            <Value value="Collaroy"/>
            <Value value="Cooma"/>
            <Value value="Coonabarabran"/>
            <Value value="Croydon Park"/>
            <Value value="Edgecliff"/>
            <Value value="Fairfield East"/>
            <Value value="Glen Innes"/>
            <Value value="Gundagai"/>
            <Value value="Gunnedah"/>
            <Value value="Homebush West"/>
            <Value value="Hornsby"/>
            <Value value="Hornsby Heights"/>
            <Value value="Ingleside"/>
            <Value value="Inverell"/>
            <Value value="Kiwarrak"/>
            <Value value="Lane Cove West"/>
            <Value value="Leumeah"/>
            <Value value="Manton"/>
            <Value value="Meadow Flat"/>
            <Value value="Merriwa"/>
            <Value value="Merrylands"/>
            <Value value="Molong"/>
            <Value value="Mount Keira"/>
            <Value value="Mount Victoria"/>
            <Value value="Mulwala"/>
            <Value value="North Ryde"/>
            <Value value="North Wahroonga"/>
            <Value value="Padstow Heights"/>
            <Value value="Raglan"/>
            <Value value="Rhodes"/>
            <Value value="Rixs Creek"/>
            <Value value="Rouse Hill"/>
            <Value value="Sandy Hollow"/>
            <Value value="South Kempsey"/>
            <Value value="St Marys"/>
            <Value value="Strathfield"/>
            <Value value="Wardell"/>
            <Value value="Warrawee"/>
            <Value value="Westdale"/>
            <Value value="Wilton"/>
            <Value value="Rydalmere"/>
            <Value value="Bankstown"/>
            <Value value="Pennant Hills"/>
            <Value value="Sydney"/>
            <Value value="Coolac"/>
            <Value value="Darlinghurst"/>
            <Value value="Huntleys Point"/>
            <Value value="Liverpool"/>
            <Value value="Maclean"/>
            <Value value="Mosman"/>
            <Value value="Newtown"/>
            <Value value="Rozelle"/>
            <Value value="Sawyers Gully"/>
            <Value value="Surry Hills"/>
            <Value value="Twelve Mile Creek"/>
            <Value value="Yarra"/>
            <Value value="Auburn"/>
            <Value value="Moore Park"/>
            <Value value="Narrabeen"/>
            <Value value="North Parramatta"/>
            <Value value="Northmead"/>
            <Value value="Pymble"/>
            <Value value="Roselands"/>
            <Value value="Wahroonga"/>
            <Value value="Adamstown"/>
            <Value value="Alexandria"/>
            <Value value="Annandale"/>
            <Value value="Appin"/>
            <Value value="Banksia"/>
            <Value value="Beverly Hills"/>
            <Value value="Blakehurst"/>
            <Value value="Bombala"/>
            <Value value="Bondi Junction"/>
            <Value value="Bonnyrigg"/>
            <Value value="Bookham"/>
            <Value value="Braemar"/>
            <Value value="Brighton-Le-Sands"/>
            <Value value="Cammeray"/>
            <Value value="Castle Hill"/>
            <Value value="Cataract"/>
            <Value value="Cecil Hills"/>
            <Value value="Chatswood"/>
            <Value value="Chinderah"/>
            <Value value="Collector"/>
            <Value value="Cordeaux"/>
            <Value value="Elderslie"/>
            <Value value="Engadine"/>
            <Value value="Ermington"/>
            <Value value="Figtree"/>
            <Value value="Five Dock"/>
            <Value value="Freemans Waterhole"/>
            <Value value="Glendale"/>
            <Value value="Greenacre"/>
            <Value value="Hamilton"/>
            <Value value="Hamilton East"/>
            <Value value="Jones Island"/>
            <Value value="Kew"/>
            <Value value="Killara"/>
            <Value value="Lake Innes"/>
            <Value value="Lane Cove"/>
            <Value value="Lidcombe"/>
            <Value value="Lilyfield"/>
            <Value value="Middle Harbour"/>
            <Value value="Minchinbury"/>
            <Value value="Mona Vale"/>
            <Value value="Nabiac"/>
            <Value value="North Narrabeen"/>
            <Value value="North Wollongong"/>
            <Value value="Oatlands"/>
            <Value value="Penrith"/>
            <Value value="Pheasants Nest"/>
            <Value value="Pine Valley"/>
            <Value value="Rockdale"/>
            <Value value="Rooty Hill"/>
            <Value value="Roseville"/>
            <Value value="Seven Hills"/>
            <Value value="South Grafton"/>
            <Value value="St Ives"/>
            <Value value="St Peters"/>
            <Value value="Strathfield South"/>
            <Value value="Table Top"/>
            <Value value="Taren Point"/>
            <Value value="Tomago"/>
            <Value value="Towradgi"/>
            <Value value="Unanderra"/>
            <Value value="Villawood"/>
            <Value value="Wallsend"/>
            <Value value="Windang"/>
            <Value value="Wollongong"/>
            <Value value="Woodburn"/>
            <Value value="Woolooware"/>
            <Value value="Bunyan"/>
            <Value value="Werrington"/>
            <Value value="Pyrmont"/>
            <Value value="Redfern"/>
            <Value value="Balgowlah"/>
            <Value value="Bomaderry"/>
            <Value value="Charlestown"/>
            <Value value="Dee Why"/>
            <Value value="East Maitland"/>
            <Value value="Eastwood"/>
            <Value value="Epping"/>
            <Value value="Lane Cove North"/>
            <Value value="Oxley Park"/>
            <Value value="Padstow"/>
            <Value value="Redhead"/>
            <Value value="Sydenham"/>
            <Value value="Wolli Creek"/>
            <Value value="Woodlands"/>
            <Value value="Wentworthville"/>
        </DataField>
        <DataField name="cardinal_direction_name" optype="categorical" dataType="string">
            <Value value="BOTH"/>
            <Value value="NORTH"/>
            <Value value="SOUTH"/>
            <Value value="WEST"/>
            <Value value="EAST"/>
        </DataField>
        <DataField name="period" optype="categorical" dataType="string">
            <Value value="ALL DAYS"/>
            <Value value="AM PEAK"/>
            <Value value="OFF PEAK"/>
            <Value value="PM PEAK"/>
            <Value value="WEEKDAYS"/>
            <Value value="WEEKENDS"/>
            <Value value="PUBLIC HOLIDAYS"/>
        </DataField>
        <DataField name="wgs84_latitude" optype="continuous" dataType="double"/>
        <DataField name="wgs84_longitude" optype="continuous" dataType="double"/>
    </DataDictionary>
    <TransformationDictionary>
        <DerivedField name="label" optype="categorical" dataType="double">
            <Apply function="if">
                <Apply function="lessOrEqual">
                    <FieldRef field="traffic_count"/>
                    <Constant dataType="double">10000.0</Constant>
                </Apply>
                <Constant dataType="double">0.0</Constant>
                <Constant dataType="double">1.0</Constant>
            </Apply>
            <Value value="0.0"/>
            <Value value="1.0"/>
        </DerivedField>
    </TransformationDictionary>
</PMML>
vruusmann commented 3 years ago

ValueError: Required element PMML/@isScorable=true is not defined

The uploaded PMML document does not contain any model elements.

You're asking the Openscoring server to "deploy a model", but you're giving it a model-less (transformation only) PMML document.

Try getting started with some valid/model-ful PMML document. For example, https://github.com/openscoring/openscoring/blob/master/openscoring-service/src/etc/DecisionTreeIris.pmml

chinyii commented 3 years ago

@vruusmann I see, I think I understand now, my piplineModel is inadequate. Do you have any resources for building pipeline models for pyspark on Jupyter Notebook? I was able to evaluate the model on Jupyter Notebook, so I thought I could just pmml the pipeline model. I really appreciate all the help you have given!

Edit: I can see the end product, but I am not so sure about the process for DecisionTreeIris.pmml

Try getting started with some valid/model-ful PMML document. For example, https://github.com/openscoring/openscoring/blob/master/openscoring-service/src/etc/DecisionTreeIris.pmml

vruusmann commented 3 years ago

I was able to evaluate the model on Jupyter Notebook, so I thought I could just pmml the pipeline model.

Apache Spark ML pipelines may be transformation-only. Your pipeline was just performing data transformations, it did not learn anything from the transformed data, so it's kind a half-way done anyway.

Do you have any resources for building pipeline models for pyspark on Jupyter Notebook?

There's nothing special about PMML wrt PySpark and/or Jupyter Notebooks.

Any model-ful pipeline should be okay. Just take your existing pipeline, and append a DecisionTreeRegressor or DecisionTreeClassifier to it (depending on the nature of the label column).

Alternatively, see this: https://openscoring.io/blog/2020/01/19/converting_logistic_regression_pmml/#apache-spark