11"""
2- Settings for DataJoint.
2+ Settings for DataJoint
33"""
44
55from contextlib import contextmanager
4848 "database.use_tls" : None ,
4949 "enable_python_native_blobs" : True , # python-native/dj0 encoding support
5050 "add_hidden_timestamp" : False ,
51- "filepath_checksum_size_limit" : None , # file size limit for when to disable checksums
51+ # file size limit for when to disable checksums
52+ "filepath_checksum_size_limit" : None ,
5253 }
5354)
5455
@@ -117,6 +118,7 @@ def load(self, filename):
117118 if filename is None :
118119 filename = LOCALCONFIG
119120 with open (filename , "r" ) as fid :
121+ logger .info (f"DataJoint is configured from { os .path .abspath (filename )} " )
120122 self ._conf .update (json .load (fid ))
121123
122124 def save_local (self , verbose = False ):
@@ -236,7 +238,8 @@ class __Config:
236238
237239 def __init__ (self , * args , ** kwargs ):
238240 self ._conf = dict (default )
239- self ._conf .update (dict (* args , ** kwargs )) # use the free update to set keys
241+ # use the free update to set keys
242+ self ._conf .update (dict (* args , ** kwargs ))
240243
241244 def __getitem__ (self , key ):
242245 return self ._conf [key ]
@@ -250,7 +253,9 @@ def __setitem__(self, key, value):
250253 valid_logging_levels = {"DEBUG" , "INFO" , "WARNING" , "ERROR" , "CRITICAL" }
251254 if key == "loglevel" :
252255 if value not in valid_logging_levels :
253- raise ValueError (f"{ 'value' } is not a valid logging value" )
256+ raise ValueError (
257+ f"'{ value } ' is not a valid logging value { tuple (valid_logging_levels )} "
258+ )
254259 logger .setLevel (value )
255260
256261
@@ -260,11 +265,9 @@ def __setitem__(self, key, value):
260265 os .path .expanduser (n ) for n in (LOCALCONFIG , os .path .join ("~" , GLOBALCONFIG ))
261266)
262267try :
263- config_file = next (n for n in config_files if os .path .exists (n ))
268+ config . load ( next (n for n in config_files if os .path .exists (n ) ))
264269except StopIteration :
265- pass
266- else :
267- config .load (config_file )
270+ logger .info ("No config file was found." )
268271
269272# override login credentials with environment variables
270273mapping = {
@@ -292,6 +295,8 @@ def __setitem__(self, key, value):
292295 )
293296 if v is not None
294297}
295- config .update (mapping )
298+ if mapping :
299+ logger .info (f"Overloaded settings { tuple (mapping )} from environment variables." )
300+ config .update (mapping )
296301
297302logger .setLevel (log_levels [config ["loglevel" ]])
0 commit comments