# save (and load) files on local host from Interactive Tool

**URL:** https://help.galaxyproject.org/t/save-and-load-files-on-local-host-from-interactive-tool/15453
**Category:** usegalaxy.org support
**Tags:** interactive-tools
**Created:** [May 16, 2025, 7:56pm UTC](https://help.galaxyproject.org/t/save-and-load-files-on-local-host-from-interactive-tool/15453 "2025-05-16T19:56:45Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![rheiland](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/rheiland/32/6369_2.png) [@rheiland](https://help.galaxyproject.org/u/rheiland)
#### Post date: [May 16, 2025, 7:56pm UTC](https://help.galaxyproject.org/t/save-and-load-files-on-local-host-from-interactive-tool/15453/1 "2025-05-16T19:56:45Z")

</div>

I have developed an IT (it happens to use PyQt5 for the GUI) and I’d like to be able to save a file that it generates directly to my local disk (not into the Galaxy workspace). Is this possible? What I’ve read so far seems to indicate that I need to run the Docker container using additional params, perhaps ([Networking using the host network | Docker Docs](https://docs.docker.com/engine/network/tutorials/host/)).

Later, I’d like the tool to access/upload a file from my local disk too.  
thanks, Randy

---

<div class="post-metadata">

### Author: ![jennaj](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/jennaj/32/27_2.png) [@jennaj](https://help.galaxyproject.org/u/jennaj)
#### Post date: [May 16, 2025, 11:17pm UTC](https://help.galaxyproject.org/t/save-and-load-files-on-local-host-from-interactive-tool/15453/2 "2025-05-16T23:17:04Z")

</div>

Hi @rheiland

To be clear, the IT is being launched from inside of Galaxy, but you want to be able to use that IT to read and write files to/from outside of Galaxy. Applications like RStudio can do this when run as an IT, so I don’t think it has to do with Galaxy necessarily, and the focus is more the network everything is hosted on.

And now I read your link 🙃 – maybe compare what the RStudio Galaxy IT wrapper is doing since that is the example I can think of off hand. We also have the tutorial here which I am sure you have seen but someone else may read this later and be not sure sure where to look.

- [Hands-on: Galaxy Interactive Tools / Galaxy Interactive Tools / Galaxy Server administration](https://training.galaxyproject.org/training-material/topics/admin/tutorials/interactive-tools/tutorial.html)

Let’s also cross-post this to the Dev chat to see if anyone has instructions that may be written up somewhere outside of the tutorials. → [You're invited to talk on Matrix](https://matrix.to/#/!fVQwotRzniGGJbeUUi:gitter.im/$oF8jkvk_dbsSue67QopU0UIXbJ901ZjKvp5SK3lRwSQ?via=gitter.im&via=matrix.org)

Good questions!

---

<div class="post-metadata">

### Author: ![bjoern.gruening](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/bjoern.gruening/32/10_2.png) [@bjoern.gruening](https://help.galaxyproject.org/u/bjoern.gruening)
#### Post date: [May 17, 2025, 8:15am UTC](https://help.galaxyproject.org/t/save-and-load-files-on-local-host-from-interactive-tool/15453/3 "2025-05-17T08:15:33Z")

</div>

@rheiland I think this is independent of Galaxy. Your webtool would need to support this. However, you seem to have a Desktop app (that we fake to be a web-application). I assume that Desktop app can only write to “a local” directory. “local” here means local to where the Docker container is running.

If you run the container on your Desktop (without Galaxy) you can indeed add a Docker parameter `-v /home/foo/transfer_folder/:/output/` to the Docker start command. This parameter will mount a host (your Desktop) into the container (/output/). When you now save a file in your App to `/output` it will also appear in `/home/foo/transfer_folder/` on your Desktop.

However, this does not work if the Docker container is running somewhere else and not on your Desktop.

I hope that makes sense.

---

<div class="post-metadata">

### Author: ![rheiland](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/rheiland/32/6369_2.png) [@rheiland](https://help.galaxyproject.org/u/rheiland)
#### Post date: [May 17, 2025, 9:37pm UTC](https://help.galaxyproject.org/t/save-and-load-files-on-local-host-from-interactive-tool/15453/4 "2025-05-17T21:37:02Z")

</div>

Thanks @bjoern.gruening . After re-reading the Docker link I shared, I have to agree with you. So, I’m still stuck at not knowing how I can download/export a file, e.g., foo.dat, from my IT so that it can be saved to my Desktop. Optionally, if I can make foo.dat appear in the Galaxy History, but “on-demand” and not wait for the IT to exit, that would be acceptable for now.  
I began looking at the BioBlend Python API, in part because my IT is written in Python, but so far it’s not obvious how that could do what I want. I don’t even understand its initial “GalaxyInstance” method and why an API key is necessary.

---

<div class="post-metadata">

### Author: ![bjoern.gruening](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/bjoern.gruening/32/10_2.png) [@bjoern.gruening](https://help.galaxyproject.org/u/bjoern.gruening)
#### Post date: [May 18, 2025, 10:01am UTC](https://help.galaxyproject.org/t/save-and-load-files-on-local-host-from-interactive-tool/15453/5 "2025-05-18T10:01:50Z")

</div>

> Optionally, if I can make foo.dat appear in the Galaxy History, but “on-demand” and not wait for the IT to exit

For example, you can use this small helper library. This will provide you a `put()` and `get()` function based on bioblend. We use that for example in the Jupyter IT to retrieve and export data to Galaxy.

> **[GitHub - bgruening/galaxy\_ie\_helpers: Helper scripts to work with Galaxy's Interactive...](https://github.com/bgruening/galaxy_ie_helpers/)**
>
> Helper scripts to work with Galaxy's Interactive Environments

The API key is needed, because the IT run completely isolated from Galaxy. It’s really an external service just started by Galaxy. Galaxy can insert an [API key on the fly](https://github.com/galaxyproject/galaxy/blob/dev/tools/interactive/interactivetool_jupyter_notebook.xml#L17), so you should not worry about that.

---

<div class="post-metadata">

### Author: ![rheiland](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/rheiland/32/6369_2.png) [@rheiland](https://help.galaxyproject.org/u/rheiland)
#### Post date: [May 18, 2025, 9:45pm UTC](https://help.galaxyproject.org/t/save-and-load-files-on-local-host-from-interactive-tool/15453/6 "2025-05-18T21:45:25Z")

</div>

Thanks @bjoern.gruening . I’ve been trying to figure out how I might use your `put()` in my IT. So, I pip installed your helpers in my Dockerfile:

> <https://github.com/rheiland/docker-pcstudio/blob/main/Dockerfile#L41>

and I copy/pasted the env vars (that you linked to) into my IT’s .xml:

> <https://github.com/rheiland/pcstudio_shed/blob/main/interactivetool_pcstudio.xml#L14>

and I attempt a `File -> Download -> PhysiCell_settings.xml` in my Studio IT:

> <https://github.com/rheiland/docker-pcstudio/blob/main/bin/studio.py#L31>

and

> <https://github.com/rheiland/docker-pcstudio/blob/main/bin/studio.py#L1278>

It did not work - it killed my IT. I can take a closer look at my Galaxy log to see if I can learn anything from the errors, but before that, would you be able to tell me if I’m invoking the `put` with the correct/sufficient args? That file, PhysiCell\_settings.xml, does indeed exist in the /config dir of the Docker image.

And if it’s not obvious, I’m just testing this on my local Galaxy server. Does that cause problems with this?

---

<div class="post-metadata">

### Author: ![bjoern.gruening](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/bjoern.gruening/32/10_2.png) [@bjoern.gruening](https://help.galaxyproject.org/u/bjoern.gruening)
#### Post date: [May 19, 2025, 7:59pm UTC](https://help.galaxyproject.org/t/save-and-load-files-on-local-host-from-interactive-tool/15453/7 "2025-05-19T19:59:11Z")

</div>

Can you just raise the error and see why it crashes?

---

<div class="post-metadata">

### Author: ![rheiland](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/rheiland/32/6369_2.png) [@rheiland](https://help.galaxyproject.org/u/rheiland)
#### Post date: [May 20, 2025, 12:43pm UTC](https://help.galaxyproject.org/t/save-and-load-files-on-local-host-from-interactive-tool/15453/8 "2025-05-20T12:43:23Z")

</div>

Thanks - and sorry, I should have done that earlier. I’m getting a `KeyError('HISTORY_ID')`. So perhaps I’m misunderstanding what I need to do to make the `<environment_variables>` do their magic in my `interactivetool_pcstudio.xml`. I am not explicitly setting any env vars on my own.

---

<div class="post-metadata">

### Author: ![bjoern.gruening](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/bjoern.gruening/32/10_2.png) [@bjoern.gruening](https://help.galaxyproject.org/u/bjoern.gruening)
#### Post date: [May 21, 2025, 5:56am UTC](https://help.galaxyproject.org/t/save-and-load-files-on-local-host-from-interactive-tool/15453/9 "2025-05-21T05:56:42Z")

</div>

That looks fine. Your XML also looks fine? Can you check you are really running this version.

This is working for the Juypter IT [galaxy/tools/interactive/interactivetool\_ml\_jupyter\_notebook.xml at release\_24.2\_europe · usegalaxy-eu/galaxy · GitHub](https://github.com/usegalaxy-eu/galaxy/blob/release_24.2_europe/tools/interactive/interactivetool_ml_jupyter_notebook.xml#L15)

Can you maybe see which ENVs are set inside the container when Galaxy starts it?

---

<div class="post-metadata">

### Author: ![rheiland](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/rheiland/32/6369_2.png) [@rheiland](https://help.galaxyproject.org/u/rheiland)
#### Post date: [May 21, 2025, 10:25am UTC](https://help.galaxyproject.org/t/save-and-load-files-on-local-host-from-interactive-tool/15453/10 "2025-05-21T10:25:50Z")

</div>

Thanks for continuing to build up my confidence in trying to test all this.  
Long story short: I had been attempting to test using a “myTools” (local) version of my IT and (previously) a version in the testtoolshed. I just now realized that even though I was selecting my IT in the MyTools section of the Galaxy Tools column, what was being loaded in the URL was the testtoolshed version:

```auto
http://127.0.0.1:8080/?tool_id=testtoolshed.g2.bx.psu.edu%2Frepos%2Frheiland%2Fphysicell_studio%2Finteractive_tool_pcstudio%2F0.1&version=latest

```

When I renamed

```auto
yoga:~/dev/galaxy-24.2.3/config$ mv tool_sheds_conf.xml tool_sheds_conf.xml-argh

```

and re-ran the server (`sh run.sh`), I now got the desired myTools version:

```auto
http://127.0.0.1:8080/?tool_id=interactive_tool_pcstudio&version=latest

```

and when I ran my IT and tested its `File -> download` feature, I at least got past the `KeyError`, but now I get `Exception("Could not connect to a galaxy instance. Please contact your SysAdmin for help..."` which is not good since I am the SysAdmin 😅 . Do you know what this might mean?

---

<div class="post-metadata">

### Author: ![rheiland](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/rheiland/32/6369_2.png) [@rheiland](https://help.galaxyproject.org/u/rheiland)
#### Post date: [May 21, 2025, 1:41pm UTC](https://help.galaxyproject.org/t/save-and-load-files-on-local-host-from-interactive-tool/15453/11 "2025-05-21T13:41:33Z")

</div>

Then I tried the opposite approach - remove the local myTools version, update the IT in the testtoolshed, reinstall it in my local Galaxy as Admin, confirm that it is using that version due to a suffixed-name change (“TTS”), and re-run. Same error.

 ![Screenshot 2025-05-21 at 9.38.11 AM](https://us1.discourse-cdn.com/flex020/uploads/galaxy/original/2X/b/b8f78e3518a07082037dc8e774d3d11aa1002e59.png)  
 ![Screenshot 2025-05-21 at 9.37.51 AM](https://us1.discourse-cdn.com/flex020/uploads/galaxy/original/2X/6/66f60d93c7b611086b9a446f8752c4e0dfa24573.png)

---

<div class="post-metadata">

### Author: ![rheiland](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/rheiland/32/6369_2.png) [@rheiland](https://help.galaxyproject.org/u/rheiland)
#### Post date: [May 22, 2025, 10:47am UTC](https://help.galaxyproject.org/t/save-and-load-files-on-local-host-from-interactive-tool/15453/12 "2025-05-22T10:47:34Z")

</div>

I’m probably doing this in a very crude fashion, but I added a menu item to my IT to show relevant(?) env vars and it dumps:

```auto
{"HISTORY ID': f597429621d6eb2b', 'REMOTE HOST': 'http://
localhost:8080", 'HOME': 'home/heiland/dev/galaxy-24.2.3/database/
jobs_directory/000/38/home', GALAXY_URL': 'http://localhost:8080',
'GALAXY MEMORY MB': ". 'GALAXY MEMORY MB PER SLOT: ".
'GALAXY SLOTS':'1, 'API KEY':
'7c53-delete-for-privacy', 'GALAXY WEB PORT':
"8080'}

```

yet when I attempt a `put`, still get `Could not connect to a galaxy instance`

---

<div class="post-metadata">

### Author: ![bjoern.gruening](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/bjoern.gruening/32/10_2.png) [@bjoern.gruening](https://help.galaxyproject.org/u/bjoern.gruening)
#### Post date: [May 22, 2025, 11:44am UTC](https://help.galaxyproject.org/t/save-and-load-files-on-local-host-from-interactive-tool/15453/13 "2025-05-22T11:44:48Z")

</div>

Just to make sure your setup works, can you please try the Juypter IT?

So far this looks all good to me. I assume `localhost:8080` brings you to the Galaxy? Or you running OSX maybe? In OSX Docker is running in a VM I think, maybe `localhost` is resolving to the VM and not your host OSX?

---

<div class="post-metadata">

### Author: ![rheiland](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/rheiland/32/6369_2.png) [@rheiland](https://help.galaxyproject.org/u/rheiland)
#### Post date: [May 22, 2025, 1:21pm UTC](https://help.galaxyproject.org/t/save-and-load-files-on-local-host-from-interactive-tool/15453/14 "2025-05-22T13:21:00Z")

</div>

Yes, `localhost:8080` takes me to my local Galaxy. I’m testing on Ubuntu. I start a Jupyter IT and run a Python notebook, create a hello.txt and try to “put” it:

```auto
Exception Traceback (most recent call last)
<ipython-input-7-f641031f7f42> in <module>
----> 1 put("hello.txt")

/opt/conda/lib/python3.8/site-packages/galaxy_ie_helpers/ __init__.py in put(filenames, file_type, history_id)
    111
    112 history_id = history_id or os.environ['HISTORY_ID']
--> 113 gi = get_galaxy_connection(history_id=history_id)
    114 for filename in filenames:
    115 log.debug('Uploading gx=%s history=%s localpath=%s ft=%s', gi, history_id, filename, file_type)

/opt/conda/lib/python3.8/site-packages/galaxy_ie_helpers/ __init__.py in get_galaxy_connection(history_id, obj)
     98 ### Fail ###
     99 msg = "Could not connect to a galaxy instance. Please contact your SysAdmin for help with this error"
--> 100 raise Exception(msg)
    101

```

---

<div class="post-metadata">

### Author: ![rheiland](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/rheiland/32/6369_2.png) [@rheiland](https://help.galaxyproject.org/u/rheiland)
#### Post date: [May 22, 2025, 1:26pm UTC](https://help.galaxyproject.org/t/save-and-load-files-on-local-host-from-interactive-tool/15453/15 "2025-05-22T13:26:55Z")

</div>

Do I need to provide more args, e.g., a history\_id, to the `put`?.. apparently not.

---

<div class="post-metadata">

### Author: ![rheiland](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/rheiland/32/6369_2.png) [@rheiland](https://help.galaxyproject.org/u/rheiland)
#### Post date: [May 22, 2025, 1:44pm UTC](https://help.galaxyproject.org/t/save-and-load-files-on-local-host-from-interactive-tool/15453/16 "2025-05-22T13:44:03Z")

</div>

I remember now that I’d tested earlier on [usegalaxy.eu](http://usegalaxy.eu) and it worked

 ![Screenshot from 2025-05-22 09-42-03](https://us1.discourse-cdn.com/flex020/uploads/galaxy/original/2X/5/57735f06b6b196d585cfec11fac08c1bc9579f58.jpeg)

---

<div class="post-metadata">

### Author: ![bjoern.gruening](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/bjoern.gruening/32/10_2.png) [@bjoern.gruening](https://help.galaxyproject.org/u/bjoern.gruening)
#### Post date: [May 22, 2025, 1:46pm UTC](https://help.galaxyproject.org/t/save-and-load-files-on-local-host-from-interactive-tool/15453/17 "2025-05-22T13:46:30Z")

</div>

This all looks fine. The put() is also fine. The history is obtained with

```auto
history_id or os.environ['HISTORY_ID']

```

The problem is your setup. Inside the Docker container localhost is not getting you to your Galaxy host, but inside the container.

Have a look at [Hands-on: Galaxy Interactive Tools / Galaxy Interactive Tools / Development in Galaxy](https://training.galaxyproject.org/training-material/topics/dev/tutorials/interactive-tools/tutorial.html#galaxy-configuration)

Especially `<param id="docker_run_extra_arguments">--add-host localhost:host-gateway</param>` where we teach the Docker Container what localhost means.

---

<div class="post-metadata">

### Author: ![bjoern.gruening](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/bjoern.gruening/32/10_2.png) [@bjoern.gruening](https://help.galaxyproject.org/u/bjoern.gruening)
#### Post date: [May 22, 2025, 1:46pm UTC](https://help.galaxyproject.org/t/save-and-load-files-on-local-host-from-interactive-tool/15453/18 "2025-05-22T13:46:48Z")

</div>

You can also push your changes and we test on EU - as you like.

---

<div class="post-metadata">

### Author: ![rheiland](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/rheiland/32/6369_2.png) [@rheiland](https://help.galaxyproject.org/u/rheiland)
#### Post date: [May 22, 2025, 2:19pm UTC](https://help.galaxyproject.org/t/save-and-load-files-on-local-host-from-interactive-tool/15453/19 "2025-05-22T14:19:53Z")

</div>

I definitely want to be able to test locally. I’ve got a lot of changes to make to our IT before we go “live” at a workshop in July and it seems logical to shorten the dev time by testing locally.  
Thanks for pointing out the Galaxy host/Docker container issue. This makes me feel like maybe I’m really close to resolving this. When I visit the link you provided, it discusses `job_conf.xml`, yet in my server, I’m seeing `job_conf.yml`. Copy/pasting that here. It sure sounds like what’s being done in there now would resolve this. What am I missing?

```auto
(base) heiland@yoga:~/dev/galaxy-24.2.3/config$ cat job_conf.yml
runners:
  local:
    load: galaxy.jobs.runners.local:LocalJobRunner
    workers: 4

execution:
  default: docker_dispatch
  environments:
    local:
      runner: local

    docker_local:
      runner: local
      docker_enabled: true
      docker_set_user:

      # InteractiveTools do need real hostnames or URLs to work - simply specifying IPs will not work.
      # If you develop interactive tools on your 'localhost' and don't have a proper domain name
      # you need to tell all Docker containers a hostname where Galaxy is running.
      # This can be done via the add-host parameter during the `docker run` command.
      # 'localhost' here is an arbitrary hostname that matches the IP address of your
      # Galaxy host. Make sure this hostname ('localhost') is also set in your galaxy.yml file, e.g.
      # `galaxy_infrastructure_url: http://localhost:8080`.
      docker_run_extra_arguments: --add-host localhost:host-gateway --platform linux/amd64

    docker_dispatch:
      runner: dynamic
      type: docker_dispatch
      docker_destination_id: docker_local
      default_destination_id: local

```

---

<div class="post-metadata">

### Author: ![rheiland](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/rheiland/32/6369_2.png) [@rheiland](https://help.galaxyproject.org/u/rheiland)
#### Post date: [May 22, 2025, 2:49pm UTC](https://help.galaxyproject.org/t/save-and-load-files-on-local-host-from-interactive-tool/15453/20 "2025-05-22T14:49:13Z")

</div>

And fwiw, I also have:

```auto
(base) heiland@yoga:~/dev/galaxy-24.2.3/config$ cat galaxy.yml
gravity:
  app_server: gunicorn
  gunicorn:
    bind: 'localhost:8080'
  gx_it_proxy:
    enable: true
    port: 4002

  #handlers:
  # handler:
  # processes: 3
  # pools:
  # - job-handlers
  # - workflow-schedulers
galaxy:
  admin_users: randy.heiland@gmail.com
  interactivetools_enable: true
  interactivetools_map: database/interactivetools_map.sqlite

  # outputs_to_working_directory will provide you with a better level of isolation. It is highly recommended to set
  # this parameter with InteractiveTools.
  outputs_to_working_directory: true

  # `galaxy_infrastructure_url` needs to be reachable from IT containers.
  # For local development you can map arbitrary hostnames. See `job_conf.yml.interactivetools`
  # for an example.
  # In the local development case you should use the `http` protocol (e.g http://localhost:8080) to access
  # your Galaxy, so saving notebooks doesn't fail due to invalid certificates.
  galaxy_infrastructure_url: http://localhost:8080

  # Do not set the following 2 options if you are using an upstream proxy server like nginx
  interactivetools_upstream_proxy: false
  interactivetools_proxy_host: localhost:4002

  job_config_file: config/job_conf.yml
  tool_config_file: config/tool_conf.xml

```

[Next page](https://help.galaxyproject.org/t/save-and-load-files-on-local-host-from-interactive-tool/15453.md?page=2)
