I didn't get to test it on the cloud yet and trying to make final adjustments
Hi AgitatedDove14 , path to the config file for trains manual execution
I was trying to do exactly as you mentioned setting the environment variable
before
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 trains
Then when you actually import trains, everything is already set and it will not read the configuration again.
Make sense ?
The problem is, the configuration is loaded at import time, so there is no "time" to pass anything other than environment variable.
That said if the only difference is server config you can useTask.set_credentials
I'll try to go with this option, I think its actually perfect for my needs
Great!
I'll try to go with this option, I think its actually perfect for my needs
Programmatically before , importing the package, set os.environ['TRAINS_CONFIG_FILE']='~/my_new_trains.conf'
BTW: What's the use case for doing so?
thanks for helping again
My pleasure :)
Hi RipeGoose2
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 🙂
I came across it before but thought its only relevant for credentials
We are working on improving the docs, hopefully it will get clearer 😉
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..
Hi RipeGoose2
when creating a task the default path is still there
What do you mean by "PATH" do you want to provide path for the config file? is it for trains
manual execution or the agent
?
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..
AgitatedDove14 the option you mentioned just before sounds much better for me, I must admit I find the name of the method confusing. I came across it before but thought its only relevant for credentials
hi AgitatedDove14 , when I'm using the set_credentials approach does it mean the trains.conf is redundant? if the file doesn't exists on the machine, will it be an issue? if not, so what defaults should I assume for the rest of the values?