-
Notifications
You must be signed in to change notification settings - Fork 152
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
Feature logging #293
base: master
Are you sure you want to change the base?
Feature logging #293
Conversation
* Also new logging instantiation
self.logger.info("*** OPTIMIZATION SEARCH TERMINATED BECAUSE THE LIMIT") | ||
self.logger.info("ON THE MAXIMUM NUMBER OF TRIALS ") | ||
self.logger.info(repetitions) | ||
self.logger.info("HAS BEEN EXCEEDED.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be a warning?
from .base import database | ||
|
||
try: | ||
import tables | ||
except ImportError: | ||
print( | ||
spotpylogging.get_logger("hdf5").info( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be a warning IMO
if criter_change_pcent <= pcento: | ||
print( | ||
self.logger.debug( | ||
"THE BEST POINT HAS IMPROVED IN LAST %d LOOPS BY LESS THAN THE USER-SPECIFIED THRESHOLD %f" | ||
% (kstop, pcento) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kstop, pcento
should be arguments passed to debug
for deferred evaluation by logging.
@@ -297,7 +301,7 @@ def sample( | |||
and proceed == True | |||
): | |||
nloop += 1 | |||
print("ComplexEvo loop #%d in progress..." % nloop) | |||
self.logger.debug("ComplexEvo loop #%d in progress..." % nloop) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.logger.debug("ComplexEvo loop #%d in progress..." % nloop) | |
self.logger.debug("ComplexEvo loop #%d in progress...", nloop) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should work this way.
@@ -216,7 +220,7 @@ def sample( | |||
xf[rep] = like | |||
icall += 1 | |||
if self.status.stop: | |||
print( | |||
self.logger.debug( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be warning IMO
self.logger.info( | ||
"Starting the SA algotrithm with " + str(repetitions) + " repetitions..." | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.logger.info( | |
"Starting the SA algotrithm with " + str(repetitions) + " repetitions..." | |
) | |
self.logger.info("Starting the SA algotrithm with %d repetitions...", repetitions) |
@@ -270,7 +270,7 @@ def programm_depth(self, pars, runs): | |||
if LNDEP[L] >= 1: | |||
CL = np.vstack((CL, TL[L, :])) | |||
IPOS = IPOS + 1 | |||
print((IPOS, ITRY)) | |||
self.logger.info((IPOS, ITRY)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does that work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like this. I would suggest double checking whether to use info
, warning
or debug
depending on the message.
Also I would double check passing variables to the logging message. It should be consistent and I would either prefer f-strings or the recommended deferred evaluation approach using the old fashioned formatting approach using %s
, %d
, %f
and so on and passing the respective variable to the logging method.
Feel free to apply your changes. From my perspective they are reasonable, but I don't have time for this at the moment. |
Hey I merged the feature-logging branch to the latest master changes, to be in sync with the spotpy master again. Unfortunately I forgot un-synced changes in my fork vs my local branches, therefore I pushed a new branch to my fork and created a new merge request. So this branch is now perfectly in sync with
thouska/spotpy:master
. This replaces #244 as merge request (I closed it already) and the preceding discussion in issue #239.Note that writing to stdout can decrease overall performance, regardless of normal
print
or alogging
print. The advantage of using a logging mechanism is central configuration of message pattern and log levels.Hope this finally finds it's way into the codebase :)