简体   繁体   English

是否可以动态指定 Trains 配置文件或相对于运行脚本路径?

[英]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.假设我有一个服务器,许多用户在其中运行不同的实验,可能使用不同的 Trains 服务器。

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:我知道TRAINS_CONFIG_FILE环境变量,但我想知道是否可以通过以下方式之一使其更加灵活:

  1. Specifying the Trains config file dynamically, ie during runtime of the training script?动态指定 Trains 配置文件,即在训练脚本运行期间?
  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免责声明:我是 Allegro Trains 团队的成员

  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:这意味着如果在导入package之前设置os环境,应该没问题:
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).配置文件是基于当前工作目录加载的,这意味着如果你有os.environ['TRAINS_CONFIG_FILE']='trains.conf' ,trains.conf 文件将在导入发生时从运行目录加载(通常是执行脚本的文件夹)。 This means you can have it as part of the repository, and always set the TRAINS_CONFIG_FILE to point to it.这意味着您可以将它作为存储库的一部分,并始终将TRAINS_CONFIG_FILE设置为指向它。

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.请注意,当使用trains-agent运行时,此方法将覆盖trains-agent传递给代码的配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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