Run the Problem Inspector locally causes to "Error: JSON.parse: unexpected character at line 1 column 1 of the JSON data" error
Hi All!
I'm runng a simple code using ising sampler (num_reads=100) with Problem inspector locally on my PC (Ocean virtualspace). I have no errors and successful opening the inspector on browser window.
Next I'm trying to run Problem inspector for a simple examples like structural-imbalance and graph-partitioning (with qubo sampler, num_reads=100). It works properly on D-Wave cloud IDE like this:
But locally causes to the next error in the opened browser window:
Error: JSON.parse: unexpected character at line 1 column 1 of the JSON data
Comments
Hello,
Are you able to give any additional information, such as more of the stack trace from the error?
You might want to try updating your local libraries to make sure they are on the latest version.
The IDE is on the latest version, so it might hint at an old library.
Thanks for your patience and for reaching out!
Hi, David!
Thank you for your attention. I updated my local libraries before running, so I have the latest version.
This error doesn't give me a stack trace in the python cli, it just prints my output, opens a web browser and timed out. But I am running python with -m trace --trace. You can see the last lines of the trace:
--- modulename: os, funcname: check_str
os.py(735): if not isinstance(value, str):
os.py(737): return value
os.py(673): except KeyError:
os.py(675): raise KeyError(key) from None
_collections_abc.py(667): except KeyError:
_collections_abc.py(668): return False
webbrowser.py(84): for name in _tryorder:
webbrowser.py(85): browser = get(name)
--- modulename: webbrowser, funcname: get
webbrowser.py(39): if _tryorder is None:
webbrowser.py(43): if using is not None:
webbrowser.py(44): alternatives = [using]
webbrowser.py(47): for browser in alternatives:
webbrowser.py(48): if '%s' in browser:
webbrowser.py(57): try:
webbrowser.py(58): command = _browsers[browser.lower()]
webbrowser.py(61): if command[1] is not None:
webbrowser.py(63): elif command[0] is not None:
webbrowser.py(64): return command[0]()
--- modulename: webbrowser, funcname: __init__
webbrowser.py(145): self.name = name
webbrowser.py(146): self.basename = name
webbrowser.py(86): if browser.open(url, new, autoraise):
--- modulename: webbrowser, funcname: open
webbrowser.py(601): sys.audit("webbrowser.open", url)
webbrowser.py(602): try:
webbrowser.py(603): os.startfile(url)
selectors.py(315): return r, w + x, []
selectors.py(326): r = set(r)
selectors.py(327): w = set(w)
selectors.py(328): for fd in r | w:
selectors.py(338): return ready
socketserver.py(234): if self.__shutdown_request:
socketserver.py(236): if ready:
socketserver.py(239): self.service_actions()
--- modulename: socketserver, funcname: service_actions
socketserver.py(260): pass
socketserver.py(231): while not self.__shutdown_request:
socketserver.py(232): ready = selector.select(poll_interval)
--- modulename: selectors, funcname: select
selectors.py(320): timeout = None if timeout is None else max(timeout, 0)
selectors.py(321): ready = []
selectors.py(322): try:
selectors.py(323): r, w, _ = self._select(self._readers, self._writers, [], timeout)
--- modulename: selectors, funcname: _select
selectors.py(314): r, w, x = select.select(r, w, w, timeout)
webbrowser.py(609): return True
webbrowser.py(87): return True
__init__.py(95): if block is Block.ONCE:
__init__.py(96): app_server.wait_problem_accessed(problem_id, timeout=timeout)
--- modulename: server, funcname: wait_problem_accessed
server.py(203): logger.debug('%s.wait_problem_accessed(problem_id=%r, timeout=%r)',
server.py(204): type(self).__name__, problem_id, timeout)
server.py(203): logger.debug('%s.wait_problem_accessed(problem_id=%r, timeout=%r)',
--- modulename: __init__, funcname: debug
__init__.py(1421): if self.isEnabledFor(DEBUG):
--- modulename: __init__, funcname: isEnabledFor
__init__.py(1681): if self.disabled:
__init__.py(1684): try:
__init__.py(1685): return self._cache[level]
__init__.py(1686): except KeyError:
__init__.py(1687): _acquireLock()
--- modulename: __init__, funcname: _acquireLock
__init__.py(220): if _lock:
__init__.py(221): _lock.acquire()
__init__.py(1688): try:
__init__.py(1689): if self.manager.disable >= level:
__init__.py(1693): level >= self.getEffectiveLevel()
--- modulename: __init__, funcname: getEffectiveLevel
__init__.py(1670): logger = self
__init__.py(1671): while logger:
__init__.py(1672): if logger.level:
__init__.py(1674): logger = logger.parent
__init__.py(1671): while logger:
__init__.py(1672): if logger.level:
__init__.py(1674): logger = logger.parent
__init__.py(1671): while logger:
__init__.py(1672): if logger.level:
__init__.py(1673): return logger.level
__init__.py(1692): is_enabled = self._cache[level] = (
__init__.py(1696): _releaseLock()
--- modulename: __init__, funcname: _releaseLock
__init__.py(227): if _lock:
__init__.py(228): _lock.release()
__init__.py(1697): return is_enabled
server.py(205): problem_access_sem[problem_id].acquire(blocking=True, timeout=timeout)
--- modulename: storage, funcname: <lambda>
storage.py(32): problem_access_sem = defaultdict(lambda: threading.Semaphore(value=0))
--- modulename: threading, funcname: __init__
threading.py(389): if value < 0:
threading.py(391): self._cond = Condition(Lock())
--- modulename: threading, funcname: __init__
threading.py(223): if lock is None:
threading.py(225): self._lock = lock
threading.py(227): self.acquire = lock.acquire
threading.py(228): self.release = lock.release
threading.py(232): try:
threading.py(233): self._release_save = lock._release_save
threading.py(234): except AttributeError:
threading.py(235): pass
threading.py(236): try:
threading.py(237): self._acquire_restore = lock._acquire_restore
threading.py(238): except AttributeError:
threading.py(239): pass
threading.py(240): try:
threading.py(241): self._is_owned = lock._is_owned
threading.py(242): except AttributeError:
threading.py(243): pass
threading.py(244): self._waiters = _deque()
threading.py(392): self._value = value
--- modulename: threading, funcname: acquire
threading.py(418): if not blocking and timeout is not None:
threading.py(420): rc = False
threading.py(421): endtime = None
threading.py(422): with self._cond:
--- modulename: threading, funcname: __enter__
threading.py(247): return self._lock.__enter__()
threading.py(423): while self._value == 0:
threading.py(424): if not blocking:
threading.py(426): if timeout is not None:
threading.py(433): self._cond.wait(timeout)
--- modulename: threading, funcname: wait
threading.py(293): if not self._is_owned():
--- modulename: threading, funcname: _is_owned
threading.py(264): if self._lock.acquire(0):
threading.py(268): return True
threading.py(295): waiter = _allocate_lock()
threading.py(296): waiter.acquire()
threading.py(297): self._waiters.append(waiter)
threading.py(298): saved_state = self._release_save()
--- modulename: threading, funcname: _release_save
threading.py(256): self._lock.release() # No state to save
threading.py(299): gotit = False
threading.py(300): try: # restore state no matter what (e.g., KeyboardInterrupt)
threading.py(301): if timeout is None:
threading.py(302): waiter.acquire()
selectors.py(315): return r, w + x, []
selectors.py(326): r = set(r)
selectors.py(327): w = set(w)
selectors.py(328): for fd in r | w:
selectors.py(338): return ready
socketserver.py(234): if self.__shutdown_request:
socketserver.py(236): if ready:
socketserver.py(239): self.service_actions()
--- modulename: socketserver, funcname: service_actions
socketserver.py(260): pass
socketserver.py(231): while not self.__shutdown_request:
socketserver.py(232): ready = selector.select(poll_interval)
--- modulename: selectors, funcname: select
selectors.py(320): timeout = None if timeout is None else max(timeout, 0)
selectors.py(321): ready = []
selectors.py(322): try:
selectors.py(323): r, w, _ = self._select(self._readers, self._writers, [], timeout)
--- modulename: selectors, funcname: _select
selectors.py(314): r, w, x = select.select(r, w, w, timeout)
selectors.py(315): return r, w + x, []
selectors.py(326): r = set(r)
selectors.py(327): w = set(w)
selectors.py(328): for fd in r | w:
selectors.py(338): return ready
socketserver.py(234): if self.__shutdown_request:
socketserver.py(236): if ready:
socketserver.py(239): self.service_actions()
--- modulename: socketserver, funcname: service_actions
socketserver.py(260): pass
socketserver.py(231): while not self.__shutdown_request:
socketserver.py(232): ready = selector.select(poll_interval)
--- modulename: selectors, funcname: select
selectors.py(320): timeout = None if timeout is None else max(timeout, 0)
selectors.py(321): ready = []
selectors.py(322): try:
selectors.py(323): r, w, _ = self._select(self._readers, self._writers, [], timeout)
Hello,
A few more questions that will help us debug the issue:
Thank you for your patience and understanding!
Hi, sorry,
I forgot to add that details:
Are you able to provide a screenshot that includes the JSON parse error?
If the error is happening in the browser, you could check the browser console to see if there are any errors in there. This would probably mean that the error is happening in the browser's JavaScript code. This might give some more context.
Can you share a minimal code example that reproduces the issue? Steps to reproduce could also help get us a little closer to understanding the problem.
If you could provide a pip freeze, we could confirm the versions of all of the libraries that are installed:
The -m trace --trace doesn't seem to have any information about the JSON error you had mentioned above.
We are not yet able to reproduce the issue you are seeing using the Python, OS, and browser versions you mentioned above.
How are you running Python? Are you using the Command Prompt, or an IDE/SDK on your local machine?
Are you able to run the code in Debug mode and set a break point to see what is contained in the JSON object? This is a lot easier to do locally with an IDE, and often you can set the Debug mode to break on errors. That way you could also get a stack trace if the error is happening in Python.
Daria,
You may be able to see what JSON the browser is trying to parse by using the View Page Source command in the browser page which is showing the JSON.parse error message.
I'll let David J. continue working with you, but thought this may help.
Ed
Hello, I am curious how did you solve this issue as I am facing the same problem.
However, I can't even have access to the problem inspector when I run my code on the online IDE.
Thank you!
(ps.: I changed my default browser from firefox to chrome and it doesn't affect, same error)
(pps.: when I try to use the problem inspector via the repl, I does work well!)
Jeremie
Hello,
Are you importing the problem inspector before instantiating and running the solver?
One thing to do is move all of your headers to the top of the file.
This way all of the hooks will be set up properly.
Please let us know if this helps resolve your issue.
If not, please provide us this some more information, possibly the exact error message or stack trace you are seeing.
Hello,
thanks for the answer! In fact this issue has disappeared a few hours later, doing the same thing I was able to acces the ICE from the online IDE or locally.
I have now another question, unrelated to this problem but important for me:
I want to use auto_scale = False for the problems I sample on the QPU. When I set auto_scale = False, the biases shown on the ICE are the good biases I want to apply, but the coupling values are doubled with regard to the sampled BQM. Is it an artifact of the ICE software or are the coupling really doubled even when auto_scale = False ?
Thank you!
Jeremie
Hello,
Sorry for all the questions, but I have an new one: I can access the ICE when I use dwave.inspector.show(sample) where sampler has been sample on the QPU with a forward annealing schedule. But when I do the same with a sample that has been obtained via reverse annealing I face this issue:
2022-02-16 16:45:57,073 dwave.inspector.server ERROR Thread-1 Exception on /api/problems/bca6018d-c583-4001-8767-596d4693bff0 [GET]
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2073, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1519, in full_dispatch_request
return self.finalize_request(rv)
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1538, in finalize_request
response = self.make_response(rv)
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1716, in make_response
rv = jsonify(rv)
File "/usr/local/lib/python3.7/site-packages/flask/json/__init__.py", line 355, in jsonify
f"{dumps(data, indent=indent, separators=separators)}\n",
File "/usr/local/lib/python3.7/site-packages/flask/json/__init__.py", line 133, in dumps
rv = _json.dumps(obj, **kwargs)
File "/usr/local/lib/python3.7/json/__init__.py", line 238, in dumps
**kw).encode(obj)
File "/usr/local/lib/python3.7/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/local/lib/python3.7/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/usr/local/lib/python3.7/site-packages/flask/json/__init__.py", line 57, in default
return super().default(o)
File "/usr/local/lib/python3.7/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type int8 is not JSON serializable
And I can't access the ICE on this problem. The sample seems to be fine as I can access all its elements. The only issue is about the ICE I would like to use...
Thank for any help!!
Jeremie
Hello,
Would you be able to repost your questions to new threads to improve on visibility for other community members and to improve searchability in the future?
It might also be helpful if you could include screenshots of what you are seeing to be clear.
I am not sure what you mean by ICE.
Are you referring to Integrated Control Errors?
https://docs.dwavesys.com/docs/latest/c_qpu_ice.html#qpu-ice-ranges
Do you mean the Problem Inspector?
For the coupler values if you could show a screen shot of where the coupler values look good and look doubled that would be helpful. Also a code example here will help us understand how you are submitting the problems.
Can you please give a complete code example that results in the stack trace from your second problem with reverse annealing? This will help us understand what you are seeing a bit better.
Again, if you could make a new thread for each error you are seeing then we can help you resolve these issues. I will start looking into the reverse annealing issue while we wait for you to create the new threads, and will follow up there. It's possible that the way the code is input is slightly different. It's very helpful if we can reproduce the problem you are seeing.
Thank you for your patience and coordination.
Please sign in to leave a comment.