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

Allow the pmgrc file to be read for the MPREster settings #708

Merged
merged 3 commits into from
Nov 16, 2022
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
18 changes: 13 additions & 5 deletions mp_api/client/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@
from mp_api.client import __file__ as root_dir
from multiprocessing import cpu_count
from typing import List
from pymatgen.core import _load_pmg_settings
import os

CPU_COUNT = 8

PMG_SETTINGS = _load_pmg_settings()
_NUM_PARALLEL_REQUESTS = PMG_SETTINGS.get("MPRESTER_NUM_PARALLEL_REQUESTS", 8)
_MAX_RETRIES = PMG_SETTINGS.get("MPRESTER_MAX_RETRIES", 3)
_MUTE_PROGRESS_BAR = PMG_SETTINGS.get("MPRESTER_MUTE_PROGRESS_BARS", False)
_MAX_HTTP_URL_LENGTH = PMG_SETTINGS.get("MPRESTER_MAX_HTTP_URL_LENGTH", 2000)

try:
CPU_COUNT = cpu_count()
Expand Down Expand Up @@ -49,19 +55,21 @@ class MAPIClientSettings(BaseSettings):
)

NUM_PARALLEL_REQUESTS: int = Field(
CPU_COUNT,
_NUM_PARALLEL_REQUESTS,
description="Number of parallel requests to send.",
)

MAX_RETRIES: int = Field(3, description="Maximum number of retries for requests.")
MAX_RETRIES: int = Field(
_MAX_RETRIES, description="Maximum number of retries for requests."
)

MUTE_PROGRESS_BARS: bool = Field(
False,
_MUTE_PROGRESS_BAR,
description="Whether to mute progress bars when data is retrieved.",
)

MAX_HTTP_URL_LENGTH: int = Field(
2000,
_MAX_HTTP_URL_LENGTH,
description="Number of characters to use to define the maximum length of a given HTTP URL.",
)

Expand Down