Subprocess

The subprocess_example.py script demonstrates multiple subprocesses interacting and reporting to a main Task. Each Task in a subprocess references the main Task by calling Task.current_task, which always returns the main Task. The Task in each subprocess reports the following to the main Task:

  • Hyperparameters - Additional, different hyperparameters.
  • Log - Text logged to the console as the Task in each subprocess executes.

When the script runs, it creates an experiment named Popen example which is associated with the examples project.

Hyperparameters

Trains automatically logs the command line arguments from argparse. In the mp_worker function, we create a parameter dictionary with random keys and values. We call Task.connect on Task.current_task to connect the random parameters to the main Task.

additional_parameters = {'stuff_' + str(randint(0, 100)): 'some stuff ' + str(randint(0, 100))}
Task.current_task().connect(additional_parameters)

All the parameters appear in the Trains Web (UI), HYPER PARAMETERS tab.

Log

Output to the console, including the text messages from the Task in each subprocess, appear in the RESULTS tab, LOG sub-tab.