options to facilitate testing

Programmers discuss here anything related to FreeOrion programming. Primarily for the developers to discuss.

Moderator: Committer

Message
Author
User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13603
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: options to facilitate testing

#16 Post by Geoff the Medio »

Cjkjvfnby wrote:And got this in config.xml:
<auto-advance-n-turns>5</auto-advance-n-turns>
There is a "storable" parameter to the OptionsDB::Add function that defaults to true, but can be set to false, and probably should be in this case.

Code: Select all

Index: chmain.cpp
===================================================================
--- chmain.cpp	(revision 7754)
+++ chmain.cpp	(working copy)
@@ -107,7 +107,7 @@
         GetOptionsDB().Add<int>("fullscreen-monitor-id",    UserStringNop("OPTIONS_DB_FULLSCREEN_MONITOR_ID"), 0, RangedValidator<int>(0, 5));
         GetOptionsDB().AddFlag('q', "quickstart",           UserStringNop("OPTIONS_DB_QUICKSTART"),            false);
         GetOptionsDB().AddFlag("auto-quit",                 UserStringNop("OPTIONS_DB_AUTO_QUIT"),             false);
-        GetOptionsDB().Add<int>("auto-advance-n-turns",     UserStringNop("OPTIONS_DB_AUTO_N_TURNS"),          0, RangedValidator<int>(0, 400));
+        GetOptionsDB().Add<int>("auto-advance-n-turns",     UserStringNop("OPTIONS_DB_AUTO_N_TURNS"),          0, RangedValidator<int>(0, 400), false);
         GetOptionsDB().Add<std::string>("load",             UserStringNop("OPTIONS_DB_LOAD"),                  "", Validator<std::string>(), false);
         GetOptionsDB().Add("UI.sound.music-enabled",        UserStringNop("OPTIONS_DB_MUSIC_ON"),              true);
         GetOptionsDB().Add("UI.sound.enabled",              UserStringNop("OPTIONS_DB_SOUND_ON"),              true);

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: options to facilitate testing

#17 Post by Dilvish »

Thanks for catching this Cjkjvfnby, and thanks for the solution Geoff, that does the trick.

Code: Select all

r7755 | dilvish-fo | 2014-10-27 20:32:36 -0700 (Mon, 27 Oct 2014) | 1 line
fixes auto-advance-n-turns option so that it is not saved to the permanent options file
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Cjkjvfnby
AI Contributor
Posts: 539
Joined: Tue Jun 24, 2014 9:55 pm

Re: options to facilitate testing

#18 Post by Cjkjvfnby »

My crash on auto-quit reproduces on 7751 log in logs.zip
Attachments
logs.zip
(165.95 KiB) Downloaded 113 times
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: options to facilitate testing

#19 Post by Dilvish »

Cjkjvfnby wrote:My crash on auto-quit reproduces on 7751
The FSM intro menu error issue should be fixed as of r7753, and the crash report being triggered (for me it was both from cross-quit and from auto-quit) should be fixed as of r7754. r7755 is the current weekly version, although it got pushed out a day later than normal-- you appear to have missed updating to it.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Vezzra
Release Manager, Design
Posts: 6100
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: options to facilitate testing

#20 Post by Vezzra »

Dilvish wrote:r7755 is the current weekly version, although it got pushed out a day later than normal
Yep, have been busy on Monday, got back home really late in the evening and haven't been in the mood to go through the whole procedure that late. So I put it off until Tuesday evening... well, that way r7755 made it into the test builds :D

User avatar
Cjkjvfnby
AI Contributor
Posts: 539
Joined: Tue Jun 24, 2014 9:55 pm

Re: options to facilitate testing

#21 Post by Cjkjvfnby »

Key to turn off time prints:
--time-log key with 2 possible values: disable and to_file or just any text that translates to python as is

I will make support for python:
no key: print timing logs (current situation)
disable no print at all
to_file to log and to file https://github.com/freeorion/freeorion/ ... ming.py#L6

Or may be make one key for all cases: --ai-options
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: options to facilitate testing

#22 Post by Dilvish »

Cjkjvfnby wrote:Key to turn off time prints:
The value to totally disabling AI time logging is... less disk space used? That's not seeming worth an extra option. The part of your logging proposal that I see the most value for would be to specify a file for certain AI testing output (which I would see useful to facilitate testing as it would be simpler to parse than the full log file). Generalizing that somewhat akin to the "--ai-options" you suggest, I think it would make sense to have a single optional "--ai-config <filename>" option, and that config file could specify special logging files, test parameters, or whatever other parameters we wanted. For Python I expect we'd make that file compatible with the ConfigParser module.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Cjkjvfnby
AI Contributor
Posts: 539
Joined: Tue Jun 24, 2014 9:55 pm

Re: options to facilitate testing

#23 Post by Cjkjvfnby »

Dilvish wrote:
Cjkjvfnby wrote:Key to turn off time prints:
The value to totally disabling AI time logging is... less disk space used? That's not seeming worth an extra option. The part of your logging proposal that I see the most value for would be to specify a file for certain AI testing output (which I would see useful to facilitate testing as it would be simpler to parse than the full log file).

May be just split C++ and AI logs. After this and switcher for timers, I expect logs to be almost same.
Generalizing that somewhat akin to the "--ai-options" you suggest, I think it would make sense to have a single optional "--ai-config <filename>" option, and that config file could specify special logging files, test parameters, or whatever other parameters we wanted. For Python I expect we'd make that file compatible with the ConfigParser module.
ok
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Cjkjvfnby
AI Contributor
Posts: 539
Joined: Tue Jun 24, 2014 9:55 pm

Re: options to facilitate testing

#24 Post by Cjkjvfnby »

Test patch for options.

I reorganise existings debug tools and add support for options.
feel free to change fo.getAIOptions() and other config names

Config sample:

Code: Select all

[Main]
timers_dump = False
timers_dump_folder = timers
timers_to_log = True
Attachments

[The extension patch has been deactivated and can no longer be displayed.]

If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Cjkjvfnby
AI Contributor
Posts: 539
Joined: Tue Jun 24, 2014 9:55 pm

Re: options to facilitate testing

#25 Post by Cjkjvfnby »

Dilvish wrote:
Cjkjvfnby wrote:My crash on auto-quit reproduces on 7751
The FSM intro menu error issue should be fixed as of r7753, and the crash report being triggered (for me it was both from cross-quit and from auto-quit) should be fixed as of r7754. r7755 is the current weekly version, although it got pushed out a day later than normal-- you appear to have missed updating to it.
Still reproduces in 7757 see logs in attach.
Attachments
auto-quit.zip
(47.42 KiB) Downloaded 107 times
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: options to facilitate testing

#26 Post by Dilvish »

Cjkjvfnby wrote:Still reproduces in 7757 see logs in attach.
Yeah, it had initially seemed cleared up but then has often been appearing for me again as well, both with auto-quit and manually quitting. I'll try to get around to looking at it again, but on Linux at least it seems low priority, only causing some additional terminal output. Does it cause more significant trouble on Windows?
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Cjkjvfnby
AI Contributor
Posts: 539
Joined: Tue Jun 24, 2014 9:55 pm

Re: options to facilitate testing

#27 Post by Cjkjvfnby »

Dilvish wrote:
Cjkjvfnby wrote:Still reproduces in 7757 see logs in attach.
Yeah, it had initially seemed cleared up but then has often been appearing for me again as well, both with auto-quit and manually quitting. I'll try to get around to looking at it again, but on Linux at least it seems low priority, only causing some additional terminal output. Does it cause more significant trouble on Windows?
I will find some workaround it.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: options to facilitate testing

#28 Post by Dilvish »

OK, I implemented two new options for this, --ai-path and --ai-config; neither is stored in the FO config.xml file and so can only be modified via command line

--ai-path <pathname> : sets the directory for the AI scripts, relative to the Resource Directory; default is "AI"
an easy way to test an alternate set of AI scripts, such as in a "default/AI_test" folder or somesuch.

--ai-config <string> : a string available to the AI via AIInterface (fo.getAIConfigStr()); currently expected to identify an AI config file within the AI directory
This is primarily to facilitate more fine-tuned experimentation with the values of individual parameters used by the various AI scripts. Right now the only implemented use is from an initial patch by Cjkjvfnby having the config control whether detailed AI timing info is gathered and logged to file. As part of my AI experimentation I want to augment the option handling to derive some info dependent on empire number so that different AI's in the same game could be assigned different operating parameters (there is a little bit of that already done piece-meal in various places but I want it more readily driven by some external test driver code).

Cjkjvfnby: these should be available to you after the next weekly builds. Also, notes on a few mods I made to your options patch: SafeConfigParser is apparently the recommended ConfigParser to use, and we might wind up wanting to use its interpolation abilities, so I swapped over to it. I had also recalled reading about issues with reading/writing/manually-editing config files if not using a pure string version like SafeConfigParser, though I can't remember where and didn't confirm it. Your approach to having the option_tools know the intended type of every option was handy in some ways, but I didn't really want to get into requiring that every possible option be specified in option_tools.py. So, if client code using these options needs a non-string value the client code will know that and can do the conversion itself; the only complication to that was for bool options so I made a helper function for converting them-- option_tools.check_bool(option). I also had option_tools.py work with OrderedDicts so that we can keep the default config file a bit more organized. The default config file will always be read before the optional one specified via ai-config, and so the optional config file need only have those options differing from default.

One more caveat -- I decided to have the default config file be automatically written if not already present. If the default ini file was really large and/or the file system really slow that conceivably that might lead to write conflict race problems between the AIs, but since it should be a rare event for the file to need to be written I've left it like that for now at least.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13603
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: options to facilitate testing

#29 Post by Geoff the Medio »

Dilvish wrote:...AI config file within the AI directory...
...config file be automatically written if not already present.
You can't (assume you can) write into the AI script directory. If you want to write a file, it needs to be in the user directory, similar to save files or the log files.

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: options to facilitate testing

#30 Post by Dilvish »

Geoff the Medio wrote:You can't (assume you can) write into the AI script directory. If you want to write a file, it needs to be in the user directory, similar to save files or the log files.
Ah, sorry I forgot about that.

Code: Select all

r7779 | dilvish-fo | 2014-11-30 14:06:58 -0800 (Sun, 30 Nov 2014) | 1 line
added handling in case default AI config location is not writable by user
That should clear up the issue.

Edit: To clarify, for now, I'm not going to worry about actually figuring out a good user location for the config files, because it/they are currently only intended for dev use.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

Post Reply