Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
cluster:usage_tips:python [2022/05/16 10:35] – created benedikt | cluster:usage_tips:python [2022/05/16 23:04] (current) – aegir | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Python ====== | + | ====== Python |
+ | Sleep Revolution projects that depend on data sets hosted on the Reykjavík University cluster | ||
+ | during development will benefit greatly from having access to the data sets through a modern project IDE | ||
+ | such as PyCharm. | ||
+ | |||
+ | This guide outlines how you can configure PyCharm to execute code on a remote machine while at the same time ensuring that the development environment stays identical to what you would use for local development. | ||
+ | |||
+ | ==== Other programming languages ==== | ||
+ | This specific setup is for python development, | ||
+ | solutions for many other programming languages through IDEs’ such as the ones listed below. | ||
+ | |||
+ | * IntelliJ: Java | ||
+ | * Rider: DotNet & C# | ||
+ | * CLion: C \& C++ | ||
+ | * WebStorm: JavaScript & WebFrameworks | ||
+ | * GoLand: Go & JavaScript | ||
+ | |||
+ | |||
+ | ==== Step 1: Request professional license ==== | ||
+ | The PyCharm IDE’s professional version is required for the setup and is available for free to all | ||
+ | students, but requires sending a request for a free educational license. | ||
+ | |||
+ | Apply for the free license by following this web link: | ||
+ | [[https:// | ||
+ | |||
+ | |||
+ | ==== Step 2: Download PyCharm professional edition ==== | ||
+ | Download and install PyCharm **Professional edition** to your machine. | ||
+ | |||
+ | Download link: [[https:// | ||
+ | |||
+ | |||
+ | ==== Step 3: Connect to vpn.ru.is ==== | ||
+ | Using a VPN client such as Cisco Anyconnect or OpenConnect, | ||
+ | |||
+ | |||
+ | ==== Step 4: Create a working directory on remote machine ==== | ||
+ | When we work remotely, all project files are copied from the local machine to the server. We | ||
+ | want to store these copied files on the server in a neatly located folder within our server user’s | ||
+ | home directory so that we can easily find them again. | ||
+ | |||
+ | - Open a terminal and SSH into your server user: '' | ||
+ | - Create a new directory for project files: '' | ||
+ | |||
+ | |||
+ | ==== Step 5: Open project in PyCharm ==== | ||
+ | Open your project in PyCharm. We recommend you to always open the project from the directory where your source code resides. This is most often named the '' | ||
+ | |||
+ | |||
+ | ==== Step 6: Configure a remote interpreter ==== | ||
+ | Once the project is open we need to configure a python interpreter to use as a remote execution | ||
+ | environment. Navigate to '' | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | Once the window is open we select the SSH interpreter option on the left, then fill in | ||
+ | the IP address of the server and our username on the remote machine. Finally, we press next. The image below illustrates the process. | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | Once you are on the next tab, enter your server user's authentication password and press next. See the below image. | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | On the next tab, change the interpreter to ''/ | ||
+ | the folder you created in step 4. The path should be ''/ | ||
+ | unless you created the directory not in your home directory on the remote machine. Then press | ||
+ | Ok and Finish. The below image illustrates the process. | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | |||
+ | ==== Step 7: Configure remote terminal ==== | ||
+ | For some things such as executing tests in the terminal or browsing project files on the remote | ||
+ | machine you might want to have the remote terminal handy in your PyCharm editor. | ||
+ | |||
+ | Navigate to '' | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | Once this is done, you need to start the SSH session to get the terminal running. To do this, | ||
+ | click '' | ||
+ | editor’s terminal you should see that you are no longer in your machines terminal but in the | ||
+ | server terminal. | ||
+ | |||
+ | |||
+ | |||
+ | ==== Manually syncing project files ==== | ||
+ | |||
+ | When we are working on a remote development environment the files are continuously uploaded to the remote server. This is done automatically by PyCharm by default. Sometimes, especially when we are restructuring our files and folders, PyCharm may get confused about what changes must be uploaded and thus corrupting the sync between your local environment and your remote | ||
+ | environment. | ||
+ | |||
+ | In such cases we can manually trigger a re-upload of our files to the remote server. See the image below for how to do this. | ||
+ | |||
+ | {{ : | ||
+ | |||