trainsclearml

Can Trains config file be specified dynamically or relative to the running script path?


Suppose I have a server where many users run different experiments, possibly with different Trains Servers.

I know about the TRAINS_CONFIG_FILE environment variable, but I wonder if this can be made more flexible in one of the following ways:

  1. Specifying the Trains config file dynamically, i.e. during runtime of the training script?
  2. Storing a config file in each of the training repos and specifying its path relatively to the running script path (instead of relatively to ~/)?

Solution

  • Disclaimer: I'm a member of Allegro Trains team

    1. Loading of the configuration is done at import time. This means that if you set the os environment before importing the package, you should be fine:
    os.environ['TRAINS_CONFIG_FILE']='~/repo/trains.conf'
    from trains import Task
    
    1. The configuration file is loaded based on the current working directory, this means that if you have os.environ['TRAINS_CONFIG_FILE']='trains.conf' the trains.conf file will be loaded from the running directory at the time the import happens (which usually is the folder where your script is executed from). This means you can have it as part of the repository, and always set the TRAINS_CONFIG_FILE to point to it.

    A few notes: