Modularize the Python code
Closed this issue · 2 comments
Rediness commented
Mainly, the AlphaZeroManager, which has many responsibiliies (logging, training, cleaning, initializing state, etc)
Split those responsibilities accordingly to make code reuse and improvment easier.
shindavid commented
My suggestions:
- Make a separate
util/tee_printing.py
file, that has aTeePrinter
class, and a free functioninit_tee_printing(filename: str)
. Calling that function will make it so thatprint()
statements print both to stdout and to the passed-in filename. Then replace theinit_logging()
call in therun()
method with a call toinit_tee_printing()
. - Separate the file/directory organizer role (class AlphaZeroOrganizer?) from the role of managing the self-play cmds and the role of doing the model training. Change scripts like
py/alphazero/compute_ratings.py
that only need the organizer role to construct the organizer, not the manager. - Make separate classes for the training role and the self-play-process management role. The sensitive part is making a clear interface between these classes and the organizer.
shindavid commented
All this has been completed. The alphazero loop logic is now well-separated into different servers/modules.