Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save datasets in Galaxy history from jupyterlab notebook #1157

Merged
merged 62 commits into from
Dec 11, 2021

Conversation

anuprulez
Copy link
Contributor

@anuprulez anuprulez commented Sep 10, 2021

This PR adds a Galaxy tool for processing long-running jobs emitted from a script in the Jupyterlab notebook such as created here. This tool will be useful for running scripts as a job such as training a machine/deep learning model that takes a long time to finish. The trained model (as ONNX format) will be available in Galaxy history after the job finishes.

Steps to run this tool:

  1. Serve Galaxy via planemo locally containing this tool
  2. Generate an API key from running Galaxy instance
  3. Execute the notebook https://github.com/anuprulez/jupyterlabtool/blob/master/upload_jltools.ipynb after updating the API key. This notebook will connect to the local Galaxy instance via bioblend and execute the saved script on Galaxy. Once the job finishes, the trained model will be available in a newly created Galaxy history as an ONNX file.
  4. Note: ONNX file format is now available in Galaxy in the dev branch.

Currently, this work is in progress, tools tests are not yet written. Your comments are welcome!! Thanks!

tool_output

@mvdbeek
Copy link
Collaborator

mvdbeek commented Sep 16, 2021

What do you think about using a collection with discover_outputs, this should have a similar effect and be better performance-wise, it would work better in workflows, history extractions etc ?

@@ -0,0 +1,80 @@
<tool id="run_jupyter_job" name="Run long running jupyterlab job" version="0.0.1">
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anuprulez can you check if there exists a hidden=true option here?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please also add a recent profile=21.05

@@ -0,0 +1,80 @@
<tool id="run_jupyter_job" name="Run long running jupyterlab job" version="0.0.1">
<description>on GPUs</description>
<requirements>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought this needs to run in a Docker container? We should make this explicit, as we don't want to run this in conda, for security reasons?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping @anuprulez

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dynamic code execution is the same as executing code written in any other interactive tool. The execution command from this tool can be sent to any secluded VM for running as far as I understand.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but this tool is way more insecure than any other tool, left? So making sure it runs in Docker and not by accident in Conda is making it a little bit more secure?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, having a docker container running this tool will automatically enable it to run in a secluded environment.

Copy link
Collaborator

@mvdbeek mvdbeek Sep 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving to an explicit container requirement does not in any way guarantee this is safe. The right way right now is to make it an interactive tool. The medium term solution is a tag that means we require containerized execution and pick a destination that can run it (so effectively an interactive tool without open ports).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current tool is supposed to be executed on jupyterlab notebook that is already an interactive tool. I am not sure if interactive tools interact with one another?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem, they're just tools.

<data format="h5" name="outfile_output_arrays" label="Saved arrays"></data>
</outputs>
<tests>
<test>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you a test for num expected outputs?

<output name="outfile_output_model" file="scikit-script-model.onnx" ftype="onnx" compare="sim_size" delta="50" />
</test>
<test>
<param name="select_file" value="tf-script.py"/>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not combining this test with the first one?

</output>
</test>
<test>
<param name="select_file" value="scikit-script.py"/>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and this test with the second?

@anuprulez anuprulez changed the title [RFC] Save datasets in Galaxy history from jupyterlab notebook Save datasets in Galaxy history from jupyterlab notebook Oct 7, 2021
@anuprulez
Copy link
Contributor Author

Steps to run this tool (after this is merged to Galaxy EU):

  1. Open Galaxy's interactive tool (https://live.usegalaxy.eu/?tool_id=interactive_tool_ml_jupyter_notebook)
  2. Write a script as .ipynb file (or copy the entire script from: https://github.com/anuprulez/galaxytools/blob/run_job/tools/jupyter_job/test-data/tf-script.py)
  3. Open another .ipynb tab and write and execute the following script:
url = <<Galaxy's URL>> e.g. https://usegalaxy.eu/
key = <<your Galaxy's API key>>
file_path = <<ipynb script relative path with respect to the notebook>>
tool_output = run_script_job(file_path)

Copy link
Owner

@bgruening bgruening left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, thanks a lot @anuprulez

@bgruening bgruening merged commit f945b1b into bgruening:master Dec 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants