[英]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
环境变量,但我想知道是否可以通过以下方式之一使其更加灵活:
~/
)?在每个训练存储库中存储一个配置文件并指定其相对于运行脚本路径的路径(而不是相对于~/
)?Disclaimer: I'm a member of Allegro Trains team免责声明:我是 Allegro Trains 团队的成员
os.environ['TRAINS_CONFIG_FILE']='~/repo/trains.conf'
from trains import Task
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:几点注意事项:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.