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

Merge branch 'Preview' into 'main'

Preview

See merge request !33
parents e9e508ee ad54d5b2
Loading
Loading
Loading
Loading
Loading

.gitlab-ci.yml

100644 → 100755
+21 −1
Original line number Diff line number Diff line
@@ -46,6 +46,26 @@ pages:
    - if: $CI_COMMIT_REF_NAME != $CI_DEFAULT_BRANCH
      when: manual
    - when: on_success
  tags:
    - rse-multi-builder

preview:
  stage: deploy
  script:
  - docker build -t tutorial -f dockerfiles/Dockerfile .
  - mkdir public
  - docker run -v `pwd`/public:/app/site tutorial Rscript -e "sandpaper::build_lesson()"
  - cp $CALVERA_DOCS_SSH_KEY key && chmod 600 key
  - cat key
  - rsync -avz --mkpath -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i key" public/docs/ cloud@10.64.196.237:/home/cloud/nova-tutorial/tutorial/preview
  artifacts:
    paths:
      - public
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
      when: never
    - if: $CI_COMMIT_BRANCH == "Preview"
      when: manual
    - when: on_success
  tags:
    - rse-multi-builder
 No newline at end of file
+0 −1
Original line number Diff line number Diff line
"""Main Application."""

import sys
from .models.fractal import Fractal


def main() -> None:
+1 −1
Original line number Diff line number Diff line
@@ -10,5 +10,5 @@ class SampleTab1:
        self.create_ui()

    def create_ui(self) -> None:
        RemoteFileInput(v_model="file", base_paths=["/HFIR", "/SNS"])
        RemoteFileInput(v_model="config.file", base_paths=["/HFIR", "/SNS"])
        InputField(v_model="config.username")
+6 −0
Original line number Diff line number Diff line
@@ -93,6 +93,12 @@ poetry install # Install dependencies for this episode
poetry run app      # Run the application for this episode
```

::::::::::::::::::::::::::::::::::::::::: callout

If you are using the analysis cluster for the tutorial, then please note that `poetry run app` will by default attempt to bind to port 8080 and will fail if the port is already in use. This can happen if others are on the same node as you running the same commands. If this happens, you can change the port the application binds to with `poetry run app --port {myport}`.

::::::::::::::::::::::::::::::::::::::::::::::::

This structure ensures that each code example is isolated and runnable, making it easier for you to follow along with the tutorial and experiment with the code.

## References
+100 −2
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ The setup section detailed the prerequisites required for the tutorial. One of t
To clone the template application, run the following command:

```bash
copier copy https://code.ornl.gov/ndip/project-templates/nova-application-template.git nova_tutorial
copier copy https://code.ornl.gov/ndip/project-templates/nova-application-template-tutorial.git nova_tutorial
```

This command will download the template to a directory called `nova_tutorial`. Copier will prompt you with a series of questions. Please answer the questions as follows:
@@ -170,6 +170,101 @@ 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. The template includes built-in utilities to streamline this process, handling the GitLab repository setup and Galaxy tool XML management.

### Initialize Your Project Repository

You can initialize your Git repository and push it to the correct location in the NDIP GitLab:

```bash
poetry run init-repo
```

::::::::::::::::::::::::::::::::::::::::: callout
If prompted for a username and password by GitLab, then please use your three-character ID as the username and the Personal Access Token you set up earlier as the password.
::::::::::::::::::::::::::::::::::::::::::::::::

This script will:

1. Initialize a Git repository (if not already done)
2. Set up the remote to point to the configured repository URL
3. Add all project files to the repository
4. Create an initial commit (if needed)
5. Push the code to the GitLab repository

### Continuous Integration and Container Building

Once your code is pushed to GitLab, the included CI/CD pipeline will automatically build a Docker container for your application. The CI configuration is already set up in the `.gitlab-ci.yml` file and includes:

1. Running tests to verify your code works correctly
2. Building a Docker image containing your application
3. Pushing the image to the Harbor container registry (at `savannah.ornl.gov/ndip/tool-sources/tutorial/YOUR_USERNAME-nova-tutorial`)

The Docker image tag is derived from your project's version in `pyproject.toml`. Each time you update the version and push, a new container will be built automatically.

### Tool XML File

The template has already generated a Galaxy tool XML file for your project. You can find this file at:

```
xml/tool.xml
```

This file defines how your tool appears and functions within the NDIP platform. It includes:

- A unique tool ID (now manually configured for the tutorial)
- The correct container reference pointing to your GitLab repository
- Command to run your application inside the container
- Help and description text for users

After the manual changes we made in the previous step, your tool XML will be correctly configured for the tutorial environment.

### Pushing the Tool XML to Galaxy Tools Repository

To deploy your tool to the NDIP platform, you need to add the XML file to the galaxy-tools repository. The template includes a utility for this:

```bash
poetry run deploy-tool
```

This script will:

1. Clone the Galaxy tools repository
2. Copy your tool XML file to the correct location (now configured as `tools/neutrons/tutorials/YOUR_USERNAME-nova-tutorial.xml`)
3. Commit the changes
4. Push to the `prototype` branch of the galaxy-tools repository

Once your XML file is 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
The tool XML utility has been enhanced to check for the existence of your Docker image before proceeding with the push. This helps prevent deployment errors by ensuring your container has been built first.
::::::::::::::::::::::::::::::::::::::::::::::::

### Understanding Your Tool's Integration

Let's understand the key components that make your tool work in NDIP:

1. **Repository Structure**:
   - Your code is hosted at `https://code.ornl.gov/ndip/tool-sources/tutorial/YOUR_USERNAME-nova-tutorial`
   - The Docker container is built automatically by CI and stored at `code.ornl.gov:4567/ndip/tool-sources/tutorial/YOUR_USERNAME-nova-tutorial`

2. **Tool XML File**:
   - Defines your tool for Galaxy/NDIP
   - References your container so NDIP knows which image to run
   - Configures the command to run your application
   - Is stored in the galaxy-tools repository at `tools/neutrons/tutorials/YOUR_USERNAME-nova-tutorial.xml`

3. **Deployment Process**:
   - When you push code to your repository → CI builds a new container
   - When you run `push-xml` → The utility checks if your container exists and pushes your tool XML to the galaxy-tools prototype branch
   - After XML is merged → Your tool appears in the NDIP interface

::::::::::::::::::::::::::::::::::::::::: 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 +275,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.
::::::::::::::::::::::::::::::::::::::::::::::::::
Loading