mirror of
https://github.com/CHN-beta/nixos.git
synced 2026-01-12 04:39:23 +08:00
packages.sbatch-tui: 统一设置输出文件和任务名
This commit is contained in:
@@ -17,6 +17,8 @@ int main()
|
||||
std::string UserCommand;
|
||||
std::string SubmitCommand;
|
||||
std::string CurrentInterface = "Program";
|
||||
std::string JobName = std::filesystem::current_path().filename().string();
|
||||
std::string OutputFile = "output.txt";
|
||||
} State;
|
||||
std::vector<std::unique_ptr<Program>> Programs;
|
||||
auto ConfigFile = YAML::LoadFile(SBATCH_CONFIG);
|
||||
@@ -64,6 +66,8 @@ int main()
|
||||
return ftxui::Container::Vertical
|
||||
({
|
||||
Programs[State.ProgramSelected]->get_interface() | with_bottom_heavy,
|
||||
input(&State.JobName, "Job name: "),
|
||||
input(&State.OutputFile, "Output file: "),
|
||||
// 操作按钮
|
||||
ftxui::Container::Horizontal
|
||||
({
|
||||
@@ -111,7 +115,8 @@ int main()
|
||||
else if (State.UserCommand == "Continue")
|
||||
{
|
||||
State.CurrentInterface = "Confirm";
|
||||
State.SubmitCommand = Programs[State.ProgramSelected]->get_submit_command();
|
||||
State.SubmitCommand = Programs[State.ProgramSelected]->get_submit_command()
|
||||
+ "\n--job-name='{}' --output='{}'"_f(State.JobName, State.OutputFile);
|
||||
}
|
||||
else std::unreachable();
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@ namespace sbatch
|
||||
int MemorySchemeSelected = 0;
|
||||
std::vector<std::string> MemorySchemeEntries = { "Default", "All", "Custom" };
|
||||
std::string Memory = "1";
|
||||
std::string JobName = std::filesystem::current_path().filename().string();
|
||||
std::string OutputFile = "output.txt";
|
||||
std::string InputFile = "input.txt";
|
||||
};
|
||||
protected: StateType State_;
|
||||
@@ -47,7 +45,6 @@ namespace sbatch
|
||||
if (saved_state.MemorySchemeSelected < State_.MemorySchemeEntries.size())
|
||||
State_.MemorySchemeSelected = saved_state.MemorySchemeSelected;
|
||||
State_.Memory = saved_state.Memory;
|
||||
State_.OutputFile = saved_state.OutputFile;
|
||||
State_.InputFile = saved_state.InputFile;
|
||||
}
|
||||
catch (...) {}
|
||||
@@ -90,12 +87,8 @@ namespace sbatch
|
||||
}) | with_title("Memory:", ftxui::Color::GrayDark) | with_separator
|
||||
}) | with_title("Resource allocation:") | with_bottom,
|
||||
// 第三行:任务名和输入输出文件
|
||||
ftxui::Container::Vertical
|
||||
({
|
||||
input(&State_.JobName, "Job name: "),
|
||||
input(&State_.InputFile, "Input file: "),
|
||||
input(&State_.OutputFile, "Output file: "),
|
||||
}) | with_title("Misc:")
|
||||
ftxui::Container::Vertical({input(&State_.InputFile, "Input file: ")})
|
||||
| with_title("Misc:")
|
||||
});
|
||||
}
|
||||
public: virtual std::string get_submit_command() const override
|
||||
@@ -116,11 +109,8 @@ namespace sbatch
|
||||
else if (State_.MemorySchemeSelected == 2) return "--mem={}G"_f(State_.Memory);
|
||||
else std::unreachable();
|
||||
}();
|
||||
return "sbatch --partition={}\n{}{} {}\n--job-name='{}' --output='{}'\n--wrap=\"mumax3 {}\""_f
|
||||
(
|
||||
State_.QueueEntries[State_.QueueSelected], gpu_string, cpu_string, mem_string,
|
||||
State_.JobName, State_.OutputFile, State_.InputFile
|
||||
);
|
||||
return "sbatch --partition={}\n{}{} {}\n--wrap=\"mumax3 {}\""_f
|
||||
(State_.QueueEntries[State_.QueueSelected], gpu_string, cpu_string, mem_string, State_.InputFile);
|
||||
}
|
||||
};
|
||||
template void Program::register_child_<Mumax3>();
|
||||
|
||||
@@ -18,8 +18,6 @@ namespace sbatch
|
||||
int MemorySchemeSelected = 0;
|
||||
std::vector<std::string> MemorySchemeEntries = { "Default", "All", "Custom" };
|
||||
std::string Memory = "1";
|
||||
std::string JobName = std::filesystem::current_path().filename().string();
|
||||
std::string OutputFile = "output.txt";
|
||||
bool OptcellEnable = false;
|
||||
int OptcellSelected = 0;
|
||||
std::vector<std::string> OptcellEntries = { "fix ab", "fix c" };
|
||||
@@ -96,8 +94,7 @@ namespace sbatch
|
||||
// 第三行:任务名和输出文件
|
||||
ftxui::Container::Vertical
|
||||
({
|
||||
input(&State_.JobName, "Job name: "),
|
||||
input(&State_.OutputFile, "Output file: "),
|
||||
|
||||
ftxui::Container::Horizontal
|
||||
({
|
||||
checkbox("Generate OPTCELL", &State_.OptcellEnable),
|
||||
@@ -141,11 +138,11 @@ namespace sbatch
|
||||
else return ""s;
|
||||
}();
|
||||
return
|
||||
"{}sbatch --partition={} --nodes=1-1\n{}{}\n--job-name='{}' --output='{}'\n"
|
||||
"{}sbatch --partition={} --nodes=1-1\n{}{}\n"
|
||||
"--wrap=\"srun{} vasp-intel vasp-{}\""_f
|
||||
(
|
||||
optcell_string, State_.QueueEntries[State_.QueueSelected], cpu_string, mem_string,
|
||||
State_.JobName, State_.OutputFile, srun_string, State_.VaspEntries[State_.VaspSelected]
|
||||
srun_string, State_.VaspEntries[State_.VaspSelected]
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -21,8 +21,6 @@ namespace sbatch
|
||||
int MemorySchemeSelected = 0;
|
||||
std::vector<std::string> MemorySchemeEntries = { "Default", "All", "Custom" };
|
||||
std::string Memory = "1";
|
||||
std::string JobName = std::filesystem::current_path().filename().string();
|
||||
std::string OutputFile = "output.txt";
|
||||
bool OptcellEnable = false;
|
||||
int OptcellSelected = 0;
|
||||
std::vector<std::string> OptcellEntries = { "fix ab", "fix c" };
|
||||
@@ -116,8 +114,6 @@ namespace sbatch
|
||||
// 第三行:任务名和输出文件
|
||||
ftxui::Container::Vertical
|
||||
({
|
||||
input(&State_.JobName, "Job name: "),
|
||||
input(&State_.OutputFile, "Output file: "),
|
||||
ftxui::Container::Horizontal
|
||||
({
|
||||
checkbox("Generate OPTCELL", &State_.OptcellEnable),
|
||||
@@ -158,10 +154,10 @@ namespace sbatch
|
||||
else if (State_.MemorySchemeSelected == 2) return " --mem={}G"_f(State_.Memory);
|
||||
else std::unreachable();
|
||||
}();
|
||||
return "{}sbatch --partition={}\n{} {}{}\n--job-name='{}' --output='{}'\n--wrap=\"srun vasp-nvidia vasp-{}\""_f
|
||||
return "{}sbatch --partition={}\n{} {}{}\n--wrap=\"srun vasp-nvidia vasp-{}\""_f
|
||||
(
|
||||
optcell_string, State_.QueueEntries[State_.QueueSelected], gpu_string, cpu_string, mem_string,
|
||||
State_.JobName, State_.OutputFile, State_.VaspEntries[State_.VaspSelected]
|
||||
State_.VaspEntries[State_.VaspSelected]
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user