Code Monkey home page Code Monkey logo

marvin_brain's Introduction

marvin_brain's People

Contributors

albireox avatar bretthandrews avatar havok2063 avatar marvin-manga avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

marvin_brain's Issues

request auth overrides any explicit authorization when .netrc file present

The Python requests package uses the .netrc file for authentication when the auth attribute is not set. However, when using auth tokens, and setting an explicit request header 'Authorization: Bearer <token>', requests overrides the input when a .netrc file is found and switches back to Basic auth. Removing the .netrc makes the request work as expected.

See here for the problem. psf/requests#3929

I think the solution, beyond abandoning tokens and sticking with .netrc auth, is to write a custom Auth class that accepts both, and pass it into the requests. My desired preference order is 1. token, 2. netrc.

Unclear API error when internet is down.

A student got this error while trying to run a relatively simple query. The problem ended being that her connection was stale. So, not really a "bug", but it would be good if we could provide a clearer error in this case.

Hi Jose. Here's the error. 

WARNING: No local database found. Cannot perform queries.
WARNING: local mode failed. Trying remote now.
Your parsed filter is: 
nsa.z<0.02
---------------------------------------------------------------------------
gaierror                                  Traceback (most recent call last)
/home/christina/anaconda3/lib/python3.6/site-packages/requests/packages/urllib3/connection.py in _new_conn(self)
    140             conn = connection.create_connection(
--> 141                 (self.host, self.port), self.timeout, **extra_kw)
    142 

/home/christina/anaconda3/lib/python3.6/site-packages/requests/packages/urllib3/util/connection.py in create_connection(address, timeout, source_address, socket_options)
     59 
---> 60     for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
     61         af, socktype, proto, canonname, sa = res

/home/christina/anaconda3/lib/python3.6/socket.py in getaddrinfo(host, port, family, type, proto, flags)
    742     addrlist = []
--> 743     for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
    744         af, socktype, proto, canonname, sa = res

gaierror: [Errno -3] Temporary failure in name resolution

During handling of the above exception, another exception occurred:

NewConnectionError                        Traceback (most recent call last)
/home/christina/anaconda3/lib/python3.6/site-packages/requests/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)
    599                                                   body=body, headers=headers,
--> 600                                                   chunked=chunked)
    601 

/home/christina/anaconda3/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
    344         try:
--> 345             self._validate_conn(conn)
    346         except (SocketTimeout, BaseSSLError) as e:

/home/christina/anaconda3/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py in _validate_conn(self, conn)
    843         if not getattr(conn, 'sock', None):  # AppEngine might not have  `.sock`
--> 844             conn.connect()
    845 

/home/christina/anaconda3/lib/python3.6/site-packages/requests/packages/urllib3/connection.py in connect(self)
    283         # Add certificate verification
--> 284         conn = self._new_conn()
    285 

/home/christina/anaconda3/lib/python3.6/site-packages/requests/packages/urllib3/connection.py in _new_conn(self)
    149             raise NewConnectionError(
--> 150                 self, "Failed to establish a new connection: %s" % e)
    151 

NewConnectionError: <requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fa05c0a60b8>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution

During handling of the above exception, another exception occurred:

MaxRetryError                             Traceback (most recent call last)
/home/christina/anaconda3/lib/python3.6/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
    422                     retries=self.max_retries,
--> 423                     timeout=timeout
    424                 )

/home/christina/anaconda3/lib/python3.6/site-packages/requests/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)
    648             retries = retries.increment(method, url, error=e, _pool=self,
--> 649                                         _stacktrace=sys.exc_info()[2])
    650             retries.sleep()

/home/christina/anaconda3/lib/python3.6/site-packages/requests/packages/urllib3/util/retry.py in increment(self, method, url, response, error, _pool, _stacktrace)
    375         if new_retry.is_exhausted():
--> 376             raise MaxRetryError(_pool, url, error or ResponseError(cause))
    377 

MaxRetryError: HTTPSConnectionPool(host='api.sdss.org', port=443): Max retries exceeded with url: /marvin2/api/query/cubes/ (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fa05c0a60b8>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))

During handling of the above exception, another exception occurred:

ConnectionError                           Traceback (most recent call last)
/home/christina/anaconda3/lib/python3.6/site-packages/marvin/extern/marvin_brain/python/brain/api/api.py in _sendRequest(self, request_type)
    143             elif request_type == 'post':
--> 144                 self._response = self.session.post(self.url, data=self.params, timeout=self.timeout)
    145         except requests.Timeout as rt:

/home/christina/anaconda3/lib/python3.6/site-packages/requests/sessions.py in post(self, url, data, json, **kwargs)
    534 
--> 535         return self.request('POST', url, data=data, json=json, **kwargs)
    536 

/home/christina/anaconda3/lib/python3.6/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)
    487         send_kwargs.update(settings)
--> 488         resp = self.send(prep, **send_kwargs)
    489 

/home/christina/anaconda3/lib/python3.6/site-packages/raven/breadcrumbs.py in send(self, request, *args, **kwargs)
    296         try:
--> 297             resp = real_send(self, request, *args, **kwargs)
    298         except Exception:

/home/christina/anaconda3/lib/python3.6/site-packages/requests/sessions.py in send(self, request, **kwargs)
    608         # Send the request
--> 609         r = adapter.send(request, **kwargs)
    610 

/home/christina/anaconda3/lib/python3.6/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
    486 
--> 487             raise ConnectionError(e, request=request)
    488 

ConnectionError: HTTPSConnectionPool(host='api.sdss.org', port=443): Max retries exceeded with url: /marvin2/api/query/cubes/ (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fa05c0a60b8>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))

During handling of the above exception, another exception occurred:

BrainError                                Traceback (most recent call last)
/home/christina/anaconda3/lib/python3.6/site-packages/marvin/tools/query/query.py in run(self, qmode)
    785             try:
--> 786                 ii = Interaction(route=url, params=params)
    787             except Exception as e:

/home/christina/anaconda3/lib/python3.6/site-packages/marvin/extern/marvin_brain/python/brain/api/api.py in __init__(self, route, params, request_type, auth, timeout)
     41         if self.url:
---> 42             self._sendRequest(request_type)
     43         else:

/home/christina/anaconda3/lib/python3.6/site-packages/marvin/extern/marvin_brain/python/brain/api/api.py in _sendRequest(self, request_type)
    152             self._closeRequestSession()
--> 153             raise BrainError('Requests Connection Error: {0}'.format(con))
    154         except requests.RequestException as req:

BrainError: Requests Connection Error: HTTPSConnectionPool(host='api.sdss.org', port=443): Max retries exceeded with url: /marvin2/api/query/cubes/ (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fa05c0a60b8>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))

During handling of the above exception, another exception occurred:

MarvinError                               Traceback (most recent call last)
<ipython-input-22-e2f1fa1db4d4> in <module>()
      8 #set up the query so that it can be run
      9 q = Query(searchfilter = filter, returnparams = params)
---> 10 r = q.run()

/home/christina/anaconda3/lib/python3.6/site-packages/marvin/tools/query/query.py in wrapper(self, *args, **kwargs)
     94         if not self.query and self.mode == 'local':
     95             self._createBaseQuery()
---> 96         return f(self, *args, **kwargs)
     97     return wrapper
     98 

/home/christina/anaconda3/lib/python3.6/site-packages/marvin/tools/query/query.py in wrapper(self, *args, **kwargs)
    106         if self.mode == 'local' and self.filterparams and not self._alreadyInFilter(self.filterparams.keys()):
    107             self.add_condition()
--> 108         return f(self, *args, **kwargs)
    109 
    110     return wrapper

/home/christina/anaconda3/lib/python3.6/site-packages/marvin/tools/query/query.py in wrapper(self, *args, **kwargs)
     82         if self.query and self.mode == 'local':
     83             self.query = self.query.params({'drpver': self._drpver, 'dapver': self._dapver})
---> 84         return f(self, *args, **kwargs)
     85     return wrapper
     86 

/home/christina/anaconda3/lib/python3.6/site-packages/marvin/tools/query/query.py in run(self, qmode)
    788                 # if a remote query fails for any reason, then try to clean them up
    789                 # self._cleanUpQueries()
--> 790                 raise MarvinError('API Query call failed: {0}'.format(e))
    791             else:
    792                 res = ii.getData()

MarvinError: API Query call failed: Requests Connection Error: HTTPSConnectionPool(host='api.sdss.org', port=443): Max retries exceeded with url: /marvin2/api/query/cubes/ (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fa05c0a60b8>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)).
You can submit this error to Marvin GitHub Issues (https://github.com/sdss/marvin/issues/new).
Fill out a subject and some text describing the error that just occurred.
If able, copy and paste the full traceback information into the issue as well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.