简体   繁体   中英

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, ie 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 ~/ )?

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:

  • What is the use case for different configuration files?
  • Notice that when running with trains-agent , this method will override the configuration that the trains-agent passes to the code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM