I have some python scripts that are contacting an external server in order to produce their results.
I would like to pass the IP of that external server as an environment variable in the python scripts.
Right now the python tools do not see the variables even if it is set in the /etc/environment. I also tried setting the variables in the galaxy service.
Any ideas how I can pass the variables inside the python tools?
Don’t know if you are in a hurry and need a temporary quick fix. But if so, you can execute a bash script containing export VARNAME="my value" and the python script instead of directly executing the python script from the XML.
This does not run on worker nodes, there is only the master node.
The tools are python scripts.
When I was testing them I tried to fetch the env variables inside the script but they didn’t exist. So I figured that they ran inside a python virtual environment.
So I want to find a way to load some env variables inside that virtual environment when every script starts.
Maybe I do not fully grasp the context and I am wrong somewhere.
The overarching issue is you are trying to bypass Galaxy to pass a tool information. This will always be brittle as Galaxy decides the execution environment. I recommend using one of Galaxies mechanisms to pass a tool information. Perhaps put it in a file in the tool-data folder and have the tool read it. One of the things I have been meaning to look into is if Galaxy loads anything you include in the galaxy.yml into its config object. You can access that via the $_app_ variable in the tools command block via the Cheetah template engine.
What I am doing now is exactly what you described. I am saving the info on a python script in a specific path and then I load it when my python tools run.
I was just asking if there is another, proper way to do that, maybe by putting the variables in the galaxy.yml as you said. Is this possible? I did not understand the way you said, to load it through the $app variable. Is there an example for that somewhere?