Commit b0ef01a3 authored by Ayres, Andrew's avatar Ayres, Andrew
Browse files

Add pushing tool to ndip

parent 6d6ea44c
Loading
Loading
Loading
Loading
+135 −1
Original line number Diff line number Diff line
@@ -170,6 +170,137 @@ The template includes a basic GitLab CI configuration file (`.gitlab-ci.yml`).
:::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::

## Deploying Your Tool to NDIP

Now that we have our template application set up, we need to integrate it with the NDIP platform. This involves three main steps:

1. Building a Docker container for our application
2. Cloning the galaxy-tools repository
3. Creating an XML file that defines our tool and adding it to the repository

### Building a Docker Container

The template comes with a Dockerfile that we can use to build a container for our application. Let's do that:

```bash
cd nova_tutorial
docker build -t nova-tutorial:latest -f dockerfiles/Dockerfile .
```

This creates a Docker image named `nova-tutorial` with the tag `latest` that contains our application and all its dependencies.

::::::::::::::::::::::::::::::::::::::::: callout
Normally, we would push this image to a container registry so that NDIP can access it. However, for this tutorial, we'll skip this step. In a real deployment, you would push the image using a command like `docker push <registry-url>/nova-tutorial:latest`. For the tutorial, we'll use a pre-pushed container.

When releasing new versions of your tool, you'll want to use versioned tags for your container images, such as `nova-tutorial:1.0.0`, to maintain backward compatibility while allowing for updates.
::::::::::::::::::::::::::::::::::::::::::::::::

### Cloning the Galaxy Tools Repository

To deploy our tool to the NDIP platform, we need to add its XML definition to the galaxy-tools repository. Let's clone the repository and switch to the prototype branch:

```bash
# Clone the galaxy-tools repository
git clone https://code.ornl.gov/ndip/galaxy-tools.git

# Navigate to the repository
cd galaxy-tools

# Check out the prototype branch
git checkout prototype
```

### Creating and Adding the Tool XML File

Now we'll create an XML file that defines our tool for the NDIP platform. We'll place it in the appropriate directory within the galaxy-tools repository:

```bash
# Create the directory if needed
mkdir -p tools/neutrons/tutorial

# Create the XML file
touch tools/neutrons/tutorial/<username>_nova_tutorial.xml
```

Replace `<username>` with your username to ensure the tool ID is unique.

Now, edit the file and add the following XML content:

```xml
<tool id="<username>_nova_tutorial" tool_type="interactive" name="<Username>'s NOVA Tutorial Tool" version="0.1.0">
    <description>A simple NOVA template application</description>
    <requirements>
        <container type="docker">ghcr.io/ornl/ndip/nova-tutorial:latest</container>
    </requirements>
    <entry_points>
        <entry_point name="NOVA Tutorial" requires_domain="False">
            <port>8080</port>
            <url>app</url>
        </entry_point>
    </entry_points>
    <environment_variables>
        <environment_variable name="HISTORY_ID">$__history_id__</environment_variable>
        <environment_variable name="GALAXY_URL">$__galaxy_url__</environment_variable>
        <environment_variable name="API_KEY" inject="api_key"/>
    </environment_variables>
    <command><![CDATA[
        python -m nova_tutorial.app
    ]]></command>
    <help><![CDATA[
        # NOVA Tutorial Application
        
        This is a simple template application created using the NOVA framework.
        It demonstrates a basic user interface with tabs.
    ]]></help>
</tool>
```

Make sure to replace `<username>` with your actual username in both the `id` and `name` attributes to ensure your tool has a unique identifier.

Let's break down the key elements of this XML file:

- `<tool>` element with attributes:
  - `id`: A unique identifier for your tool (includes your username for uniqueness)
  - `tool_type="interactive"`: Specifies that this is an interactive tool
  - `name`: A user-friendly name for the tool
  - `version`: The tool version

- `<requirements>`: Specifies the Docker container to use

- `<entry_points>`: Defines how users can access the tool
  - `<port>`: The port the application is running on
  - `<url>`: The URL path to access the application

- `<environment_variables>`: Critical variables passed to the tool
  - `HISTORY_ID`: The current Galaxy history ID
  - `GALAXY_URL`: The Galaxy server URL
  - `API_KEY`: The user's API key for Galaxy

- `<command>`: The command to run inside the container

- `<help>`: Documentation for the tool

### Committing and Pushing Your Changes

Now that we've created our tool XML file, we need to commit the changes and push them to the prototype branch:

```bash
# Add the new file to git
git add tools/neutrons/tutorial/<username>_nova_tutorial.xml

# Commit the changes
git commit -m "Add <username>'s NOVA tutorial tool"

# Push the changes to the prototype branch
git push origin prototype
```

Once your changes are pushed to the prototype branch, an automated CI job will deploy your tool to the calvera-test instance. You can then access your tool through the NDIP web interface at https://calvera-test.ornl.gov.

::::::::::::::::::::::::::::::::::::::::: callout
In a production environment, when your tool is ready for users, you would create a merge request from the prototype branch to the dev branch. The NDIP team reviews these changes, merges them, and your tool will be deployed to the production instance during the next deployment.
::::::::::::::::::::::::::::::::::::::::::::::::

## References

*   **Nova Documentation**: https://nova-application-development.readthedocs.io/en/latest/
@@ -180,7 +311,10 @@ The template includes a basic GitLab CI configuration file (`.gitlab-ci.yml`).

:::::::::::::::::::::::::::::::::::::::: keypoints
- Nova provides a template application to help get started developing your application.
- Use the copier tool to set clone the template application.
- Use the copier tool to clone the template application.
- Poetry is a project management tool used to install dependencies and manage virtual environments.
- The template application includes everything you need to get started such as basic CI, dockerfile, and tests.
- Docker containers package your application and all its dependencies for deployment.
- Galaxy tool XML files define how your tool appears and functions in NDIP.
- Tools are deployed by adding their XML files to the galaxy-tools repository's prototype branch.
::::::::::::::::::::::::::::::::::::::::::::::::::
+20 −52
Original line number Diff line number Diff line
@@ -5,79 +5,46 @@ exercises: 0
---
# 8. Development Cycle and Next Steps

In this section, we will look at other resources you may want to integrate with your application and outline the process for taking an application like the one we\'ve created in this tutorial and deploying it to the NOVA/NDIP platform. While we won\'t actually perform the deployment in this tutorial, we will cover the key steps and resources involved.
In this section, we will look at other resources you may want to integrate with your application.

## ONCat Integration

If needed, you can integrate your application with ONCat via [pyoncat](https://pypi.org/project/pyoncat/2.1/). If you need to access non-public information with the API then you will need to use an authenticated client in `pyoncat`. We strongly recommend you email oncat-support@ornl.gov explaining the use case for your ONCat integration as they can advise you on the most appropriate form of authentication for your application and how to set it up.

## Containerizing Your Application
## Advanced Container Configurations

The first step in deploying your application to the NOVA/NDIP platform is to package it as a Docker container. Docker containers provide a lightweight and portable way to package your application and all of its dependencies. This ensures that your application will run consistently across different environments.

Fortunately, the template application we used in this tutorial already includes a `Dockerfile` that you can use as a starting point. The Dockerfile is a set of instructions that Docker uses to build your container image.

Here\'s what the Dockerfile typically includes:

* **Base Image:** Specifies the base operating system and environment for your application.
* **Dependencies:** Describes how to install any required libraries or packages.
* **Application Files:** Defines how to copy your application code into the container.
* **Entrypoint:** Sets the command that is run when the container starts.

To containerize your application, you would:

1. Navigate to the top level of your project (where the `dockerfiles` folder is).
2. Run the docker build command in the following format `docker build -t <your_image_name>:<your_image_tag> -f dockerfiles/Dockerfile .`
3. Test your docker container using the command `docker run <your_image_name>:<your_image_tag>`.
4. Push your docker container to a container registry.

After the docker container is deployed to a registry, it can then be used by the platform.
The basic container configuration we created in Episode 2 works well for most applications, but there are some advanced configurations that may be useful for more complex applications.

::::::::::::::::::::::::::::::::::::::::: callout
GPU acceleration in a container is possible but beyond the scope of this tutorial. Typically, a base container is chosen which already has all of the gpu dependencies installed such as ```regproxy.ornl.gov/hub_proxy/kitware/trame:py3.10-glvnd-2024-12```. The team has built similar containers already which can be used as a reference for development, such as, ```https://code.ornl.gov/ndip/trame-apps/ct-scan-visualizer/```
GPU acceleration in a container is possible but beyond the scope of this tutorial. Typically, a base container is chosen which already has all of the GPU dependencies installed such as ```regproxy.ornl.gov/hub_proxy/kitware/trame:py3.10-glvnd-2024-12```. The team has built similar containers already which can be used as a reference for development, such as ```https://code.ornl.gov/ndip/trame-apps/ct-scan-visualizer/```
::::::::::::::::::::::::::::::::::::::::::::::::::

## Defining Your Tool with XML

Once your application is containerized, you will also need to define your tool using an XML file. This XML file describes your tool to the NDIP platform, including its inputs, outputs, parameters, and the Docker container image that should be used to run the tool. The NDIP platform makes use of the Galaxy tool framework.

The XML file includes:
## Development Lifecycle

*   **Tool ID:** A unique identifier for your tool.
*   **Name and Description:** User-friendly name and description of the tool.
*   **Inputs:** Defines the input parameters, including their types, labels, and optional constraints.
*   **Outputs:** Describes the output files or datasets produced by the tool.
*   **Container Image:** Specifies the Docker image that should be used to run the tool.
*   **Command:** Specifies the command line that is executed inside the docker container.
As we saw in Episode 2, we can deploy our tools to the NDIP platform by adding XML files to the galaxy-tools repository's prototype branch. Let's discuss what happens after that initial deployment.

You can find numerous examples of Galaxy tool XML files in the NDIP GitLab repository:
[https://code.ornl.gov/ndip/galaxy-tools](https://code.ornl.gov/ndip/galaxy-tools)
### Continued Development

Detailed documentation on creating tool XML files is available on the Calvera documentation site:
[https://calvera.ornl.gov/docs/dev](https://calvera.ornl.gov/docs/dev)
Once your tool is deployed to the platform, you may want to continue development to fix bugs or add new features. The process for continuing development on an existing tool is similar to getting a new tool on the platform.

## Development Lifecycle
You will continue to develop on the *prototype* branch, where you can push and test changes. Once you are satisfied with the new version of your tool, submit a merge request to update the tool in the *dev* branch. The NDIP team will review these changes, perform the merge, and the new version of the tool will be updated on the NDIP production instance, Calvera, during the next deployment.

### How to get a new tool on NDIP
### Versioning Your Tools

After creating your tool\'s XML file, it needs to be added to the NDIP platform. For testing your tool on the platform, it should be added to the *prototype* branch of the GitLab repository linked above in a repository folder `tools/neutrons`, or it's subfolder. With a git commit, an automated CI job will push your tool to the calvera-test instance. Test your application via the web browser interface. After you\'ve verified that your tool is performing as expected, submit a merge request to the repository\'s *dev* branch and engage with our team.
As you continue to develop your tool, it's important to keep track of versions. The XML file we created in Episode 2 includes a version attribute that you should update whenever you make significant changes to your tool.

The *dev* branch is used as a staging branch for tools that are ready to be put in front of users. Tools here will be added to the NDIP production instance, Calvera, during the next deployment.

### Continued Development

The process for continuing development on an existing tool is similar to getting a new tool on the platform. You will continue to develop on the *prototype* branch, where you can push and test changes. Once you are satisified with the new version of your tool, submit a merge request to update the tool in the *dev* branch. Our team will review these changes, perform the merge, and the new version of the tool will be updated on the NDIP production instance, Calvera, during the next deployment.

## Putting It All Together
## Future Tool Enhancements

Once you have your Docker container and tool XML file, you would:
As you become more familiar with NDIP and the Galaxy platform, you might want to explore more advanced features:

1. Upload the Docker image to a container registry.
2. Upload the XML file to the NDIP platform.
3. Make sure that the API_KEY and GALAXY_URL are passed to the application as environmental variables.
4. Test your application via the web browser interface.
- Creating complex workflows that combine multiple tools
- Integrating with high-performance computing resources
- Developing specialized data analysis pipelines

After performing these steps, your application will be available to NDIP users.
These topics are beyond the scope of this introductory tutorial, but the NDIP team is available to help you explore these possibilities as your tools mature.

## Additional Resources

@@ -90,10 +57,11 @@ After performing these steps, your application will be available to NDIP users.
*   **nova-mvvm documentation**: https://nova-application-development.readthedocs.io/projects/mvvm-lib/en/latest/
*   **Calvera documentation**: https://calvera-test.ornl.gov/docs/

By following the steps outlined in this section, you can deploy your own applications to the NDIP platform and make them available to the wider scientific community.
By following this tutorial, you've learned how to create and deploy a NOVA application to the NDIP platform. You can now build on this foundation to create more complex scientific applications that can be easily shared with the wider scientific community.

:::::::::::::::::::::::::::::::::::::::: keypoints
- Tools must be containerized to run on NDIP.
- NDIP requires tools to have an XML file which defines input, outputs, tool id, and the container location.
- NDIP requires tools to have an XML file which defines inputs, outputs, tool ID, and the container location.
- Tool XML files must be added to the Galaxy Tools Repository.
- The development lifecycle involves continuous testing on the prototype branch before promoting to dev.
::::::::::::::::::::::::::::::::::::::::::::::::::