我正在使用Pycharm在SSH服务器上对Python进行远程部署和执行。但是,我也希望能够直接以相同的方式运行其他文件。例如,我想通过sbatch“运行”一个“ job.run”脚本以将其提交给HPC服务器。
我可以看到pycharm运行以下类型的python命令,
ssh://username@server:22/home/username/anaconda3/bin/python -u /home/username/project1/main.py
我想拥有另一个称为“ job.run”的文件,该文件的运行方式如下,
ssh://username@server:22/home/username/bin/sbatch /home/username/project1/job.run
感觉很简单,但是我找不到任何允许我做的选项所以。
I am using PyCharm to do remote deployment and execution of python on an SSH server. However, I would also like to be able to run other files directly in the same way. For example, I would like to "run" a "job.run" script through sbatch to submit it to a HPC server.
I can see PyCharm runs the following type of command for python
ssh://username@server:22/home/username/anaconda3/bin/python -u /home/username/project1/main.py
I would like to have another file called "job.run" that runs as follows
ssh://username@server:22/home/username/bin/sbatch /home/username/project1/job.run
This feels like it should be simple to do, however I cannot find any options that allow me to do so.
发布评论
评论(2)
一个选项是将特定的解释器配置为解释您确保在第6步的对话框窗口中确保设置
interrant:/usr/usr/bin/bash 。然后,您应该使用
obif设置该项目的解释器。运行
以下文件this doc 。您可能需要两个不同的项目,其中包括不同的配置文件/解释器;一个带有Python代码,另一个带有Slurm提交脚本。
将所有内容都保留在同一项目中的另一个选项可能是将作业提交在Python代码中,要么使用
os.System(“ sbatch job.run”)
或更通用的 subprocess packageOne option is to configure a specific interpreter as explained here where you make sure to set
Interpreter: /usr/bin/bash
in the dialog window of step 6. Then you should set that interpreter for the project with thejob.run
file following this doc. You might need two distinct projects with different profiles/interpreter for that ; one with the Python code, another with the Slurm submission scripts.Another option, to keep everything inside the same project, could be to wrap the submission of jobs in Python code, either using
os.system("sbatch job.run")
or the more versatile subprocess package我认为您可以尝试使用
外部(远程)工具
选项。它允许您创建上下文操作,然后可以从project
pycharm中的文件视图或分配给keymap。查看此文档部分:。
这应该将用于执行Python脚本的现有SSH服务器配置挂钩。
I think you could try using
External (Remote) Tools
option. It allows you to create context actions that you can then trigger fromProject
file view in PyCharm or assign to keymap.Take a look at this documentation section: https://www.jetbrains.com/help/pycharm/configuring-third-party-tools.html#remote-ext-tools.
This should hook to your existing SSH server configuration that you are using for executing Python scripts.