Skip to content

Commit 5298a01

Browse files
authored
Fix rendering of MPRester docstring in deployed docs (#863)
* Fix rendering of MPRester docstring in deployed docs * Do the same for the real MPRester class
1 parent 3bc3ac8 commit 5298a01

File tree

2 files changed

+65
-57
lines changed

2 files changed

+65
-57
lines changed

mp_api/client/core/client.py

+31-26
Original file line numberDiff line numberDiff line change
@@ -74,32 +74,37 @@ def __init__(
7474
headers: dict = None,
7575
mute_progress_bars: bool = settings.MUTE_PROGRESS_BARS,
7676
):
77-
"""Args:
78-
api_key (str): A String API key for accessing the MaterialsProject
79-
REST interface. Please obtain your API key at
80-
https://www.materialsproject.org/dashboard. If this is None,
81-
the code will check if there is a "PMG_MAPI_KEY" setting.
82-
If so, it will use that environment variable. This makes
83-
easier for heavy users to simply add this environment variable to
84-
their setups and MPRester can then be called without any arguments.
85-
endpoint (str): Url of endpoint to access the MaterialsProject REST
86-
interface. Defaults to the standard Materials Project REST
87-
address at "https://api.materialsproject.org", but
88-
can be changed to other urls implementing a similar interface.
89-
include_user_agent (bool): If True, will include a user agent with the
90-
HTTP request including information on pymatgen and system version
91-
making the API request. This helps MP support pymatgen users, and
92-
is similar to what most web browsers send with each page request.
93-
Set to False to disable the user agent.
94-
session: requests Session object with which to connect to the API, for
95-
advanced usage only.
96-
debug: if True, print the URL for every request
97-
monty_decode: Decode the data using monty into python objects
98-
use_document_model: If False, skip the creating the document model and return data
99-
as a dictionary. This can be simpler to work with but bypasses data validation
100-
and will not give auto-complete for available fields.
101-
timeout: Time in seconds to wait until a request timeout error is thrown
102-
headers (dict): Custom headers for localhost connections.
77+
"""Initialise the REST API helper class.
78+
79+
Arguments:
80+
api_key: A String API key for accessing the MaterialsProject
81+
REST interface. Please obtain your API key at
82+
https://www.materialsproject.org/dashboard. If this is None,
83+
the code will check if there is a "PMG_MAPI_KEY" setting.
84+
If so, it will use that environment variable. This makes
85+
easier for heavy users to simply add this environment variable to
86+
their setups and MPRester can then be called without any arguments.
87+
endpoint: Url of endpoint to access the MaterialsProject REST
88+
interface. Defaults to the standard Materials Project REST
89+
address at "https://api.materialsproject.org", but
90+
can be changed to other urls implementing a similar interface.
91+
include_user_agent: If True, will include a user agent with the
92+
HTTP request including information on pymatgen and system version
93+
making the API request. This helps MP support pymatgen users, and
94+
is similar to what most web browsers send with each page request.
95+
Set to False to disable the user agent.
96+
session: requests Session object with which to connect to the API, for
97+
advanced usage only.
98+
s3_resource: boto3 S3 resource object with which to connect to the object stores.
99+
debug: if True, print the URL for every request
100+
monty_decode: Decode the data using monty into python objects
101+
use_document_model: If False, skip the creating the document model and return data
102+
as a dictionary. This can be simpler to work with but bypasses data validation
103+
and will not give auto-complete for available fields.
104+
timeout: Time in seconds to wait until a request timeout error is thrown
105+
headers: Custom headers for localhost connections.
106+
mute_progress_bars: Whether to disable progress bars.
107+
103108
"""
104109
self.api_key = api_key or DEFAULT_API_KEY
105110
self.base_endpoint = endpoint

mp_api/client/mprester.py

+34-31
Original file line numberDiff line numberDiff line change
@@ -131,37 +131,40 @@ def __init__(
131131
headers: dict | None = None,
132132
mute_progress_bars: bool = _MAPI_SETTINGS.MUTE_PROGRESS_BARS,
133133
):
134-
"""Args:
135-
api_key (str): A String API key for accessing the MaterialsProject
136-
REST interface. Please obtain your API key at
137-
https://next-gen.materialsproject.org/api. If this is None,
138-
the code will check if there is a "MP_API_KEY" setting.
139-
If so, it will use that environment variable. This makes
140-
easier for heavy users to simply add this environment variable to
141-
their setups and MPRester can then be called without any arguments.
142-
endpoint (str): Url of endpoint to access the MaterialsProject REST
143-
interface. Defaults to the standard Materials Project REST
144-
address at "https://api.materialsproject.org", but
145-
can be changed to other urls implementing a similar interface.
146-
notify_db_version (bool): If True, the current MP database version will
147-
be retrieved and logged locally in the ~/.mprester.log.yaml. If the database
148-
version changes, you will be notified. The current database version is
149-
also printed on instantiation. These local logs are not sent to
150-
materialsproject.org and are not associated with your API key, so be
151-
aware that a notification may not be presented if you run MPRester
152-
from multiple computing environments.
153-
include_user_agent (bool): If True, will include a user agent with the
154-
HTTP request including information on pymatgen and system version
155-
making the API request. This helps MP support pymatgen users, and
156-
is similar to what most web browsers send with each page request.
157-
Set to False to disable the user agent.
158-
monty_decode: Decode the data using monty into python objects
159-
use_document_model: If False, skip the creating the document model and return data
160-
as a dictionary. This can be simpler to work with but bypasses data validation
161-
and will not give auto-complete for available fields.
162-
session (Session): Session object to use. By default (None), the client will create one.
163-
headers (dict): Custom headers for localhost connections.
164-
mute_progress_bars (bool): Whether to mute progress bars.
134+
"""Initalise the MPRester.
135+
136+
Arguments:
137+
api_key (str): A String API key for accessing the MaterialsProject
138+
REST interface. Please obtain your API key at
139+
https://next-gen.materialsproject.org/api. If this is None,
140+
the code will check if there is a "MP_API_KEY" setting.
141+
If so, it will use that environment variable. This makes
142+
easier for heavy users to simply add this environment variable to
143+
their setups and MPRester can then be called without any arguments.
144+
endpoint (str): Url of endpoint to access the MaterialsProject REST
145+
interface. Defaults to the standard Materials Project REST
146+
address at "https://api.materialsproject.org", but
147+
can be changed to other urls implementing a similar interface.
148+
notify_db_version (bool): If True, the current MP database version will
149+
be retrieved and logged locally in the ~/.mprester.log.yaml. If the database
150+
version changes, you will be notified. The current database version is
151+
also printed on instantiation. These local logs are not sent to
152+
materialsproject.org and are not associated with your API key, so be
153+
aware that a notification may not be presented if you run MPRester
154+
from multiple computing environments.
155+
include_user_agent (bool): If True, will include a user agent with the
156+
HTTP request including information on pymatgen and system version
157+
making the API request. This helps MP support pymatgen users, and
158+
is similar to what most web browsers send with each page request.
159+
Set to False to disable the user agent.
160+
monty_decode: Decode the data using monty into python objects
161+
use_document_model: If False, skip the creating the document model and return data
162+
as a dictionary. This can be simpler to work with but bypasses data validation
163+
and will not give auto-complete for available fields.
164+
session: Session object to use. By default (None), the client will create one.
165+
headers: Custom headers for localhost connections.
166+
mute_progress_bars: Whether to mute progress bars.
167+
165168
"""
166169
# SETTINGS tries to read API key from ~/.config/.pmgrc.yaml
167170
api_key = api_key or DEFAULT_API_KEY or SETTINGS.get("PMG_MAPI_KEY")

0 commit comments

Comments
 (0)