Commit e2869ed6 authored by Duggan, John's avatar Duggan, John
Browse files

Fix download results button

parent 7e07b0e4
Loading
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
"""IPS Fastran classes."""

import logging
import zipfile
from io import BytesIO
from pathlib import Path
from typing import Tuple

@@ -37,9 +39,18 @@ class IPSFastranTool(BasicTool):

        return self.tool, tool_params

    def get_results(self) -> Path:
    def get_output_path(self) -> Path:
        outputs = self.tool.get_results()
        dataset = outputs.get_dataset("output")

        dataset.download("output.nc")
        return Path("output.nc")

    def get_results(self, tool: Tool) -> bytes:
        outputs = tool.get_results()
        output = outputs.get_dataset("output").get_content()
        zip_buffer = BytesIO()
        with zipfile.ZipFile(zip_buffer, mode="w", compression=zipfile.ZIP_DEFLATED) as zf:
            zf.writestr("output.nc", output)
        zip_buffer.seek(0)
        return zip_buffer.getvalue()
+1 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ class ExecutionViewModel:

    async def on_progress(self, _sender: Any, state: WorkState, details: Dict[str, Any]) -> None:
        if state == WorkState.FINISHED:
            path = self.tool.get_results()
            path = self.tool.get_output_path()
            self.completion_signal.send(output_path=path)

    def store_factory(self) -> str: