@@ -186,6 +186,7 @@ def __init__(
186186 self .use_document_model = use_document_model
187187 self .monty_decode = monty_decode
188188 self .mute_progress_bars = mute_progress_bars
189+ self ._contribs = None
189190
190191 self ._deprecated_attributes = [
191192 "eos" ,
@@ -221,21 +222,6 @@ def __init__(
221222 # Check if emmet version of server is compatible
222223 emmet_version = MPRester .get_emmet_version (self .endpoint )
223224
224- try :
225- from mpcontribs .client import Client
226-
227- self .contribs = Client (api_key , headers = self .headers , session = self .session )
228- except ImportError :
229- self .contribs = None
230- warnings .warn (
231- "mpcontribs-client not installed. "
232- "Install the package to query MPContribs data, or construct pourbaix diagrams: "
233- "'pip install mpcontribs-client'"
234- )
235- except Exception as error :
236- self .contribs = None
237- warnings .warn (f"Problem loading MPContribs client: { error } " )
238-
239225 if version .parse (emmet_version .base_version ) < version .parse (
240226 _MAPI_SETTINGS .MIN_EMMET_VERSION
241227 ):
@@ -363,6 +349,29 @@ def __molecules_getattr__(_self, attr):
363349 rester ,
364350 )
365351
352+ @property
353+ def contribs (self ):
354+ if self ._contribs is None :
355+ try :
356+ from mpcontribs .client import Client
357+
358+ self ._contribs = Client (
359+ self .api_key , headers = self .headers , session = self .session
360+ )
361+
362+ except ImportError :
363+ self ._contribs = None
364+ warnings .warn (
365+ "mpcontribs-client not installed. "
366+ "Install the package to query MPContribs data, or construct pourbaix diagrams: "
367+ "'pip install mpcontribs-client'"
368+ )
369+ except Exception as error :
370+ self ._contribs = None
371+ warnings .warn (f"Problem loading MPContribs client: { error } " )
372+
373+ return self ._contribs
374+
366375 def __enter__ (self ):
367376 """Support for "with" context."""
368377 return self
0 commit comments