Visual Studio Code: Difference between revisions

Marked this version for translation
No edit summary
(Marked this version for translation)
Line 1: Line 1:
<languages />
<languages />
<translate>
<translate>
<!--T:1-->
[https://code.visualstudio.com/ Visual Studio Code] is an integrated development environment (IDE) from [https://www.microsoft.com Microsoft] which can be used for remote development with Compute Canada clusters over [[SSH]]. In this context, users can run the graphical interface of Visual Studio Code locally, on their personal computer, while connecting to a cluster where the source code is located and where the debugging and testing operations are being executed. While Visual Studio Code may be used for development in a variety of programming languages, in this page we will focus on its use with [[Python]].
[https://code.visualstudio.com/ Visual Studio Code] is an integrated development environment (IDE) from [https://www.microsoft.com Microsoft] which can be used for remote development with Compute Canada clusters over [[SSH]]. In this context, users can run the graphical interface of Visual Studio Code locally, on their personal computer, while connecting to a cluster where the source code is located and where the debugging and testing operations are being executed. While Visual Studio Code may be used for development in a variety of programming languages, in this page we will focus on its use with [[Python]].


<!--T:2-->
When using an IDE like Visual Studio Code, it's important to distinguish what sort of action you're performing, even if all of them take place within the context of the IDE. Editing a Python script or any other text file of reasonable size (up to a few thousand lines) is a very light-weight process which requires little processing power or memory but an IDE offers you numerous other possibilities, including the ability to debug your script for example. In this case, the IDE is now ''executing'' your Python code on the shared login node and until the script crashes because of a bug, it may well consume an entire CPU core or even several if the script or the libraries which it uses are multi-threaded.
When using an IDE like Visual Studio Code, it's important to distinguish what sort of action you're performing, even if all of them take place within the context of the IDE. Editing a Python script or any other text file of reasonable size (up to a few thousand lines) is a very light-weight process which requires little processing power or memory but an IDE offers you numerous other possibilities, including the ability to debug your script for example. In this case, the IDE is now ''executing'' your Python code on the shared login node and until the script crashes because of a bug, it may well consume an entire CPU core or even several if the script or the libraries which it uses are multi-threaded.


=Configuring remote access=
=Configuring remote access= <!--T:3-->


==Configuration of your SSH keys==
==Configuration of your SSH keys== <!--T:4-->


<!--T:5-->
# If not done already, <b>[[SSH_Keys#Generating_an_SSH_Key|generate your SSH key]]</b>. For example, we will name it <code>~/.ssh/ccdb</code>.
# If not done already, <b>[[SSH_Keys#Generating_an_SSH_Key|generate your SSH key]]</b>. For example, we will name it <code>~/.ssh/ccdb</code>.
# If not done already, <b>[[SSH_Keys#Installing_your_key|install your <i>public</i> SSH key on CCDB]]</b>.
# If not done already, <b>[[SSH_Keys#Installing_your_key|install your <i>public</i> SSH key on CCDB]]</b>.
# Because compute nodes may not get your public SSH key from CCDB through LDAP, you may have to <b>copy your public key</b> to <code>~/.ssh/authorized_keys</code> on the remote cluster (create this file if it does not exist).
# Because compute nodes may not get your public SSH key from CCDB through LDAP, you may have to <b>copy your public key</b> to <code>~/.ssh/authorized_keys</code> on the remote cluster (create this file if it does not exist).


==SSH configuration file==
==SSH configuration file== <!--T:6-->


<!--T:7-->
VS Code works well with your local [[SSH configuration file]] (<code>~/.ssh/config</code>).
VS Code works well with your local [[SSH configuration file]] (<code>~/.ssh/config</code>).
Here are the recommended options :
Here are the recommended options :
Line 50: Line 54:
}}
}}
<translate>
<translate>
==First connection with VS Code==
==First connection with VS Code== <!--T:8-->


<!--T:9-->
Because some clusters do not provide access to Internet from compute nodes,
Because some clusters do not provide access to Internet from compute nodes,
the installation of VS Code Server must be done prior to using a remote connection to any compute node.
the installation of VS Code Server must be done prior to using a remote connection to any compute node.
Therefore, in VS Code, a first connection to any frontal node is required - select either :
Therefore, in VS Code, a first connection to any frontal node is required - select either :


<!--T:10-->
* beluga
* beluga
* cedar
* cedar
Line 61: Line 67:
* narval
* narval


<!--T:11-->
Note 1 : you will be prompted many times for your SSH key passphrase.
Note 1 : you will be prompted many times for your SSH key passphrase.
If not, make sure to copy your SSH public key as described in a previous section.
If not, make sure to copy your SSH public key as described in a previous section.


<!--T:12-->
Note 2 : If you are using some [[Multifactor authentication|multifactor authentication]],
Note 2 : If you are using some [[Multifactor authentication|multifactor authentication]],
you may need to check the "Details" of the connection,
you may need to check the "Details" of the connection,
which will bring you to the VS Code Terminal in which you may be prompted for your 2nd factor of authentication.
which will bring you to the VS Code Terminal in which you may be prompted for your 2nd factor of authentication.


<!--T:13-->
That first connection will automatically install VS Code Server in <code>~/.vscode-server/</code>.
That first connection will automatically install VS Code Server in <code>~/.vscode-server/</code>.
The installation can take up to 5 minutes.
The installation can take up to 5 minutes.
Once done, close the connection.
Once done, close the connection.


=Connection to a compute node=
=Connection to a compute node= <!--T:14-->


<!--T:15-->
Connection procedure:
Connection procedure:
# Make sure VS Code Server is installed as described in the previous section.
# Make sure VS Code Server is installed as described in the previous section.
Line 84: Line 94:
### If you get prompted for the type of operating system, select <b>Linux</b>
### If you get prompted for the type of operating system, select <b>Linux</b>


=See also=
=See also= <!--T:16-->
* SHARCNET General Interest Webinar, "Remote Development on Clusters with VSCode", presented by Armin Sobhani:
* SHARCNET General Interest Webinar, "Remote Development on Clusters with VSCode", presented by Armin Sobhani:
** [https://youtu.be/u9k6HikDyqk Part I]
** [https://youtu.be/u9k6HikDyqk Part I]
Bureaucrats, cc_docs_admin, cc_staff
2,306

edits