Commit 132f8aa0 authored by Duggan, John's avatar Duggan, John
Browse files

Show feedback when connecting to remote filesystem and cleanup some bugs

parent fe3a245c
Loading
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -59,7 +59,9 @@ class IPSFastranTool:
        # return self.tool, tool_params

    def prepare_local(self) -> None:
        if not isinstance(self.tool, LocalTool):
            self.tool = LocalTool(self.model)

    def prepare_superfacility(self) -> None:
        if not isinstance(self.tool, SuperfacilityTool):
            self.tool = SuperfacilityTool(self.model)
+8 −42
Original line number Diff line number Diff line
@@ -126,14 +126,8 @@ class SuperfacilityTool:
        return self.file_tree

    def read_file(self, path: str) -> str:
        [remote_path] = self.perlmutter.ls(os.path.join(self.working_directory, path))
        file = remote_path.download()

        data = file.read()
        if isinstance(data, bytes):
            return data.decode("utf-8")

        return data
        with self.perlmutter_fs.open(os.path.join(self.working_directory, path), "r") as file_obj:
            return file_obj.read()

    def refresh_output(self) -> None:
        if not self.job:
@@ -175,37 +169,9 @@ conda deactivate
        self.model.execution.is_queued = True

    def upload_file(self, file: Dict[str, Any]) -> None:
        pass
        # path = os.path.join(self.working_directory, file["relative_path"])
        # remote_path = self.perlmutter.ls()
        # response = self.session.post(
        #     "https://api.nersc.gov/api/v1.2/utilities/command/perlmutter",
        #     data={"executable": f"mkdir -p {os.path.dirname(path)}"},
        # )
        # task = response.json()
        # task_id = task["task_id"]

        # complete = False
        # data = {}
        # while not complete:
        #     self._refresh_token()
        #     response = self.session.get(f"https://api.nersc.gov/api/v1.2/tasks/{task_id}")
        #     data = response.json()

        #     complete = data["status"] == "completed"
        #     if not complete:
        #         sleep(0.1)

        # with open(file["path"], "r") as file_obj:
        #     response = self.session.put(
        #         f"https://api.nersc.gov/api/v1.2/utilities/upload/perlmutter/{path}",
        #         files={"file": file_obj},
        #     )
        # result = response.json()

        # if result["status"] == "OK":
        #     if result["output"]:
        #         self.model.execution.stdout += result["output"] + "\n"
        # else:
        #     if result["error"]:
        #         self.model.execution.stderr += result["error"] + "\n"
        if file["name"].startswith(".") or file["name"].startswith(".log"):
            return

        path = os.path.join(self.working_directory, file["relative_path"])
        with self.perlmutter_fs.open(path, "w") as file_obj:
            file_obj.write(file["content"])
+21 −7
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ class ViewState(BaseModel):

    active_tab: str = Field(default="0")
    active_output_tab: str = Field(default="0")
    connecting: bool = Field(default=False)
    errors: List[str] = Field(default=[])
    results_disabled: bool = Field(default=False)
    input_file_path: str = Field(default=os.getenv("HOME", os.getcwd()), title="Path to Input Files")
@@ -132,13 +133,6 @@ class MainViewModel:
            self.view_state.active_tab = "3"
            self.view_state_bind.update_in_view(self.view_state)

    def connect(self) -> None:
        self.ips_fastran.prepare_tool()

        file_tree = self.ips_fastran.tool.read_files()
        self.model.set_files(file_tree)
        self.config_bind.update_in_view(self.model.config)

    def edit_file(self, path: List[str]) -> None:
        if not path:
            return
@@ -150,6 +144,26 @@ class MainViewModel:

        self.view_state_bind.update_in_view(self.view_state)

    def _connect(self, *args: Any, **kwargs: Any) -> None:
        self.ips_fastran.prepare_tool()

        file_tree = self.ips_fastran.tool.read_files()
        self.model.set_files(file_tree)

    def _on_connect_complete(self, *args: Any, **kwargs: Any) -> None:
        self.config_bind.update_in_view(self.model.config)

        self.view_state.connecting = False
        self.view_state_bind.update_in_view(self.view_state)

    def connect(self) -> None:
        self.view_state.connecting = True
        self.view_state_bind.update_in_view(self.view_state)

        worker = self.binding.new_worker(self._connect)
        worker.connect_finished(self._on_connect_complete)
        worker.start()

    def _refresh_output(self, *args: Any, **kwargs: Any) -> None:
        self.ips_fastran.tool.refresh_output()

+3 −1
Original line number Diff line number Diff line
@@ -30,7 +30,9 @@ class InputFilesTab:
            )
        with HBoxLayout(v_else=True, classes="mb-1", valign="center"):
            InputField(v_model="config.proxy_command")
            vuetify.VBtn("Connect to Perlmutter Filesystem", click=self.view_model.connect)
            with vuetify.VBtn(v_if="state.connecting"):
                vuetify.VProgressCircular(indeterminate=True, size=16)
            vuetify.VBtn("Connect to Perlmutter Filesystem", v_else=True, click=self.view_model.connect)

        with GridLayout(classes="mb-2", columns=3, stretch=True):
            with VBoxLayout(classes="pl-2"):