From b56b680d23bcb2abb7a81e5cd0aaaac31d2ada21 Mon Sep 17 00:00:00 2001 From: "@jmmshn" Date: Wed, 16 Nov 2022 13:21:50 -0800 Subject: [PATCH 1/3] read pmgrc --- mp_api/client/core/settings.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/mp_api/client/core/settings.py b/mp_api/client/core/settings.py index 5386c7a3..06c31ecd 100644 --- a/mp_api/client/core/settings.py +++ b/mp_api/client/core/settings.py @@ -2,9 +2,16 @@ from mp_api.client import __file__ as root_dir from multiprocessing import cpu_count from typing import List +from pymatgen.core.__init__ 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) +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_BAR", False) +MAX_HTTP_URL_LENGTH = PMG_SETTINGS.get("MPRESTER_MAX_HTTP_URL_LENGTH", 2000) try: CPU_COUNT = cpu_count() @@ -49,19 +56,19 @@ 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.", ) From 485dd43007922aeb7a654cb7a61690172fd73cd0 Mon Sep 17 00:00:00 2001 From: "@jmmshn" Date: Wed, 16 Nov 2022 13:42:14 -0800 Subject: [PATCH 2/3] update --- mp_api/client/core/settings.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/mp_api/client/core/settings.py b/mp_api/client/core/settings.py index 06c31ecd..f5bdb44f 100644 --- a/mp_api/client/core/settings.py +++ b/mp_api/client/core/settings.py @@ -7,11 +7,10 @@ PMG_SETTINGS = _load_pmg_settings() -NUM_PARALLEL_REQUESTS = PMG_SETTINGS.get("MPRESTER_NUM_PARALLEL_REQUESTS", 8) -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_BAR", False) -MAX_HTTP_URL_LENGTH = PMG_SETTINGS.get("MPRESTER_MAX_HTTP_URL_LENGTH", 2000) +_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() @@ -56,19 +55,21 @@ class MAPIClientSettings(BaseSettings): ) NUM_PARALLEL_REQUESTS: int = Field( - NUM_PARALLEL_REQUESTS, + _NUM_PARALLEL_REQUESTS, description="Number of parallel requests to send.", ) - MAX_RETRIES: int = Field(MAX_RETRIES, 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( - MUTE_PROGRESS_BAR, + _MUTE_PROGRESS_BAR, description="Whether to mute progress bars when data is retrieved.", ) MAX_HTTP_URL_LENGTH: int = Field( - MAX_HTTP_URL_LENGTH, + _MAX_HTTP_URL_LENGTH, description="Number of characters to use to define the maximum length of a given HTTP URL.", ) From c1f2223e5bbfcf99b8b3ef888c8deb367e317fc1 Mon Sep 17 00:00:00 2001 From: "@jmmshn" Date: Wed, 16 Nov 2022 13:43:30 -0800 Subject: [PATCH 3/3] update --- mp_api/client/core/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mp_api/client/core/settings.py b/mp_api/client/core/settings.py index f5bdb44f..c539a4c2 100644 --- a/mp_api/client/core/settings.py +++ b/mp_api/client/core/settings.py @@ -2,7 +2,7 @@ from mp_api.client import __file__ as root_dir from multiprocessing import cpu_count from typing import List -from pymatgen.core.__init__ import _load_pmg_settings +from pymatgen.core import _load_pmg_settings import os