4

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.

bad_coder
  • 11,289
  • 20
  • 44
  • 72
Tristan Maxson
  • 229
  • 4
  • 15
  • did you try to run `ssh -p 22 username@server` and see if you have ssh console? if you want, you can create custom [Run/debug command](https://www.jetbrains.com/help/pycharm/run-debug-configuration.html) and then you can run it directly from pycharm – matan h Apr 17 '22 at 15:37
  • Did you setup SLURM before trying to run the script [like in this "submitting jobs" example](https://docs.rc.fas.harvard.edu/kb/convenient-slurm-commands/)? I think the IDE dialogues you need to follow are the ones in [Use Built-in SSH terminal and remote SSH external tools](https://www.jetbrains.com/help/pycharm/tutorial-using-the-product-built-in-ssh-terminal-and-remote-ssh-external-tools.html) but I don't have a SLURM server to test this. – bad_coder Apr 19 '22 at 10:26

2 Answers2

4

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

damienfrancois
  • 52,978
  • 9
  • 96
  • 110
1

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.

sol25
  • 139
  • 1
  • 8