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

Merge branch 'john' into 'main'

Misc. changes I found when going through the tutorial

See merge request !20
parents 145b49ab e21864e6
Loading
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ In this tutorial, you will learn how to use these three core NOVA libraries to b
*   Connect to NDIP.
*   Reference job definitions from tool XML files.
*   Set parameters for those tools.
*   Run the tools using the supplied paramters.
*   Run the tools using the supplied parameters.
*   Monitor the progress of the running tools.
*   Obtain output from the tool when it completes.
*   Create user interfaces to enable access to NDIP tools
@@ -104,6 +104,6 @@ This structure ensures that each code example is isolated and runnable, making i

:::::::::::::::::::::::::::::::::::::::: keypoints
- NDIP is a workflow management system used for analsyis and interpretation of neutron scattering data.
- NDIP has a range of services and tools to enable the creation of complex workdlows for data analysis.
- NDIP has a range of services and tools to enable the creation of complex workflows for data analysis.
- NOVA is a set of libraries that provide a framework to simplify the development of interactive applications for NDIP
::::::::::::::::::::::::::::::::::::::::::::::::::
+12 −12
Original line number Diff line number Diff line
@@ -36,16 +36,16 @@ 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/python.git nova_tutorial
copier copy https://code.ornl.gov/ndip/project-templates/nova-application-template.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:

*   **What is the name of your project?**
*   **What is your project name?**

    > Enter `Nova Tutorial`

*   **What is your python package name?**
*   **What is your Python package name (use Python naming conventions)?**

    > Press enter to accept the default.

@@ -65,7 +65,7 @@ This command will download the template to a directory called `nova_tutorial`. C

    > Enter `yes`

*   **Publish to pypi?**
*   **Publish to PyPI?**

    > Enter `no`

@@ -104,7 +104,7 @@ The template creates a basic project structure to help get you started quickly.

*   `nova_tutorial/`: The root directory of your project
*   `nova_tutorial/src/`: Contains your application code
*   `nova_tutorial/src/nova_tutorial/`: The name of your python package
*   `nova_tutorial/src/nova_tutorial/`: The name of your Python package
*   `nova_tutorial/tests/`: Contains your application\'s unit tests.
*   `nova_tutorial/README.md`: A readme file.

+0 −5
Original line number Diff line number Diff line
@@ -128,11 +128,6 @@ poetry run app

You should see `Fractal tool finished successfully.` printed to the console.

::::::::::::::::::::::::::::::::::::::::: callout
By default, trame will open a new tab in the browser and bring it to focus. If this is undesired behavior, it can be prevented by using ```poetry run app --server```.

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

## Asynchronous tool execution

At times, it may be desirable to execute a tool or workflow without waiting on the result. The class Tool method run has an optional `wait` parameter. The default is true so that the tool is run in a blocking manner. However, by setting the parameter to false, the tool will be run asynchronously in a non-blocking manner.
+11 −4
Original line number Diff line number Diff line
@@ -103,7 +103,7 @@ Benefits of Pydantic:

## Data Binding with NOVA

The **`nova-mvvm`** library greatly simplifies the data synchronization between the componentes of an MVVM applicationm and provides support for user interfaces utilizing the Trame, PyQt, and Panel graphical frameworks. The library provides several predefined classes including TrameBinding, PyQtBinding, and PanelBinding to connect UI components to model variables. Here, we'll focus on the TrameBinding class, but all three function similarly.
The **`nova-mvvm`** library greatly simplifies the data synchronization between the components of an MVVM application and provides support for user interfaces utilizing the Trame, PyQt, and Panel graphical frameworks. The library provides several predefined classes including TrameBinding, PyQtBinding, and PanelBinding to connect UI components to model variables. Here, we'll focus on the TrameBinding class, but all three function similarly.

### How to use TrameBinding

@@ -154,6 +154,7 @@ Let\'s see how to implement the MVVM pattern using `nova-mvvm` and incorporate P
    def run_fractal(self) -> None:
        self.model.fractal.run_fractal_tool()
        self.update_view()
```

**2. Updating our Fractal Class for pydantaic and MVVM (`src/nova_tutorial/app/models/fractal.py**

@@ -261,7 +262,8 @@ from .fractal_tab import FractalTab # Import the FractalTab

We are now going to modify the existing `main.py` file. Change the main method to match the code below.

*   **Instantiate and Run**: In the `main()` function, we create an instance of `Fractal` and call the `run_fractal_tool()` method, wrapped in a `try...except` block for basic error handling:
*   **Instantiate and Run**: In the `main()` function, we no longer need to setup the Fractal tool as it's managed via our MVVM application now.

```python
import sys
from .models.fractal import Fractal
@@ -291,6 +293,11 @@ poetry run app

The application should launch a tab in your web browser. The GUI will have a `FRACTAL` tab and a few sample tabs which were created by the template application. The run button on the `Fractal` tab can be used to launch the `Fractal` NDIP tool. The tool will take a few minutes to complete but when it does, the resulting `Fractal` image will be displayed.

::::::::::::::::::::::::::::::::::::::::: callout
If you don't want Trame to launch a tab by default, you can instead run ```poetry run app --server```.

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

:::::::::::::::::::::::::::::::::::::::  challenge
**Trigger Pydantic Validation Error (Programmatic)**
*   In `Fractal` in `src/nova_tutorial/app/models/fractal.py`, modify the `set_fractal_type` function from the previous exercise to use an *invalid* fractal type:
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ title: "Development Cycle and Next Steps"
teaching: 10
exercises: 0
---
# Next Steps
# 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.