I am running a code using bokeh to display interactive plots. it was working fine until suddenly i get error related to tornado. I have installed latest version of bokeh and tornado but it does not solve the problem.the traceback is very long :
I am using pyarpes code developped for apres data reduction pyarpes:
import arpes
from arpes.io import(load_example_data, load_without_dataset, direct_load)
from arpes.utilities import default_dataset
from arpes.utilities.conversion import convert_to_kspace
from arpes.utilities.conversion import *
from arpes.fits import *
from pathlib import Path
import arpes.corrections
import arpes.plotting
from arpes.analysis import *
from arpes.provenance import update_provenance
#DIRECT DATA LOADING test
p = Path('.')/'arpes'/'example_data'/'test.nxs'
load_without_dataset(p)
f = load_without_dataset(p, location='xxx')
data = f.sel(psi=2, phi=slice(-0.01, 0.07), eV=slice(95.2, 96.5)).transpose('eV', 'phi') # pocket selection
data_mean = (data - data.mean('eV')) # background substraction
data_mean.S.show()
ERROR:tornado.application:Uncaught exception GET /autoload.js?bokeh-autoload-element=1001&bokeh-absolute-url=http://localhost:52526&resources=none (127.0.0.1)
HTTPServerRequest(protocol='http', host='localhost:52526', method='GET', uri='/autoload.js?bokeh-autoload-element=1001&bokeh-absolute-url=http://localhost:52526&resources=none', version='HTTP/1.1', remote_ip='127.0.0.1')
Traceback (most recent call last):
File "C:\Users\xxx\Anaconda3\lib\site-packages\tornado\web.py", line 1704, in _execute
result = await result
File "C:\Users\xxx\Anaconda3\lib\site-packages\bokeh\server\views\autoload_js_handler.py", line 60, in get
session = await self.get_session()
File "C:\Users\xxx\Anaconda3\lib\site-packages\bokeh\server\views\session_handler.py", line 120, in get_session
session = await self.application_context.create_session_if_needed(session_id, self.request, token)
File "C:\Users\xxx\Anaconda3\lib\site-packages\bokeh\server\contexts.py", line 218, in create_session_if_needed
self._application.initialize_document(doc)
File "C:\Users\xxx\Anaconda3\lib\site-packages\bokeh\application\application.py", line 171, in initialize_document
h.modify_document(doc)
File "C:\Users\xxx\Anaconda3\lib\site-packages\bokeh\application\handlers\function.py", line 132, in modify_document
self._func(doc)
File "C:\Users\xxx\arpes\arpes\plotting\interactive.py", line 43, in tool_handler
return self.tool_handler_2d(doc)
File "C:\Users\xxx\arpes\arpes\plotting\interactive.py", line 225, in tool_handler_2d
color_mode_dropdown.on_change('value', on_change_color_mode)
File "C:\Users\xxx\Anaconda3\lib\site-packages\bokeh\model.py", line 551, in on_change
descriptor = self.lookup(attr)
File "C:\Users\xxx\Anaconda3\lib\site-packages\bokeh\core\has_props.py", line 492, in lookup
raise AttributeError(f"{cls.__name__}.{name} property descriptor does not exist")
AttributeError: Dropdown.value property descriptor does not exist
ERROR:tornado.access:500 GET /autoload.js?bokeh-autoload-element=1001&bokeh-absolute-url=http://localhost:52526&resources=none (127.0.0.1) 80.00ms
thanks for helping
Related
I'm trying to get data from a resource: novel-coronavirus-2019-ncov-cases from the site Humanitarian Data Exchang. Previously everything was fine, I updated the library hdx-python-api==5.9.7 to the latest version and I get the following error:
Traceback (most recent call last):
File "/home/user/dashboard/scripts/jhu.py", line 31, in <module>
Configuration.create(hdx_site="prod", user_agent="A_Quick_Example", hdx_read_only=True)
File "/home/user/anaconda3/lib/python3.8/site-packages/hdx/api/configuration.py", line 647, in create
return cls._create(
File "/home/user/anaconda3/lib/python3.8/site-packages/hdx/api/configuration.py", line 607, in _create
cls._configuration.setup_session_remoteckan(remoteckan, **kwargs)
File "/home/user/anaconda3/lib/python3.8/site-packages/hdx/api/configuration.py", line 471, in setup_session_remoteckan
self._session, user_agent = self.create_session_user_agent(
File "/home/user/anaconda3/lib/python3.8/site-packages/hdx/api/configuration.py", line 436, in create_session_user_agent
session = get_session(
File "/home/user/anaconda3/lib/python3.8/site-packages/hdx/utilities/session.py", line 173, in get_session
retries = Retry(
TypeError: __init__() got an unexpected keyword argument 'allowed_methods'
Which clearly refers me to a configuration error. I only need to download the data, so I'm using the read configuration example that was given in the official documentation.
Example code:
from hdx.api.configuration import Configuration
from hdx.data.dataset import Dataset
Configuration.create(hdx_site='prod', user_agent='A_Quick_Example', hdx_read_only=True)
def save(direct):
datasets = Dataset.read_from_hdx('novel-coronavirus-2019-ncov-cases')
print(datasets.get_date_of_dataset())
resources = Dataset.get_all_resources(datasets)
for res in resources:
url, path = res.download(folder=direct)
print('Resource URL %s downloaded to %s' % (url, path))
Can you help to solve this error?
from Adafruit_IO import *
aio = Client('user','key' )
value = 42
aio.send('communicationWeb',value)
I have developed this program to send information to my cloud adafruit when I run it, I've got this error:
Traceback (most recent call last):
File "/home/pi/Desktop/communication_mqtt/v2d.py", line 5, in <module>
aio.send('communicationWeb',value)
File "/home/pi/.local/lib/python3.9/site-packages/Adafruit_IO/client.py", line 167, in send_data
return self.create_data(feed, payload)
File "/home/pi/.local/lib/python3.9/site-packages/Adafruit_IO/client.py", line 313, in create_data
return Data.from_dict(self._post(path, data._asdict()))
File "/home/pi/.local/lib/python3.9/site-packages/Adafruit_IO/client.py", line 139, in _post
self._handle_error(response)
File "/home/pi/.local/lib/python3.9/site-packages/Adafruit_IO/client.py", line 117, in _handle_error
raise RequestError(response)
Adafruit_IO.errors.RequestError: Adafruit IO request failed: 404 Not Found - not found - API documentation can be found at https://io.adafruit.com/api/docs
When I use the function print(client.get_account()) this is my code followed by the output
from binance.client import Client,
import pandas as pd,
import mplfinance as mpl,
import numpy as np,
import os,
import matplotlib.pyplot as plt,
#I set up my credential for this api
api_key = '(my credential)'
api_secret= '(my credential)'
client=Client(api_key,api_secret)
print(client.get_account())
output
Traceback (most recent call last):
File "c:\Users\berge\OneDrive\Documents\Binance Bot\Mean_Reversion.py", line 13, in <module>
print(client.get_account())
File "C:\Users\berge\OneDrive\Documents\Binance Bot\.venv\lib\site-packages\binance\client.py", line 1956, in get_account
return self._get('account', True, data=params)
File "C:\Users\berge\OneDrive\Documents\Binance Bot\.venv\lib\site-packages\binance\client.py", line 371, in _get
return self._request_api('get', path, signed, version, **kwargs)
File "C:\Users\berge\OneDrive\Documents\Binance Bot\.venv\lib\site-packages\binance\client.py", line 334, in _request_api
return self._request(method, uri, signed, **kwargs)
File "C:\Users\berge\OneDrive\Documents\Binance Bot\.venv\lib\site-packages\binance\client.py", line 315, in _request
return self._handle_response(self.response)
File "C:\Users\berge\OneDrive\Documents\Binance Bot\.venv\lib\site-packages\binance\client.py", line 324, in _handle_response
raise BinanceAPIException(response, response.status_code, response.text)
binance.exceptions.BinanceAPIException: APIError(code=-1021): Timestamp for this request is outside of the recvWindow.
This is a very common problem, and the solution is very simple. For the Binance API to work, your system time should be synced with the Binance time.
Fix: In Windows, go to your Date & Time setting and click on "Sync now". Voila! fixed.
I've been wanting to start a small spotify-based project and I'm currently trying to utilize python to create a playlist using the spotipy library as such:
from spotipy.oauth2 import SpotifyClientCredentials
from spotipy.oauth2 import SpotifyOAuth
import spotipy.util as util
scope = 'playlist-modify-public'
username = 'aaronang_'
token = SpotifyOAuth(scope=scope,username=username)
spotifyObject = spotipy.Spotify(auth_manager = token)
playlist_name = input("Enter a playlistname:")
playlist_description = input("Enter a playlist description:")
spotifyObject.user_playlist_create(user=username,name=playlist_name,public=True,description=playlist_description)
I set my client id,client secret and redirect uri in terminal's virtual environment(venv) yet using:
set CLIENT_ID=c3032b421ce94......9a05abcb623da
set CLIENT_SECRET=32a9c32611......5b69cf643f7c33e
set CLIENT_REDIRECT_URI=http://127.0.0.1:8080/
I end up getting this error:
Traceback (most recent call last):
File "C:\Users\Aaron\spotifyPlaylist.py", line 17, in <module>
spotifyObject.user_playlist_create(user=username,name=playlist_name,public=True,description=playlist_description)
File "C:\Users\Aaron\venv\lib\site-packages\spotipy\client.py", line 784, in user_playlist_create
return self._post("users/%s/playlists" % (user,), payload=data)
File "C:\Users\Aaron\venv\lib\site-packages\spotipy\client.py", line 302, in _post
return self._internal_call("POST", url, payload, kwargs)
File "C:\Users\Aaron\venv\lib\site-packages\spotipy\client.py", line 221, in _internal_call
headers = self._auth_headers()
File "C:\Users\Aaron\venv\lib\site-packages\spotipy\client.py", line 212, in _auth_headers
token = self.auth_manager.get_access_token(as_dict=False)
File "C:\Users\Aaron\venv\lib\site-packages\spotipy\oauth2.py", line 525, in get_access_token
token_info = self.validate_token(self.cache_handler.get_cached_token())
File "C:\Users\Aaron\venv\lib\site-packages\spotipy\oauth2.py", line 380, in validate_token
token_info = self.refresh_access_token(
File "C:\Users\Aaron\venv\lib\site-packages\spotipy\oauth2.py", line 596, in refresh_access_token
self._handle_oauth_error(http_error)
File "C:\Users\Aaron\venv\lib\site-packages\spotipy\oauth2.py", line 146, in _handle_oauth_error
raise SpotifyOauthError(
spotipy.oauth2.SpotifyOauthError: error: invalid_client, error_description: Invalid client
I've seen this code work for others, yet my token won't validate. I've got a token from https://developer.spotify.com/console/put-playlist-tracks/ which worked.
Thanks.
I want to create a service in existing swarm network using python docker sdk. I have a swarm network named test_net.
Installation of library : pip3 install docker
Below is the code used for creating the service
import docker
from docker.types import RestartPolicy, Placement
def python_sdk():
client = docker.DockerClient(base_url='unix://var/run/docker.sock')
service_created = client.services.create(
image='python:3.7-alpine',
command='python /home/ubuntu/python.py',
constraints=Placement(constraints=['worker']),
mounts='/home/ubuntu/deployment/python.py:/home/ubuntu/python.py:rw',
networks=['test_net'],
restart_policy=RestartPolicy(condition='none'),
name='python_sdk'
)
print("Created service : ", service_created)
Below is the error which I got by executing above code :
Traceback (most recent call last):
File "/home/ubuntu/deployment/dags/venv/lib/python3.6/site-packages/docker/api/client.py", line 268, in _raise_for_status
response.raise_for_status()
File "/home/ubuntu/deployment/dags/venv/lib/python3.6/site-packages/requests/models.py", line 943, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http+docker://localhost/v1.41/services/create
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "client.py", line 20, in <module>
python_sdk()
File "client.py", line 16, in python_sdk
name='python_sdk'
File "/home/ubuntu/deployment/dags/venv/lib/python3.6/site-packages/docker/models/services.py", line 227, in create
service_id = self.client.api.create_service(**create_kwargs)
File "/home/ubuntu/deployment/dags/venv/lib/python3.6/site-packages/docker/utils/decorators.py", line 34, in wrapper
return f(self, *args, **kwargs)
File "/home/ubuntu/deployment/dags/venv/lib/python3.6/site-packages/docker/api/service.py", line 190, in create_service
self._post_json(url, data=data, headers=headers), True
File "/home/ubuntu/deployment/dags/venv/lib/python3.6/site-packages/docker/api/client.py", line 274, in _result
self._raise_for_status(response)
File "/home/ubuntu/deployment/dags/venv/lib/python3.6/site-packages/docker/api/client.py", line 270, in _raise_for_status
raise create_api_error_from_http_exception(e)
File "/home/ubuntu/deployment/dags/venv/lib/python3.6/site-packages/docker/errors.py", line 31, in create_api_error_from_http_exception
raise cls(e, response=response, explanation=explanation)
docker.errors.APIError: 400 Client Error for http+docker://localhost/v1.41/services/create: Bad Request ("json: cannot unmarshal object into Go struct field Placement.TaskTemplate.Placement.Constraints of type []string")
I am referring to this documentation.
How can I use Placement object to use constraints?
I also tried constraints = ["Placement(constraints=['worker']"]
I got the answer for the above issue. In the documentation, it is mentioned that the list of str needs to be passed in constraints.
The mentioned parameter is documentation : constraints (list of str) – Placement constraints.
So the final code will be,
import docker
from docker.types import RestartPolicy, Placement
def python_sdk():
client = docker.DockerClient(base_url='unix://var/run/docker.sock')
service_created = client.services.create(
image='python:3.7-alpine',
command='python /home/ubuntu/python.py',
constraints=['node.role == worker']),
mounts='/home/ubuntu/deployment/python.py:/home/ubuntu/python.py:rw',
networks=['test_net'],
restart_policy=RestartPolicy(condition='none'),
name='python_sdk'
)
print("Created service : ", service_created)