-
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 #244
Feature logging #244
Conversation
Hi @cpwnd , Three minor things:
I will work on you PR and implement different levels of the logging. Indeed some of the stuff from the algorithms can be seen as --debug @philippkraft what do you think about the cli option, logging format and having a logging file? |
* Also new logging instantiation
Hey @thouska, you can now set logfile, logdir and verbosity as "quiet" via cli parameters. I tested it via your suggested way: from spotpy.cli import main
from spotpy.examples.spot_setup_rosenbrock import spot_setup
setup = spot_setup()
main(setup) And then start it via command line e.g.
I think we implemented now all remaining points. EDIT:
|
Is this line important? Thats the last print statement remaining. spotpy/spotpy/database/__init__.py Line 21 in 6be2dcf
Maybe it can be replaced by the logger. If yes, then the |
Pull Request Test Coverage Report for Build 921
💛 - Coveralls |
With the last two commits, at least for me, this is finished. Can be merged into master now. |
Hi @cpwnd, thx for pushing this new feature. I tested it on my device and it works almost perfect. However, there is one strange error:
If I restated the code from there, it works without any error. Do you have any idea what could cause that behavior? |
I don't have an anaconda installation at the moment. But when I start it
in an interactive console (ipython) it works. Also I'm using Ubuntu
instead of Windows.
How do you start the scripts in anaconda?
Am 15.06.21 um 16:07 schrieb thouska:
…
Hi @cpwnd <https://github.com/cpwnd>,
thx for pushing this new feature. I tested it on my device and it
works almost perfect. However, there is one strange error:
Everytime it is started for the frst time in an interactive console,
any of the example errors with:
Traceback (most recent call last):
File "...\spotpy\examples\tutorial_parallel_computing_hymod.py",
line 44, in
sampler=spotpy.algorithms.mc(spot_setup, dbname='Parallel_hymod',
dbformat='csv',
File "...\spotpy\algorithms\mc.py", line 53, in *init*
super(mc, self).*init*(*args, **kwargs)
File "...\spotpy\algorithms_algorithm.py", line 221, in *init*
self.logger =
spotpylogging.instantiate_logger(self.*class*.*name*, quiet,
logfile, logdir)
File "...\spotpy\spotpylogging.py", line 49, in instantiate_logger
handler_file = logging.FileHandler(path_to_logfile)
File "...\anaconda3\lib\logging_/init/_.py", line 1143, in *init*
StreamHandler.*init*(self, self./open())
File "...\anaconda3\lib\logging_/init//.py", line 1172, in _open
return open(self.baseFilename, self.mode, encoding=self.encoding)
OSError: [Errno 22] Invalid argument:
'...\spotpy\examples\2021-06-15-spotpy.log'`
If I restated the code from there, it works without any error. Do you
have any idea what could cause that behavior?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#244 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMTH7ISCMPDF6RVPATK3P3TS5NDDANCNFSM4L2LP2MA>.
|
I start the scripts in Anaconda's spyder editor. |
@thouska please check the branch again for your Windwos Anaconda setup. I replaced the logging paths now with |
Closing this in favor of #293 |
Hey I followed your discussion in #239 and went ahead to implement the standard logging library.
If you wan't to use the code, I'm happy to contribute.
What is already done
All print calls are replaced with a
logging.info
call. I don't know if the info level is always appropriate.I changed your logging code in analyser.py (EDIT i mean objectivefunctions.py) to use the new main logger.
There is one print call in the database package. I don't know if its really necessary.
What has to be done
--verbose/debug/quiet
or something like that, to toggle the standard behavior.So we can met the requirements of the issue.
I wasn't quite sure how to add a new cli option that.
If you point me to the right direction I can add code for e.g. (1)
--quiet
=> no console output/everything is printed to the file (2) default (no option) => info level and (3)--debug
which then prints all.debug(...)
messages as well.Also printing to the file can be disabled too.
https://github.com/cpwnd/spotpy/blob/15e219692f6d7d8a9553264a5830a92b481cde82/spotpy/spotpylogging.py#L16
Not implemented in this pr
In my opinion would be possible next steps, that can be adressed with future pull requests:
At the moment I tested only with different tutorials from the examples folder.
Hope to hear from you soon :)