Skip to content

Commit bf32d01

Browse files
authored
Allow creating an exec with cpu node types (#31)
* Allow creating an exec with cpu node types Update the ls-node-types command to list CPU node types. Update the session logging and listing to print the node type. * Default to CPU node type Default to the intel cpu node type, unless a --gpu-type is passed on the cli. The default is set in the .unweave/config.toml file. * Update unweave/unweave
1 parent 5fffd8d commit bf32d01

File tree

7 files changed

+154
-80
lines changed

7 files changed

+154
-80
lines changed

cmd/provider.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313

1414
func nodeTypesToTable(nodeTypes []types.NodeType) ([]ui.Column, []ui.Row) {
1515
cols := []ui.Column{
16+
{Title: "Type", Width: 7},
1617
{Title: "Name", Width: 25},
1718
{Title: "ID", Width: 21},
1819
{Title: "Price", Width: 10},
@@ -27,6 +28,7 @@ func nodeTypesToTable(nodeTypes []types.NodeType) ([]ui.Column, []ui.Row) {
2728
regions = strings.Join(nodeType.Regions, ", ")
2829
}
2930
row := ui.Row{
31+
nodeType.Type,
3032
fmt.Sprintf("%s", dashIfZeroValue(tools.StringInv(nodeType.Name))),
3133
fmt.Sprintf("%s", dashIfZeroValue(nodeType.ID)),
3234
fmt.Sprintf("$%2.2f", float32(tools.IntInv(nodeType.Price))/100),

cmd/session.go

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,13 @@ func renderSessionListWithSessions(sessions []types.Exec) {
233233
},
234234
{Title: "vCPUs", Width: 5},
235235
{
236-
Title: "GPU",
237-
Width: 5 + ui.MaxFieldLength(sessions, func(exec types.Exec) string {
238-
return exec.Spec.GPU.Type
236+
Title: "Node type", Width: 5 + ui.MaxFieldLength(sessions, func(exec types.Exec) string {
237+
nodeType := exec.Spec.GPU.Type
238+
if nodeType == "" {
239+
nodeType = exec.Spec.CPU.Type
240+
}
241+
242+
return nodeType
239243
}),
240244
},
241245
{Title: "NumGPUs", Width: 12},
@@ -300,10 +304,15 @@ func renderSessionListWithSessions(sessions []types.Exec) {
300304
hostname = fmt.Sprintf("https://%s (internal port: %d)", s.Network.HTTPService.Hostname, s.Network.HTTPService.InternalPort)
301305
}
302306

307+
nodeType := s.Spec.GPU.Type
308+
if nodeType == "" {
309+
nodeType = s.Spec.CPU.Type
310+
}
311+
303312
row := ui.Row{
304313
fmt.Sprintf("%s", s.Name),
305314
fmt.Sprintf("%v", s.Spec.CPU.Min),
306-
fmt.Sprintf("%s", s.Spec.GPU.Type),
315+
nodeType,
307316
fmt.Sprintf("%v", s.Spec.GPU.Count.Min),
308317
fmt.Sprintf("%v", s.Spec.HDD.Min),
309318
// fmt.Sprintf("%v", s.Specs.RAM.Min),
@@ -451,9 +460,11 @@ func parseHardwareSpec() (types.HardwareSpec, error) {
451460
Max: config.GPUMemory,
452461
},
453462
},
454-
CPU: types.HardwareRequestRange{
455-
Min: config.CPUs,
456-
Max: config.CPUs,
463+
CPU: types.CPU{
464+
HardwareRequestRange: types.HardwareRequestRange{
465+
Min: config.CPUs,
466+
Max: config.CPUs,
467+
},
457468
},
458469
RAM: types.HardwareRequestRange{
459470
Min: config.Memory,

config/constants.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ const (
66
UnweaveSSHKeysDir = ".unweave_global/.ssh"
77
)
88

9-
var DefaultGPUTypes = []string{""}
9+
var DefaultNodeTypes = []string{}

config/templates/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ default_provider = 'unweave'
1515
# If the your list is `node_type = ["a100", "v100"]`, the `a100` node type will be used by
1616
# defualt. If `a100` is not available, `v100` will be used, until the end of the list. If
1717
# none of the node types are available, Unweave will return an error.
18-
node_types = ["rtx_4000", "a40"]
18+
node_types = ["intel"]
1919

2020
{{- range .Providers}}
2121

go.mod

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ require (
77
github.com/franela/goblin v0.0.0-20211003143422-0a4f594942bf
88
github.com/manifoldco/promptui v0.9.0
99
github.com/muesli/reflow v0.3.0
10-
github.com/pelletier/go-toml/v2 v2.0.6
10+
github.com/pelletier/go-toml/v2 v2.0.8
1111
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06
1212
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
1313
github.com/spf13/cobra v1.6.1
14-
github.com/unweave/unweave v0.0.0-20230621145607-b079ce8b4089
14+
github.com/unweave/unweave v0.0.0-20230627125606-54cbf0f9130e
1515
)
1616

1717
require (
@@ -20,16 +20,17 @@ require (
2020
github.com/ghodss/yaml v1.0.0 // indirect
2121
github.com/go-chi/render v1.0.2 // indirect
2222
github.com/inconshreveable/mousetrap v1.0.1 // indirect
23-
github.com/lib/pq v1.10.6 // indirect
23+
github.com/lib/pq v1.10.9 // indirect
2424
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
2525
github.com/mattn/go-colorable v0.1.13 // indirect
26-
github.com/mattn/go-isatty v0.0.16 // indirect
27-
github.com/mattn/go-runewidth v0.0.13 // indirect
26+
github.com/mattn/go-isatty v0.0.19 // indirect
27+
github.com/mattn/go-runewidth v0.0.14 // indirect
2828
github.com/muesli/termenv v0.11.1-0.20220204035834-5ac8409525e0 // indirect
2929
github.com/rivo/uniseg v0.2.0 // indirect
30-
github.com/rs/zerolog v1.28.0 // indirect
30+
github.com/rs/zerolog v1.29.1 // indirect
3131
github.com/spf13/pflag v1.0.5 // indirect
32-
golang.org/x/crypto v0.1.0 // indirect
33-
golang.org/x/sys v0.3.0 // indirect
32+
golang.org/x/crypto v0.10.0 // indirect
33+
golang.org/x/sys v0.9.0 // indirect
34+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
3435
gopkg.in/yaml.v2 v2.4.0 // indirect
3536
)

go.sum

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5O
88
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
99
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8=
1010
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
11-
github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
11+
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
1212
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
1313
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1414
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
@@ -22,9 +22,13 @@ github.com/go-chi/render v1.0.2/go.mod h1:/gr3hVkmYR0YlEy3LxCuVRFzEu9Ruok+gFqbIo
2222
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
2323
github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc=
2424
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
25+
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
26+
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
27+
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
28+
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
2529
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
26-
github.com/lib/pq v1.10.6 h1:jbk+ZieJ0D7EVGJYpL9QTz7/YW6UHbmdnZWYyK5cdBs=
27-
github.com/lib/pq v1.10.6/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
30+
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
31+
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
2832
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
2933
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
3034
github.com/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYthEiA=
@@ -33,29 +37,30 @@ github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb
3337
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
3438
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
3539
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
36-
github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ=
3740
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
41+
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
42+
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
3843
github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
3944
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
40-
github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
4145
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
46+
github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU=
47+
github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
4248
github.com/muesli/reflow v0.2.1-0.20210115123740-9e1d0d53df68/go.mod h1:Xk+z4oIWdQqJzsxyjgl3P22oYZnHdZ8FFTHAQQt5BMQ=
4349
github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
4450
github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
4551
github.com/muesli/termenv v0.11.1-0.20220204035834-5ac8409525e0 h1:STjmj0uFfRryL9fzRA/OupNppeAID6QJYPMavTL7jtY=
4652
github.com/muesli/termenv v0.11.1-0.20220204035834-5ac8409525e0/go.mod h1:Bd5NYQ7pd+SrtBSrSNoBBmXlcY8+Xj4BMJgh8qcZrvs=
47-
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
48-
github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU=
49-
github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek=
53+
github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ=
54+
github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4=
5055
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
5156
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
5257
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
5358
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
5459
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
5560
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
5661
github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
57-
github.com/rs/zerolog v1.28.0 h1:MirSo27VyNi7RJYP3078AA1+Cyzd2GB66qy3aUHvsWY=
58-
github.com/rs/zerolog v1.28.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0=
62+
github.com/rs/zerolog v1.29.1 h1:cO+d60CHkknCbvzEWxP0S9K6KqyTjrCNUy1LdQLCGPc=
63+
github.com/rs/zerolog v1.29.1/go.mod h1:Le6ESbR7hc+DP6Lt1THiV8CQSdkkNrd3R0XbEgp3ZBU=
5964
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
6065
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI=
6166
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs=
@@ -71,21 +76,23 @@ github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpE
7176
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
7277
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
7378
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
74-
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
75-
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
76-
github.com/unweave/unweave v0.0.0-20230621145607-b079ce8b4089 h1:HBU0Nr5LLfJNWoWaDMbmOlQyTEwoCZfEIOVsWOHvocQ=
77-
github.com/unweave/unweave v0.0.0-20230621145607-b079ce8b4089/go.mod h1:jSsvVJqqgH9Botkau2N4JI5W7z4JN9jG3pyywunr6w8=
78-
golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU=
79-
golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
79+
github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY=
80+
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
81+
github.com/unweave/unweave v0.0.0-20230627125606-54cbf0f9130e h1:BkEjKaicsL0XD+BbRlICWscJ0u1Tes0eDdeYUbUohKs=
82+
github.com/unweave/unweave v0.0.0-20230627125606-54cbf0f9130e/go.mod h1:jSsvVJqqgH9Botkau2N4JI5W7z4JN9jG3pyywunr6w8=
83+
golang.org/x/crypto v0.10.0 h1:LKqV2xt9+kDzSTfOhx4FrkEBcMrAgHSYgzywV9zcGmM=
84+
golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I=
8085
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
8186
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
8287
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
8388
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
84-
golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=
85-
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
86-
golang.org/x/term v0.2.0 h1:z85xZCsEl7bi/KwbNADeBYoOP0++7W1ipu+aGnpwzRM=
89+
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
90+
golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s=
91+
golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
92+
golang.org/x/term v0.9.0 h1:GRRCnKYhdQrD8kfRAdQ6Zcw1P0OcELxGLKJvtjVMZ28=
8793
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
88-
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
94+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
95+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
8996
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
9097
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
9198
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)