Forum Discussion
Python visual requieres to open a file in the service
Hi juan_pablo ,
If you've fixed the issue on your own please kindly share your solution. If the above posts help, please kindly mark it as a solution to help others find it more quickly. Thanks!
Best Regards,
Yingjie Li
Hi v-yingjl
No, unfortunately I haven't found a solution.
I decided to open the file from an S3 in AWS (Amazon) as lbendlin suggested. This work great in the Desktop version, but as soon as I publish the report to the Service, it breaks.
Your solution didn't work for me because I still need to have interactivity in the visual (I need other filters to affect the visual because they are the input to the model).
lbendlin Do you know how to make the connection to the web server accessible from Power BI Service?
This is a summary of what I have so far:
link = "https://xxxxxx.s3.amazonaws.com/models/linear_model_v1.pkl"
def predict_sq_meter_value(apartments):
try:
lin_model_v0
except:
lin_model_v0 = pickle.load(urllib.request.urlopen(link))
...
The last line "pickle.load(urllib.request.urlopen(link))" is the one that breaks when published to the PBI Service, but in the Desktop works as expected.
This is the error I get in the published report
Script Runtime Error
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Python\Lib\http\client.py", line 1298, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Python\Lib\http\client.py", line 1247, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Python\Lib\http\client.py", line 1026, in _send_output
self.send(msg)
File "C:\Python\Lib\http\client.py", line 966, in send
self.connect()
File "C:\Python\Lib\http\client.py", line 1414, in connect
super().connect()
File "C:\Python\Lib\http\client.py", line 938, in connect
(self.host,self.port), self.timeout, self.source_address)
File "C:\Python\Lib\socket.py", line 707, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "C:\Python\Lib\socket.py", line 752, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11001] getaddrinfo failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Script\0.py", line 92, in <module>
sq_val, tot_val = predict_sq_meter_value(property)
File "C:\Script\0.py", line 39, in predict_sq_meter_value
lin_model_v0 = pickle.load(urllib.request.urlopen(link))
File "C:\Python\Lib\urllib\request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "C:\Python\Lib\urllib\request.py", line 525, in open
response = self._open(req, data)
File "C:\Python\Lib\urllib\request.py", line 543, in _open
'_open', req)
File "C:\Python\Lib\urllib\request.py", line 503, in _call_chain
result = func(*args)
File "C:\Python\Lib\urllib\request.py", line 1362, in https_open
context=self._context, check_hostname=self._check_hostname)
File "C:\Python\Lib\urllib\request.py", line 1321, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 11001] getaddrinfo failed>
Please try again later or contact support. If you contact support, please provide these details.
Activity ID: 28e08314-3838-462e-b4ec-5de753c8fb15
Request ID: 80f03bdf-612e-aa34-1a41-e45de7239e1a
Correlation ID: f0bea7a5-a996-d6a4-6786-0c24eecfbb45
Time: Tue Jul 28 2020 10:39:59 GMT-0500 (Colombia Standard Time)
Service version: 13.0.13960.55
Client version: 2007.3.02011-train
Cluster URI: https://wabi-south-central-us-redirect.analysis.windows.net/
Any ideas on how can I solve this? I think I'm very close.
- lbendlin6 years ago
Super User
The service doesn't know how to reach the file on AWS. maybe an authentication issue?
For fun you could try this on the gateway to see if you get a different error message there. (yes, I know, gateway isn't really required)
- juan_pablo6 years ago
Helper V
lbendlin The AWS is running ok, in fact I can acces the pkl file from my PBI Desktop file using the same code or using any python console.
What do you mean by "try this on the gateway"?
I already have a gateway installed and connected to the report.
- lbendlin6 years ago
Super User
Ah, it's a personal gateway. I forgot that Python/R need that. Ignore me.