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

Read files from Perlmutter after establishing SSH connection

parent eec629f7
Loading
Loading
Loading
Loading
Loading
+25 −3
Original line number Diff line number Diff line
@@ -91,15 +91,37 @@ class SuperfacilityTool:
            self.model.config.result_files.append(name)

    def read_files(self) -> Dict[str, Any]:
        perlmutter_fs = filesystem(
        self.perlmutter_fs = filesystem(
            "ssh",
            host="dtn.nersc.gov",
            pkey=RSAKey.from_private_key(StringIO(self.model.config.sshproxy_key)),
            sock=ProxyCommand(self.model.config.proxy_command) if self.model.config.proxy_command else None,
            username=self.user.name,
        )
        for root, dirs, files in perlmutter_fs.walk(self.working_directory):
            print(root, dirs, files)

        self.file_tree = {}
        for root, dirs, files in self.perlmutter_fs.walk(self.working_directory):
            current_level = self.file_tree
            relative_path = root.replace(self.working_directory, "").strip("/")
            if relative_path:
                parts = relative_path.split("/")
            else:
                parts = []
            for part in parts:
                if part not in current_level:
                    current_level[part] = {}
                current_level = current_level[part]

            for file in files:
                path = os.path.join(root, file)
                with self.perlmutter_fs.open(path, "r") as file_obj:
                    current_level[file] = {
                        "content": file_obj.read(),
                        "name": file,
                        "path": path,
                        "relative_path": os.path.join(relative_path, file),
                    }
            dirs[:] = [dir for dir in dirs if dir in ["input"]]

        return self.file_tree

+1 −0
Original line number Diff line number Diff line
@@ -137,6 +137,7 @@ class MainViewModel:

        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: