How can I get a MPCONTRIBS_API_KEY?

Hello:
I want to retrieve some carrier transport data from MPCONTRIBS.
But I find I don’t know how to get a MPCONTRIBS_API_KEY from https://contribs-api.materialsproject.org/ .
If I just set client = Client(), there will be an error “OverflowError: timeout value is too large”.
So, How can I solve it?

You can find your API key in the drop down menu in the upper right of the website (Hover over the person icon after login). As for the Overflow error, it sounds like you’re using windows. Which version of the client did you install? 3.8.0 and later should include a fix.

Tanks for your reply, and I have obtain my API key. I have checked that the version of mpcontribs-client I installed is 3.8.3 using Windows. But when I run “client = Client(host = ‘API KEY’)”, I still meet an error about “OverflowError: timeout value is too large”.

Using your API key as host won’t work. Please try client = Client(apikey="YOUR-API-KEY"). The timeout error is likely caused by the client trying to connect to the wrong host.

There is still the mistake about “OverflowError: timeout value is too large” when I run :
from mpcontribs.client import Client
client = Client(apikey=“YOUR-API-KEY”)
Can you run it successfully? Maybe I have to check it again.

The error is as follows:

OverflowError Traceback (most recent call last)
in
2 from mpcontribs.client import Client
3 #name = ‘carrier_transport’
----> 4 a = Client()

D:\Anaconda\anzjhuang\lib\site-packages\mpcontribs\client_init_.py in init(self, apikey, headers, host)
168 and self.swagger_spec.http_client.headers != self.headers
169 ):
→ 170 self.load()
171
172 def load(self):

D:\Anaconda\anzjhuang\lib\site-packages\mpcontribs\client_init_.py in load(self)
174 loader = Loader(http_client)
175 origin_url = f"{self.url}/apispec.json"
→ 176 spec_dict = loader.load_spec(origin_url)
177 spec_dict[“host”] = self.host
178 spec_dict[“schemes”] = [self.protocol]

D:\Anaconda\anzjhuang\lib\site-packages\bravado\swagger_model.py in load_spec(self, spec_url, base_url)
99 :returns: json spec in dict form
100 “”"
→ 101 response = request(
102 self.http_client,
103 spec_url,

D:\Anaconda\anzjhuang\lib\site-packages\bravado\http_future.py in result(self, timeout)
268 to the constructor.
269 “”"
→ 270 incoming_response = self._get_incoming_response(timeout)
271 swagger_result = self._get_swagger_result(incoming_response)
272

D:\Anaconda\anzjhuang\lib\site-packages\bravado\http_future.py in wrapper(self, *args, **kwargs)
122
123 try:
→ 124 return func(self, *args, **kwargs)
125 except connection_errors as exception:
126 self.future._raise_connection_error(exception)

D:\Anaconda\anzjhuang\lib\site-packages\bravado\http_future.py in _get_incoming_response(self, timeout)
289 def _get_incoming_response(self, timeout=None):
290 # type: (typing.Optional[float]) → IncomingResponse
→ 291 inner_response = self.future.result(timeout=timeout)
292 incoming_response = self.response_adapter(inner_response)
293 return incoming_response

D:\Anaconda\anzjhuang\lib\site-packages\bravado\fido_client.py in result(self, timeout)
125 # crochet.TimeoutError into a fido.exceptions.HttpTimeoutError.
126 try:
→ 127 return self._eventual_result.wait(timeout=timeout)
128 except fido.exceptions.HTTPTimeoutError:
129 # Since fido.exceptions.HttpTimeoutError is a subclass of

D:\Anaconda\anzjhuang\lib\site-packages\crochet_eventloop.py in wait(self, timeout)
237 “import time.”)
238
→ 239 result = self._result(timeout)
240 if isinstance(result, Failure):
241 result.raiseException()

D:\Anaconda\anzjhuang\lib\site-packages\crochet_eventloop.py in _result(self, timeout)
195 # Queue.get(None) won’t get interrupted by Ctrl-C…
196 timeout = 2 ** 28
→ 197 self._result_set.wait(timeout)
198 # In Python 2.6 we can’t rely on the return result of wait(), so we
199 # have to check manually:

D:\Anaconda\anzjhuang\lib\threading.py in wait(self, timeout)
556 signaled = self._flag
557 if not signaled:
→ 558 signaled = self._cond.wait(timeout)
559 return signaled
560

D:\Anaconda\anzjhuang\lib\threading.py in wait(self, timeout)
304 else:
305 if timeout > 0:
→ 306 gotit = waiter.acquire(True, timeout)
307 else:
308 gotit = waiter.acquire(False)

OverflowError: timeout value is too large

Thanks for reporting the traceback. I’ll take a second look. Just to confirm: You’re working on a Window machine, in a new conda environment, and with python 3.9? Thanks!

I got a same error on Windows machine, conda environment with python 3.8

from mpcontribs.client import Client
name = ‘carrier_transport’
client = Client()

---------------------------------------------------------------------------

OverflowError Traceback (most recent call last)
in
2 from mpcontribs.client import Client
3 name = ‘carrier_transport’
----> 4 client = Client()

~.conda\envs\pytorch\lib\site-packages\mpcontribs\client_init_.py in init(self, apikey, headers, host)
168 and self.swagger_spec.http_client.headers != self.headers
169 ):
→ 170 self.load()
171
172 def load(self):

~.conda\envs\pytorch\lib\site-packages\mpcontribs\client_init_.py in load(self)
174 loader = Loader(http_client)
175 origin_url = f"{self.url}/apispec.json"
→ 176 spec_dict = loader.load_spec(origin_url)
177 spec_dict[“host”] = self.host
178 spec_dict[“schemes”] = [self.protocol]

~.conda\envs\pytorch\lib\site-packages\bravado\swagger_model.py in load_spec(self, spec_url, base_url)
99 :returns: json spec in dict form
100 “”"
→ 101 response = request(
102 self.http_client,
103 spec_url,

~.conda\envs\pytorch\lib\site-packages\bravado\http_future.py in result(self, timeout)
268 to the constructor.
269 “”"
→ 270 incoming_response = self._get_incoming_response(timeout)
271 swagger_result = self._get_swagger_result(incoming_response)
272

~.conda\envs\pytorch\lib\site-packages\bravado\http_future.py in wrapper(self, *args, **kwargs)
122
123 try:
→ 124 return func(self, *args, **kwargs)
125 except connection_errors as exception:
126 self.future._raise_connection_error(exception)

~.conda\envs\pytorch\lib\site-packages\bravado\http_future.py in _get_incoming_response(self, timeout)
289 def _get_incoming_response(self, timeout=None):
290 # type: (typing.Optional[float]) → IncomingResponse
→ 291 inner_response = self.future.result(timeout=timeout)
292 incoming_response = self.response_adapter(inner_response)
293 return incoming_response

~.conda\envs\pytorch\lib\site-packages\bravado\fido_client.py in result(self, timeout)
125 # crochet.TimeoutError into a fido.exceptions.HttpTimeoutError.
126 try:
→ 127 return self._eventual_result.wait(timeout=timeout)
128 except fido.exceptions.HTTPTimeoutError:
129 # Since fido.exceptions.HttpTimeoutError is a subclass of

~.conda\envs\pytorch\lib\site-packages\crochet_eventloop.py in wait(self, timeout)
237 “import time.”)
238
→ 239 result = self._result(timeout)
240 if isinstance(result, Failure):
241 result.raiseException()

~.conda\envs\pytorch\lib\site-packages\crochet_eventloop.py in _result(self, timeout)
195 # Queue.get(None) won’t get interrupted by Ctrl-C…
196 timeout = 2 ** 28
→ 197 self._result_set.wait(timeout)
198 # In Python 2.6 we can’t rely on the return result of wait(), so we
199 # have to check manually:

~.conda\envs\pytorch\lib\threading.py in wait(self, timeout)
556 signaled = self._flag
557 if not signaled:
→ 558 signaled = self._cond.wait(timeout)
559 return signaled
560

~.conda\envs\pytorch\lib\threading.py in wait(self, timeout)
304 else:
305 if timeout > 0:
→ 306 gotit = waiter.acquire(True, timeout)
307 else:
308 gotit = waiter.acquire(False)

OverflowError: timeout value is too large

So pity, I still haven’t solved the problem.

Hi @hitxuer and @11137,

sorry I missed your messages. I have tests in place for the latest windows, and python versions 3.7 / 3.8 / 3.9. They all succeeded for the latest release of mpcontribs-client 3.8.7: dependabot PRs · materialsproject/MPContribs@67bb9a6 · GitHub

Could you try this version in a fresh conda environment (see below) and report back? Also, please make sure to not share your API key here. You can set the environment variable MPCONTRIBS_API_KEY and it should be picked up automatically by Client(). Thanks!

conda create -n mpcontribs-client python=<your-python-version>
conda activate mpcontribs-client
pip install mpcontribs-client

best,
Patrick

For anyone coming upon this thread and looking for a solution to the OverflowError on Windows, please try to install the bravado fork (PR) manually via

pip install "bravado[fido] @ git+https://github.com/tschaume/bravado@9ce06f2df7118e16af4a3d3fdc21ccfeedc5cd50#egg=bravado-11.0.3"