I was trying to do exactly as you mentioned setting the environment variable
any trains import but it didn't work
In your entry point script, (even if you do not call
trains/ Task.init ) add:
import os os.environ['TRAINS_CONFIG_FILE']='~/my_new_trains.conf' import trainsThen when you actually import trains, everything is already set and it will not read the configuration again.
Make sense ?
AgitatedDove14 The use case is conditional choice of a server config, when ran locally or on the cloud..
I was trying to do exactly as you mentioned setting the environment variable before any trains import but it didn't work (and also its a mess in terms of my code).. I was hoping there is another way to go about it.. if not I'll try to create a minimal reproducible example..
AgitatedDove14 it does, and it did, but for some reason I couldn't make it to work this way..
I require some additional imports before to infer the config path dynamically.. but even when I stripped down the code and made sure there is no other trains imports anywhere it still didn't work..
when I'm using the set_credentials approach does it mean the trains.conf is redundant? if
Yes this means there is no need for trains.conf , all the important stuff (i.e. server + credentials you provide from code).
BTW: When you execute the same code (i.e. code with set_credentials call) the agent's coniguration will override what you have there, so you will be able to run the Task later either on prem/cloud without needing to change the code itself 🙂