Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSConceptGraph.ipynb #232

Open
mouseart opened this issue Jul 25, 2023 · 2 comments
Open

MSConceptGraph.ipynb #232

mouseart opened this issue Jul 25, 2023 · 2 comments

Comments

@mouseart
Copy link

mouseart commented Jul 25, 2023

https://github.com/microsoft/AI-For-Beginners/blob/main/lessons/2-Symbolic/MSConceptGraph.ipynb Unable to function properly
I tried running in VS Code environment
https://github.com/microsoft/AI-For-Beginners/blob/main/lessons/2-Symbolic/MSConceptGraph.ipynb The first paragraph of code for:

import urllib
import json
import ssl

def http(x):
    ssl._create_default_https_context = ssl._create_unverified_context
    response = urllib.request.urlopen(x)
    data = response.read()
    return data.decode('utf-8')

def query(x):
    return json.loads(http("https://concept.research.microsoft.com/api/Concept/ScoreByProb?instance={}&topK=10".format(urllib.parse.quote(x))))

query('microsoft')

But the following error prompt appears:

SSLZeroReturnError Traceback (most recent call last)
File~/. yenv/versions/3.9.7/lib/python3.9/urllib/request. py: 1346, in AbstractHTTPHandler.do_ Open (self, http_class, req, * * http_conn_args)
1345 try:
->1346 h. request (req. get_method(), req. selector, req. data, headers,
1347 encode_ Chunked=req.has_ Header ('Transfer encoding ')
1348 except OSError as err: # timeout error
File~/. pyenv/versions/3.9.7/lib/python3.9/http/client.py:1279, in HTTPConnection.request (self, method, URL, body, headers, encode_chunked)
Send a complete request to the server
->1279 self_ Send_ Request (method, URL, body, headers, encode_chunked)
File~/. yenv/versions/3.9.7/lib/python3.9/http/client.py:1325, in HTTPConnection_ Send_ Request (self, method, URL, body, headers, encode_chunked)
1324 body=_ Encode (body, 'body')
->1325 self. endheaders (body, encode_chunked=encode_chunked)
File~/. pyenv/versions/3.9.7/lib/python3.9/http/client.py:1274, in HTTPConnection. endheaders (self, messagebody, encode_chunked)
1273 raise CannotSendHeader()
->1274 self_ Send_ Output (messagebody, encode_chunked=encode_chunked)
File~/. yenv/versions/3.9.7/lib/python3.9/http/client.py: 1034, in HTTPConnection_ Send_ Output (self, messagebody, encode_chunked)
1033 del self_ Buffer [:]
->1034 self. send (msg)
1036 if message_ Body is not None:
one thousand and thirty-seven
->1349 raise URLError (err)
1350 r=h. getresponse()
1351 exception:
URLError:
Output is truncated View as a scrollable element or open in a text editor Adjust cell output settings

What went wrong and how should I make the necessary modifications?
Thank you very much to those who can provide help.

@omar908
Copy link
Contributor

omar908 commented Aug 10, 2023

Hi @mouseart!

Just tested it myself, I am getting a timeout error as well.

Looking into it, looks like the website we are trying to obtain the JSON from is no longer available. Which would cause the timeout issue we are both seeing.

image

If there was a URL with the same JSON this one hosted previously we could use that, or if someone can get a copy it could be added to the project itself, I would think.

Sorry this isn't much of a solution, but wanted to clarify it is not an issue on your end at least.


UPDATE
Using "Wayback Machine", we can see the format of the JSON that was expected to be retrieved.

https://web.archive.org/web/20220330074751/https://concept.research.microsoft.com/Home/API

image

Technically, someone could re-create the JSON data into a local file, add it to the repo and adjust the code to load it, to mimic the results being retrieved. Test that it works correctly and has the expected results.

@mouseart
Copy link
Author

Hi @mouseart!

Just tested it myself, I am getting a timeout error as well.

Looking into it, looks like the website we are trying to obtain the JSON from is no longer available. Which would cause the timeout issue we are both seeing.

image

If there was a URL with the same JSON this one hosted previously we could use that, or if someone can get a copy it could be added to the project itself, I would think.

Sorry this isn't much of a solution, but wanted to clarify it is not an issue on your end at least.

UPDATE Using "Wayback Machine", we can see the format of the JSON that was expected to be retrieved.

https://web.archive.org/web/20220330074751/https://concept.research.microsoft.com/Home/API

image

Technically, someone could re-create the JSON data into a local file, add it to the repo and adjust the code to load it, to mimic the results being retrieved. Test that it works correctly and has the expected results.

Thank you for your feedback. I roughly understand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants