Published
Edited
Sep 20, 2021
Insert cell
Insert cell
intro_txt = md`
You can follow these steps to set up the wolf controller.

## Authorizing Google Cloud SDK

Make sure that you have installed the [Google Cloud SDK](https://cloud.google.com/sdk/docs/install#mac) on your local computer. Then run the following commands in your terminal to ensure you have authorized the Google Cloud SDK.

\`\`\`
gcloud auth login --update-adc
\`\`\`

## Provision of wolF Cluster
<p>
Enter your desired GCP project to use and name for the new controller:
</p>
`
Insert cell
dashboard_domain = "wolf.fm"
Insert cell
viewof gcp_project = {
let urlparams = new URLSearchParams(window.location.search)
let project = urlparams.get("project") ?? "broad-getzlab-wolfws-202109"
let name = urlparams.get("name") ?? "wolf-controller"
return Inputs.text({label: "GCP Project", value: project})
}
Insert cell
viewof vm_name = {
let urlparams = new URLSearchParams(window.location.search)
let project = urlparams.get("project") ?? "broad-getzlab-wolfws-202109"
let name = urlparams.get("name") ?? "wolf-controller"
return Inputs.text({label: "VM Name", value: name})
}
Insert cell
viewof machine_type = Inputs.select(["n1-standard-4", "n1-standard-8", "n1-standard-2", "n1-standard-16", "n1-highmem-2", "n1-highmem-4", "n1-highmem-8", "n1-highmem-16"], {label: "Machine Type"})
Insert cell
gcp_zone = "us-east1-d"
Insert cell
graphql_port = {
update_window_url(gcp_project, vm_name)
return map_vm_to_port(gcp_project, vm_name)
}
Insert cell
wolfapi_port = graphql_port + 1
Insert cell
notebook_port = graphql_port + 2
Insert cell
vscode_port = graphql_port + 3
Insert cell
instruction_txt = md`
Now you can run the following shell commands on your computer to setup the VM:

<pre>
# clone the code
git clone git@github.com:getzlab/slurm_gcp_docker.git slurm_gcp_docker
cd slurm_gcp_docker

# run the remote provision script
python3 src/setup_remote.py \\
--project <b>${gcp_project}</b> \\
--zone <b>${gcp_zone}</b> \\
--machine-type <b>${machine_type}</b> \\
<b>${vm_name}</b>
</pre>

<h2>Connect to the Controller with Port Forwarding</h2>

Finally, to use this dashboard, you will need to forward some ports from the controller to your local computer. Run the following command:

<pre>
gcloud compute ssh \\
--project ${gcp_project} \\
--zone ${gcp_zone} ${vm_name} \\
-- -L ${notebook_port}:localhost:8888 \\
-L ${graphql_port}:localhost:4200 \\
-L ${wolfapi_port}:localhost:9900 \\
-L ${vscode_port}:localhost:8889
</pre>

Then open http://port${graphql_port}.wolfgui.${dashboard_domain}/machine to see the dashboard.
`
Insert cell
// Assign a unique port to each VM. So that we may connect to multiple controllers.
function map_vm_to_port(project, name) {
let joined_str = project + "##" + name
let port = Math.abs(hash_string(joined_str)) % 40000 + 2000
return port
}
Insert cell
function update_window_url(project, name) {
let state = {
project: project,
name: name
}
update_port(project, name)
history.replaceState(state, "", "index" + `?project=${project}&name=${name}`)
}
Insert cell
function hash_string(str) {
var hash = 0, i, chr;
if (str.length === 0) return hash;
for (i = 0; i < str.length; i++) {
chr = str.charCodeAt(i);
hash = ((hash << 5) - hash) + chr;
hash |= 0; // Convert to 32bit integer
}
return hash;
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more