Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fall back on PMG_MAPI_KEY #1841

Merged
merged 3 commits into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion mpcontribs-client/mpcontribs/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
from plotly.express._chart_types import line as line_chart
from cachetools import cached, LRUCache
from cachetools.keys import hashkey
from pymatgen.core import SETTINGS

RETRIES = 3
MAX_WORKERS = 3
Expand Down Expand Up @@ -886,7 +887,9 @@ def __init__(
host = os.environ.get("MPCONTRIBS_API_HOST", DEFAULT_HOST)

if not apikey:
apikey = os.environ.get("MPCONTRIBS_API_KEY")
apikey = os.environ.get("MPCONTRIBS_API_KEY", SETTINGS.get("PMG_MAPI_KEY"))
if apikey and len(apikey) != 32:
raise MPContribsClientError(f"Invalid API key: {apikey}")

if apikey and headers:
apikey = None
Expand Down
Loading