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

Update code snippets and small rewording

parent 56451e36
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ class Fractal:
        nova = Nova(galaxy_url=self.galaxy_url, galaxy_key=self.galaxy_key)
        tool = Tool(id="neutrons_fractal")
        params = Parameters()
        params.add_input(name="fractal_type", value=self.fractal_type)
        #params.add_input(name="option", value=self.fractal_type)

        with nova.connect() as galaxy_connection:
            data_store = galaxy_connection.create_data_store(name="fractal_store")
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ class Fractal:
        nova = Nova(galaxy_url=self.galaxy_url, galaxy_key=self.galaxy_key)
        tool = Tool(id="neutrons_fractal")
        params = Parameters()
        params.add_input(name="fractal_type", value=self.fractal_type)
        params.add_input(name="option", value=self.fractal_type)

        with nova.connect() as galaxy_connection:
            data_store = galaxy_connection.create_data_store(name="fractal_store")
+14 −20
Original line number Diff line number Diff line
import os
from nova.galaxy import Nova, Parameters, Tool
from nova.mvvm.interface import BindingInterface
from pydantic import BaseModel, ValidationError
from pydantic import BaseModel, Field,ValidationError
from typing import Literal

from ..models.fractal import Fractal


class FractalToolInput(BaseModel):
    fractal_type: Literal["mandelbrot", "julia", "random", "markus"]
    fractal_type: Literal["mandelbrot", "julia", "random", "markus"] = Field(default="mandelbrot")


class FractalViewModel():
@@ -16,21 +15,18 @@ class FractalViewModel():
        super().__init__()
        self.fractal = Fractal()

        self._fractal_type = "mandelbrot"
        self._run_button_disabled = True
        self._message = ""
        self._fractal_type = FractalToolInput()
        self._job_status:dict[str, Any] = {}
        self._message: str = ""

        self.run_button_disabled_bind = binding.new_bind(
            linked_object=self,
            linked_object_arguments=["run_button_disabled"],
        self.job_status_bind = binding.new_bind(
            linked_object=self._job_status
        )
        self.message_bind = binding.new_bind(
            linked_object=self,
            linked_object_arguments=["message"],
            linked_object=self._message,
        )
        self.fractal_type_bind = binding.new_bind(
            linked_object=self, 
            linked_object_arguments=["fractal_type"]
            linked_object=self._fractal_type,
        )   

    def set_fractal_type(self, fractal_type: str):
@@ -38,18 +34,16 @@ class FractalViewModel():
            FractalToolInput(fractal_type=fractal_type)
        except ValidationError as e:
             self._message = f"Validation Error: {e}"
             self.message_bind.update_in_view(self)
             return
        self._fractal_type = fractal_type
        print(f"Set new fractal type to: {self._fractal_type}")

    def run_fractal_tool(self):
        self._run_button_disabled = True
        self._job_status["fractal"] = "Starting"
        try:
            self.fractal.set_fractal_type(self._fractal_type)
            self.fractal.set_fractal_type(self._fractal_type.fractal_type)
            self.fractal.run_fractal_tool()
            self._message = "Fractal tool finished successfully."
        except Exception as e:
            self._message = f"Error running fractal tool: {e}"
            raise e
 No newline at end of file
        finally:
            self._run_button_disabled = False
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ class Fractal:
        nova = Nova(galaxy_url=self.galaxy_url, galaxy_key=self.galaxy_key)
        tool = Tool(id="neutrons_fractal")
        params = Parameters()
        params.add_input(name="fractal_type", value=self.fractal_type)
        params.add_input(name="option", value=self.fractal_type)

        with nova.connect() as galaxy_connection:
            data_store = galaxy_connection.create_data_store(name="fractal_store")
+0 −2
Original line number Diff line number Diff line
import os
from nova.galaxy import Nova, Parameters, Tool
from nova.mvvm.interface import BindingInterface
from pydantic import BaseModel, Field,ValidationError
from typing import Literal
@@ -20,7 +19,6 @@ class FractalViewModel():
        self._job_status:dict[str, Any] = {}
        self._message: str = ""


        self.job_status_bind = binding.new_bind(
            linked_object=self._job_status
        )
Loading