forked from Paperspace/paperspace-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample_bash_script.sh
More file actions
executable file
·46 lines (34 loc) · 1.84 KB
/
sample_bash_script.sh
File metadata and controls
executable file
·46 lines (34 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
# Note: this script requires the 'jq' tool for JSON parsing. See https://stedolan.github.io/jq/
# To install jq run 'sudo apt-get install jq'
# Substitute your apiKey here
export PAPERSPACE_API_KEY=1be4f97...
# List out all the templates
echo "paperspace templates list"
paperspace templates list
# Select the first template with a label of "Ubuntu 14.04 Server", using the 'jq' tool
# NOTE: to use the "ML in a Box" template change "Ubuntu 14.04 Server" to "ML in a Box"
t_label="Ubuntu 14.04 Server"
echo "Finding a template with label \"$t_label\" ..."
t_id=`paperspace templates list | jq -r --arg t "$t_label" '.[] | select(.label==$t) | .id'`
echo "Found template id \"$t_id\""
# Create a machine and parse out the new machine id
# NOTE: to create a machine from the "ML in a Box" template use "GPU+" or "P5000" instead of "C1"
m_machineType="C1"
echo "paperspace machines create --machineName \"Test Machine\" \\"
echo " --billingType \"hourly\" --region \"East Coast (NY2)\" --size 50 \\"
echo " --machineType \"$m_machineType\" --templateId \"$t_id\""
m_id=`paperspace machines create --machineName "Test Machine" --billingType "hourly" \
--region "East Coast (NY2)" --size 50 --machineType "$m_machineType" --templateId "$t_id" | jq -r '.id'`
echo "Created machine with machine id $m_id"
echo "paperspace machines waitfor --machineId $m_id --state ready"
paperspace machines waitfor --machineId "$m_id" --state "ready"
echo "paperspace machines show --machineId $m_id"
paperspace machines show --machineId "$m_id"
echo "paperspace machines stop --machineId $m_id"
paperspace machines stop --machineId "$m_id"
echo "paperspace machines waitfor --machineId $m_id --state ready"
paperspace machines waitfor --machineId "$m_id" --state "off"
echo "paperspace machines destroy --machineId $m_id"
paperspace machines destroy --machineId "$m_id"
echo "done"