Skip to content

Commit

Permalink
deploy: 8f0fe7b
Browse files Browse the repository at this point in the history
  • Loading branch information
lauraporta committed Nov 21, 2024
1 parent acf9217 commit 3e60cc1
Show file tree
Hide file tree
Showing 69 changed files with 1,579 additions and 1,543 deletions.
4 changes: 0 additions & 4 deletions .buildinfo

This file was deleted.

Binary file removed .doctrees/_static/code-blocks-note.doctree
Binary file not shown.
Binary file removed .doctrees/_static/swc-wiki-warning.doctree
Binary file not shown.
Binary file removed .doctrees/data_analysis/HPC-module-SLEAP.doctree
Binary file not shown.
Binary file removed .doctrees/data_analysis/index.doctree
Binary file not shown.
Binary file removed .doctrees/environment.pickle
Binary file not shown.
Binary file removed .doctrees/index.doctree
Binary file not shown.
Binary file removed .doctrees/open_science/Data-sharing.doctree
Binary file not shown.
Binary file removed .doctrees/open_science/GIN-repositories.doctree
Binary file not shown.
Binary file removed .doctrees/open_science/Licensing.doctree
Binary file not shown.
Binary file removed .doctrees/open_science/index.doctree
Binary file not shown.
Binary file removed .doctrees/programming/Cookiecutter-cruft.doctree
Binary file not shown.
Binary file removed .doctrees/programming/Mount-ceph-ubuntu-temp.doctree
Binary file not shown.
Binary file removed .doctrees/programming/Mount-ceph-ubuntu.doctree
Binary file not shown.
Binary file removed .doctrees/programming/SLURM-arguments.doctree
Binary file not shown.
Binary file removed .doctrees/programming/SSH-SWC-cluster.doctree
Binary file not shown.
Binary file removed .doctrees/programming/SSH-vscode.doctree
Binary file not shown.
Binary file removed .doctrees/programming/Troubleshooting.doctree
Binary file not shown.
Binary file removed .doctrees/programming/index.doctree
Binary file not shown.
1 change: 1 addition & 0 deletions _sources/programming/index.md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Small tips and tricks that do not warrant a long-form guide can be found in the
SLURM-arguments
SSH-SWC-cluster
SSH-vscode
vscode-with-slurm-job
Mount-ceph-ubuntu
Mount-ceph-ubuntu-temp
Cookiecutter-cruft
Expand Down
75 changes: 75 additions & 0 deletions _sources/programming/vscode-with-slurm-job.md.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Using VSCode with interactive SLURM jobs on the SWC HPC cluster

This guide explains how to set up and use VSCode in a SLURM interactive job on the SWC HPC cluster, offering a solution for users who require fast access to shared storage or substantial computational resources.

This solution is easy to set up and constrained by the SLURM job's resource limits, as long as those limits are applied. This ensures that users can work efficiently within the allocated resources, preventing system overload. While the constraints depend on SLURM's enforcement (e.g., memory or time limits), users should remain mindful of their resource requests to avoid program terminations.

Furthermore, VSCode's code tunnel automatically forwards any HTTP servers launched from the compute node, such as Dash-Plotly apps or Jupyter Notebook servers, offering seamless integration.


## Instructions

First, open a terminal (not the VSCode terminal) and connect to the gateway node by running:

```{code-block} console
$ ssh <SWC-USERNAME>@ssh.swc.ucl.ac.uk
$ ssh hpc-gw1
```

Once connected, request an interactive job via SLURM to access a compute node. For example:

```{code-block} console
$ srun -p fast -n 4 --mem 8G --pty bash -i
```

In this example, `-p fast` requests the fast partition, with default time settings, though you may adjust this according to your needs. For more information, see the [SLURM arguments primer](https://howto.neuroinformatics.dev/programming/SLURM-arguments.html).

After connecting to a compute node, initiate [VSCode Remote Tunnel](https://code.visualstudio.com/docs/remote/tunnels) by typing:

```{code-block} console
$ code tunnel
```

A URL (`https://github.com/login/device`) and a PIN code will appear in the terminal.
Follow this link, log in with your GitHub credentials, and enter the provided PIN to authorize access.

You have two options to run VSCode:

- **Run VSCode in the browser:**
After completing the above step, a second link will appear in the terminal (e.g., `https://vscode.dev/tunnel/<node-name>`), which you can follow to launch a VSCode browser-based session running directly on the HPC compute node. If you sign in to your VSCode account and have account syncing enabled, you will have your extensions and settings available.

- **Run VSCode on your local machine:**
If you want instead to use your local VSCode, install the "Remote - Tunnels" extension, click on "Open remote window" in the bottom left corner of the VSCode window, and select "Connect to Tunnel". You should see the node name in the list of available tunnels. Click on it to connect to the VSCode session running on the HPC compute node.

:::{note}
The name associated with the tunnel may not match the node name assigned by SLURM. E.g., the assigned compute node may appear as `gpu-380-11` in SLURM, but the corresponding tunnel may be named `gpu-350-02` in VSCode. When using VSCode via the browser, the tunnel name is shown at the end of the URL (e.g., `https://vscode.dev/tunnel/<node-name>`).
:::

If by mistake you close your terminal window, the tunnel will continue to run until you reach the time limit. To rejoin the SLURM job, you can use the following command if you know the job ID:

```{code-block} console
$ sattach <JOBID>.0
```

When you’re finished, simply exit the SLURM session to close the VSCode tunnel and release the assigned resources.

::: {dropdown} Why do I have to authenticate via GitHub?
:color: info
:icon: info

As explained in [VSCode docs](https://code.visualstudio.com/docs/remote/tunnels) it serves as a secure way to authenticate the user and ensure that only the user who initiated the tunnel can access it:
> Tunneling securely transmits data from one network to another via [Microsoft dev tunnels](https://learn.microsoft.com/azure/developer/dev-tunnels/overview).
>
> Both hosting and connecting to a tunnel requires authentication with the same Github or Microsoft account on each end. In both cases, VS Code will make outbound connections to a service hosted in Azure; no firewall changes are generally necessary, and VS Code doesn't set up any network listeners.
>
>Once you connect from a remote VS Code instance, an SSH connection is created over the tunnel in order to provide end-to-end encryption.
:::

## Additional benefits of code tunnel

One advantage of using VSCode's code tunnel is that it forwards any HTTP servers launched from the same node, such as Dash-Plotly apps or Jupyter Notebook servers. To launch your additional server, request a separate slurm job for the same compute node, e.g.:

```{code-block} console
$ srun -p fast -w <node-name> -n 4 --mem 8G --pty bash -i
```
When these are initiated, VSCode will notify you with a link that you can follow to access the server's UI directly.
15 changes: 2 additions & 13 deletions _static/basic.css
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
/*
* basic.css
* ~~~~~~~~~
*
* Sphinx stylesheet -- basic theme.
*
* :copyright: Copyright 2007-2024 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/

/* -- main layout ----------------------------------------------------------- */
Expand Down Expand Up @@ -115,15 +108,11 @@ img {
/* -- search page ----------------------------------------------------------- */

ul.search {
margin: 10px 0 0 20px;
padding: 0;
margin-top: 10px;
}

ul.search li {
padding: 5px 0 5px 20px;
background-image: url(file.png);
background-repeat: no-repeat;
background-position: 0 7px;
padding: 5px 0;
}

ul.search li a {
Expand Down
7 changes: 0 additions & 7 deletions _static/doctools.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
/*
* doctools.js
* ~~~~~~~~~~~
*
* Base JavaScript utilities for all Sphinx HTML documentation.
*
* :copyright: Copyright 2007-2024 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
"use strict";

Expand Down
7 changes: 0 additions & 7 deletions _static/language_data.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
/*
* language_data.js
* ~~~~~~~~~~~~~~~~
*
* This script contains the language-specific data used by searchtools.js,
* namely the list of stopwords, stemmer, scorer and splitter.
*
* :copyright: Copyright 2007-2024 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/

var stopwords = ["a", "and", "are", "as", "at", "be", "but", "by", "for", "if", "in", "into", "is", "it", "near", "no", "not", "of", "on", "or", "such", "that", "the", "their", "then", "there", "these", "they", "this", "to", "was", "will", "with"];
Expand Down
2 changes: 1 addition & 1 deletion _static/scripts/bootstrap.js.map

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions _static/scripts/fontawesome.js

Large diffs are not rendered by default.

File renamed without changes.
1 change: 1 addition & 0 deletions _static/scripts/fontawesome.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _static/scripts/pydata-sphinx-theme.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _static/scripts/pydata-sphinx-theme.js.map

Large diffs are not rendered by default.

38 changes: 25 additions & 13 deletions _static/searchtools.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
/*
* searchtools.js
* ~~~~~~~~~~~~~~~~
*
* Sphinx JavaScript utilities for the full-text search.
*
* :copyright: Copyright 2007-2024 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
"use strict";

Expand All @@ -20,7 +13,7 @@ if (typeof Scorer === "undefined") {
// and returns the new score.
/*
score: result => {
const [docname, title, anchor, descr, score, filename] = result
const [docname, title, anchor, descr, score, filename, kind] = result
return score
},
*/
Expand All @@ -47,6 +40,14 @@ if (typeof Scorer === "undefined") {
};
}

// Global search result kind enum, used by themes to style search results.
class SearchResultKind {
static get index() { return "index"; }
static get object() { return "object"; }
static get text() { return "text"; }
static get title() { return "title"; }
}

const _removeChildren = (element) => {
while (element && element.lastChild) element.removeChild(element.lastChild);
};
Expand All @@ -64,9 +65,13 @@ const _displayItem = (item, searchTerms, highlightTerms) => {
const showSearchSummary = DOCUMENTATION_OPTIONS.SHOW_SEARCH_SUMMARY;
const contentRoot = document.documentElement.dataset.content_root;

const [docName, title, anchor, descr, score, _filename] = item;
const [docName, title, anchor, descr, score, _filename, kind] = item;

let listItem = document.createElement("li");
// Add a class representing the item's type:
// can be used by a theme's CSS selector for styling
// See SearchResultKind for the class names.
listItem.classList.add(`kind-${kind}`);
let requestUrl;
let linkUrl;
if (docBuilder === "dirhtml") {
Expand Down Expand Up @@ -115,8 +120,10 @@ const _finishSearch = (resultCount) => {
"Your search did not match any documents. Please make sure that all words are spelled correctly and that you've selected enough categories."
);
else
Search.status.innerText = _(
"Search finished, found ${resultCount} page(s) matching the search query."
Search.status.innerText = Documentation.ngettext(
"Search finished, found one page matching the search query.",
"Search finished, found ${resultCount} pages matching the search query.",
resultCount,
).replace('${resultCount}', resultCount);
};
const _displayNextItem = (
Expand All @@ -138,7 +145,7 @@ const _displayNextItem = (
else _finishSearch(resultCount);
};
// Helper function used by query() to order search results.
// Each input is an array of [docname, title, anchor, descr, score, filename].
// Each input is an array of [docname, title, anchor, descr, score, filename, kind].
// Order the results by score (in opposite order of appearance, since the
// `_displayNextItem` function uses pop() to retrieve items) and then alphabetically.
const _orderResultsByScoreThenName = (a, b) => {
Expand Down Expand Up @@ -248,6 +255,7 @@ const Search = {
searchSummary.classList.add("search-summary");
searchSummary.innerText = "";
const searchList = document.createElement("ul");
searchList.setAttribute("role", "list");
searchList.classList.add("search");

const out = document.getElementById("search-results");
Expand Down Expand Up @@ -318,7 +326,7 @@ const Search = {
const indexEntries = Search._index.indexentries;

// Collect multiple result groups to be sorted separately and then ordered.
// Each is an array of [docname, title, anchor, descr, score, filename].
// Each is an array of [docname, title, anchor, descr, score, filename, kind].
const normalResults = [];
const nonMainIndexResults = [];

Expand All @@ -337,6 +345,7 @@ const Search = {
null,
score + boost,
filenames[file],
SearchResultKind.title,
]);
}
}
Expand All @@ -354,6 +363,7 @@ const Search = {
null,
score,
filenames[file],
SearchResultKind.index,
];
if (isMain) {
normalResults.push(result);
Expand Down Expand Up @@ -475,6 +485,7 @@ const Search = {
descr,
score,
filenames[match[0]],
SearchResultKind.object,
]);
};
Object.keys(objects).forEach((prefix) =>
Expand Down Expand Up @@ -585,6 +596,7 @@ const Search = {
null,
score,
filenames[file],
SearchResultKind.text,
]);
}
return results;
Expand Down
6 changes: 0 additions & 6 deletions _static/styles/bootstrap.css

This file was deleted.

1 change: 0 additions & 1 deletion _static/styles/bootstrap.css.map

This file was deleted.

32 changes: 31 additions & 1 deletion _static/styles/pydata-sphinx-theme.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _static/styles/pydata-sphinx-theme.css.map

Large diffs are not rendered by default.

Loading

0 comments on commit 3e60cc1

Please sign in to comment.