使用pycharm远程运行非Python脚本

发布于 2025-01-21 08:22:17 字数 449 浏览 4 评论 0 原文

我正在使用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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

她比我温柔 2025-01-28 08:22:17

一个选项是将特定的解释器配置为解释您确保在第6步的对话框窗口中确保设置 interrant:/usr/usr/bin/bash 。然后,您应该使用 obif设置该项目的解释器。运行以下文件 this doc 。您可能需要两个不同的项目,其中包括不同的配置文件/解释器;一个带有Python代码,另一个带有Slurm提交脚本。

将所有内容都保留在同一项目中的另一个选项可能是将作业提交在Python代码中,要么使用

  • os.System(“ sbatch job.run”)或更通用的 subprocess package
  • “ rel =“ nofollow noreferrer”> pyslurm 软件包

One 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 the job.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

往日 2025-01-28 08:22:17

我认为您可以尝试使用外部(远程)工具选项。它允许您创建上下文操作,然后可以从 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 from Project 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文