Skip to content
This repository was archived by the owner on Jun 6, 2023. It is now read-only.

Commit 1dc98e1

Browse files
committed
change sample apps to create C1 Ubuntu Server instances
1 parent d5460e2 commit 1dc98e1

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

samples/sample_bash_script.sh

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22

33
# Note: this script requires the 'jq' tool for JSON parsing. See https://stedolan.github.io/jq/
4+
# To install jq run 'sudo apt-get install jq'
45

56
# Substitute your apiKey here
67
PAPERSPACE_API_KEY=1be4f97...
@@ -9,14 +10,23 @@ PAPERSPACE_API_KEY=1be4f97...
910
echo "paperspace templates list"
1011
paperspace templates list
1112

12-
# Select the first template with a label of "ML in a Box", using the 'jq' tool
13-
echo "finding a template with label 'ML in a Box'..."
14-
t_id=`paperspace templates list | jq -r '.[] | select(.label=="ML in a Box") | .id'`
13+
# Select the first template with a label of "Ubuntu 14.04 Server", using the 'jq' tool
14+
# NOTE: to use the "ML in a Box" template change "Ubuntu 14.04 Server" to "ML in a Box"
15+
t_label="Ubuntu 14.04 Server"
16+
echo "Finding a template with label \"$t_label\" ..."
17+
t_id=`paperspace templates list | jq -r --arg t "$t_label" '.[] | select(.label==$t) | .id'`
18+
echo "Found template id \"$t_id\""
1519

1620
# Create a machine and parse out the new machine id
17-
echo "paperspace machines create ... --templateId $t_id"
21+
# NOTE: to create a machine from the "ML in a Box" template use "GPU+" or "P5000" instead of "C1"
22+
m_machineType="C1"
23+
echo "paperspace machines create --machineName \"Test Machine\" \\"
24+
echo " --billingType \"hourly\" --region \"East Coast (NY2)\" --size 50 \\"
25+
echo " --machineType \"$m_machineType\" --templateId \"$t_id\""
26+
1827
m_id=`paperspace machines create --machineName "Test Machine" --billingType "hourly" \
19-
--region "East Coast (NY2)" --size 50 --machineType "GPU+" --templateId "$t_id" | jq -r '.id'`
28+
--region "East Coast (NY2)" --size 50 --machineType "$m_machineType" --templateId "$t_id" | jq -r '.id'`
29+
echo "Created machine with machine id $m_id"
2030

2131
echo "paperspace machines waitfor --machineId $m_id --state ready"
2232
paperspace machines waitfor --machineId "$m_id" --state "ready"

samples/sample_node_app.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Assumes you have installed the paperspace-node package globally.
22
// Use "require('../../paperspace-node')" if running from the repository tree.
3-
var paperspace_node = require('../../paperspace-node');
3+
var paperspace_node = require('paperspace-node');
44

55
// Set apkKey for use of the paperspace api
66
var paperspace = paperspace_node({
@@ -18,27 +18,32 @@ paperspace.templates.list(
1818
}
1919
console.log(resp.body);
2020

21-
// Search the response body for a template with the label 'ML in a Box'
21+
// Search the response body for a template with the label 'Ubuntu 14.04 Server'
22+
// NOTE: to use the 'ML in a Box' template substitute 'ML in a Box' for 'Ubuntu 14.04 Server'
23+
// and substitute 'GPU+' or 'P5000' for the machineType value. The 'C1' machineType is CPU-only.
24+
var t_label = 'Ubuntu 14.04 Server'; // or 'ML in a Box'
25+
var m_machineType = 'C1'; // or 'GPU+' or 'P5000' if choosing the 'ML in a Box' template
26+
2227
var t_id;
2328
for(var i = 0; i < resp.body.length; i++) {
24-
if(resp.body[i].label === 'ML in a Box') {
29+
if(resp.body[i].label === t_label) {
2530
t_id = resp.body[i].id;
2631
break;
2732
}
2833
}
2934
if (!t_id) {
30-
console.log('Error: \'ML in a Box\' template not found.');
35+
console.log('Error: \'' + t_label + '\' template not found.');
3136
process.exit(1);
3237
}
3338

34-
// Create a machine using the found template id
35-
console.log('\npaperspace.machines.create({\n region: \'East Coast (NY2)\',\n machineType: \'GPU+\',');
39+
// Create a machine using the found template id, and the specified machine typ from above
40+
console.log('\npaperspace.machines.create({\n region: \'East Coast (NY2)\',\n machineType: \'' + m_machineType + '\',');
3641
console.log(' size: 50,\n billingType: \'hourly\',\n machineName: \'Test Machine\',');
3742
console.log(' templateId: \'' + t_id + '\'}, ...);');
3843

3944
paperspace.machines.create({
4045
region: 'East Coast (NY2)',
41-
machineType: 'GPU+',
46+
machineType: m_machineType,
4247
size: 50,
4348
billingType: 'hourly',
4449
machineName: 'Test Machine',

0 commit comments

Comments
 (0)