daytona 0.231.1 → 0.233.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eaebf5381aaab828320928cfe2b93c1d7bc97debb3c7d00540670369160f7ec7
4
- data.tar.gz: 0500242fcb1251cef97ce23d7ad4161b4ac22b0a1a67c8b2a730ca3e09e72267
3
+ metadata.gz: cca7c7f32049c410b94923b03635ae5b11a655fec10322a304cbcf4de504b35a
4
+ data.tar.gz: 5c83c64990b1491d410ca6b10932bfc4e608fe9d0172be3581d3d9660b095dcc
5
5
  SHA512:
6
- metadata.gz: c9c3e99267068a9459fc4fd4864e19abea1bc1034dc477e4057e8fe3cf430afd21a45bfcfb2550330c413f0dde18a6f9cc31a2bd92da068982c08c870c8e7343
7
- data.tar.gz: 6a96eb38e27052740ebe77e5b842df21086e9811409263b9720f9600442e5caa186ddb3908f2855f2d6e024c85d155cb83e1410f9928be7fbfbbfd25a32974fc
6
+ metadata.gz: a714624344d6f55d898aa0d9660d37665a4a694bae9f2402d5e7c29f6017912bf7b341077cfdcd6f1aa915191f360abceed9bb77f295b497eec6e3f7e763084c
7
+ data.tar.gz: ae12b125432901005cdf2b08ed97e1ef2ac877e0b3da1d2497138835579b9d779e96b8cbd378df9c96b0c82cafb171c39763e6207bac2f33dc998b6f160c725a
data/README.md CHANGED
@@ -11,15 +11,17 @@ Requires **Ruby >= 3.2**. Check your version with `ruby -v` before installing
11
11
  Install the package using **gem**:
12
12
 
13
13
  ```bash
14
- gem install daytona
14
+ gem install daytona -v '< 1'
15
15
  ```
16
16
 
17
17
  or add it to your **Gemfile**:
18
18
 
19
19
  ```ruby
20
- gem 'daytona'
20
+ gem 'daytona', '< 1'
21
21
  ```
22
22
 
23
+ The `< 1` pin keeps you on the 0.x line: `daytona` 2.x is a new major version with breaking changes.
24
+
23
25
  ## Get API key
24
26
 
25
27
  Generate an API key from the [Daytona Dashboard ↗](https://app.daytona.io/dashboard/keys) to authenticate SDK requests and access Daytona services. For more information, see the [API keys](https://www.daytona.io/docs/en/api-keys/) documentation.
@@ -283,3 +285,60 @@ daytona.volume.list.each { |vol| puts vol.name }
283
285
  query = Daytona::ListSandboxesQuery.new(labels: { 'env' => 'dev' })
284
286
  daytona.list(query).each { |sandbox| puts sandbox.id }
285
287
  ```
288
+
289
+ ## Multi-node GPU sandboxes
290
+
291
+ Multi-node access requires an enabled organization quota and compatible fabric capacity.
292
+ Initial profiles use whole 8-GPU nodes: 16 GPUs creates two nodes. Use an image containing
293
+ your framework and RDMA userspace (`libibverbs.so.1` and an mlx5 provider).
294
+
295
+ ```ruby
296
+ params = Daytona::CreateSandboxFromImageParams.new(
297
+ image: 'your-registry/rdma-workload:tag',
298
+ resources: Daytona::Resources.new(gpu: 16, cpu_per_node: [16, 16], memory_per_node: [64, 64], disk_per_node: [100, 100])
299
+ )
300
+ sandbox = daytona.create(params)
301
+ worker = sandbox.nodes[1] # Rank zero is the head.
302
+ worker.process.exec(command: 'hostname')
303
+
304
+ begin
305
+ results = sandbox.nodes.process.exec(
306
+ command: 'hostname', timeout: 120,
307
+ on_stdout: ->(rank, chunk) { print "[rank #{rank}] #{chunk}" }
308
+ )
309
+ puts results.transform_values(&:result)
310
+ rescue Daytona::Sdk::NodeOperationError => error
311
+ puts error.failures # Errors keyed by rank.
312
+ puts error.results # Successful ranks remain available.
313
+ end
314
+ sandbox.nodes.fs.upload_file('hello', '/tmp/shared.txt')
315
+ puts worker.preview_url(8080).url
316
+ ssh = worker.create_ssh_access(60)
317
+ puts ssh.ssh_command
318
+ worker.revoke_ssh_access(ssh.token)
319
+
320
+ sandbox.nodes.add(nodes: [Daytona::NodeResources.new(cpu: 16, memory: 64, disk: 100)])
321
+ sandbox.nodes.release(count: 1) # Releases the highest rank.
322
+ # When a rank fails: sandbox.nodes.replace(rank: rank).
323
+ ```
324
+
325
+ Scalar resources remain supported; arrays specify per-node allocations ordered by rank.
326
+ Node handles expose resources, state, incarnation, failure and fabric health; the sandbox
327
+ exposes `node_count`, `topology_generation` and `degraded`. Call `sandbox.refresh` for current
328
+ metadata. Retained node handles survive refreshes; enumerate the collection again after
329
+ membership changes to find replacements. Existing sandbox services address the head.
330
+
331
+ Membership helpers submit the generation of the displayed nodes and refresh membership after completion.
332
+ After a topology conflict, refresh and inspect the nodes before retrying. The helpers default to `timeout: 600`; zero disables the overall wait limit. A timeout ends the SDK wait without
333
+ canceling the submitted operation. Admission errors propagate directly; the SDK adds no queue.
334
+ Configured transport timeouts still apply.
335
+
336
+ Parallel helpers capture current membership, settle every rank and report rank-specific
337
+ errors. Exec uses a private session on every node even without streaming. Callbacks receive
338
+ `(rank, chunk)` and are serialized. A positive timeout applies per command; zero has no SDK
339
+ execution limit. Session cleanup is attempted after success, error or cancellation, with an
340
+ independent ten-second budget that needs connectivity. Successful commands remain successful
341
+ if cleanup fails; inspect `node.warnings`. RDMA checks warn without blocking execution.
342
+ Uploads are not rolled back on partial failure; IO input is read once before parallel upload.
343
+ Applications must coordinate checkpointing and process restarts after membership changes;
344
+ environment variables in existing processes are not rewritten.
@@ -60,7 +60,10 @@ module Daytona
60
60
  return self if pkgs.empty?
61
61
 
62
62
  extra_args = format_pip_install_args(find_links:, index_url:, extra_index_urls:, pre:, extra_options:)
63
- @dockerfile += "RUN python -m pip install #{Shellwords.join(pkgs.sort)}#{extra_args}\n"
63
+ # pip reads an argument beginning with `-` as an option, and shell quoting does not
64
+ # change that — the escaping covers shell metacharacters, not a leading dash. `--`
65
+ # closes the option list, so every package is parsed as a requirement.
66
+ @dockerfile += "RUN python -m pip install#{extra_args} -- #{Shellwords.join(pkgs.sort)}\n"
64
67
 
65
68
  self
66
69
  end
@@ -20,12 +20,35 @@ module Daytona
20
20
  # @return [String, Array<String>, nil] Preferred GPU type for the Sandbox
21
21
  attr_reader :gpu_type
22
22
 
23
+ # @return [Array<Integer>, nil] CPU cores for each node in rank order
24
+ attr_reader :cpu_per_node
25
+
26
+ # @return [Array<Integer>, nil] Memory in GiB for each node in rank order
27
+ attr_reader :memory_per_node
28
+
29
+ # @return [Array<Integer>, nil] Disk space in GiB for each node in rank order
30
+ attr_reader :disk_per_node
31
+
23
32
  # @param cpu [Integer, nil] Number of CPU cores to allocate
24
33
  # @param memory [Integer, nil] Amount of memory in GiB to allocate
25
34
  # @param disk [Integer, nil] Amount of disk space in GiB to allocate
26
35
  # @param gpu [Integer, nil] Number of GPUs to allocate
27
36
  # @param gpu_type [String, Array<String>, nil] Preferred GPU type for the Sandbox
28
- def initialize(cpu: nil, memory: nil, disk: nil, gpu: nil, gpu_type: nil)
37
+ # @param cpu_per_node [Array<Integer>, nil] CPU cores for each node in rank order
38
+ # @param memory_per_node [Array<Integer>, nil] Memory in GiB for each node in rank order
39
+ # @param disk_per_node [Array<Integer>, nil] Disk space in GiB for each node in rank order
40
+ def initialize(cpu: nil, memory: nil, disk: nil, gpu: nil, gpu_type: nil,
41
+ cpu_per_node: nil, memory_per_node: nil, disk_per_node: nil)
42
+ [[cpu, cpu_per_node], [memory, memory_per_node], [disk, disk_per_node]].each do |scalar, values|
43
+ next if values.nil?
44
+ raise Sdk::Error, 'Specify either the scalar or its per-node values' unless scalar.nil?
45
+ next if values.is_a?(Array) && !values.empty? && values.all? { |item| item.is_a?(Integer) && item.positive? }
46
+
47
+ raise Sdk::Error, 'Per-node resources must be non-empty arrays of positive integers'
48
+ end
49
+ @cpu_per_node = cpu_per_node
50
+ @memory_per_node = memory_per_node
51
+ @disk_per_node = disk_per_node
29
52
  @cpu = cpu
30
53
  @memory = memory
31
54
  @disk = disk
@@ -33,7 +56,13 @@ module Daytona
33
56
  @gpu_type = gpu_type
34
57
  end
35
58
 
59
+ # @api private
60
+ def validate_scalar!
61
+ raise Sdk::Error, 'Per-node resources are only supported for sandbox creation' if [cpu_per_node, memory_per_node,
62
+ disk_per_node].any?
63
+ end
64
+
36
65
  # @return [Hash] Hash representation of the resources
37
- def to_h = { cpu:, memory:, disk:, gpu:, gpu_type: }.compact
66
+ def to_h = { cpu:, memory:, disk:, gpu:, gpu_type:, cpu_per_node:, memory_per_node:, disk_per_node: }.compact
38
67
  end
39
68
  end
@@ -170,7 +170,16 @@ module Daytona
170
170
  first_page = false
171
171
  response = fetch_sandbox_page(q, cursor)
172
172
  response.items.each do |sandbox_dto|
173
- yielder << to_sandbox(sandbox_dto: sandbox_dto)
173
+ if sandbox_dto.gpu.to_i > SandboxNodes::GPUS_PER_NODE
174
+ begin
175
+ sandbox = get(sandbox_dto.id)
176
+ rescue Sdk::NotFoundError
177
+ next
178
+ end
179
+ else
180
+ sandbox = to_sandbox(sandbox_dto:)
181
+ end
182
+ yielder << sandbox
174
183
  end
175
184
  cursor = response.next_cursor
176
185
  break if cursor.nil? || (cursor.respond_to?(:empty?) && cursor.empty?)
@@ -333,6 +342,11 @@ module Daytona
333
342
  create_sandbox.cpu = params.resources&.cpu
334
343
  create_sandbox.memory = params.resources&.memory
335
344
  create_sandbox.disk = params.resources&.disk
345
+ if params.resources.is_a?(Resources)
346
+ create_sandbox.cpu_per_node = params.resources.cpu_per_node unless params.resources.cpu_per_node.nil?
347
+ create_sandbox.memory_per_node = params.resources.memory_per_node unless params.resources.memory_per_node.nil?
348
+ create_sandbox.disk_per_node = params.resources.disk_per_node unless params.resources.disk_per_node.nil?
349
+ end
336
350
  create_sandbox.gpu = params.resources&.gpu
337
351
  if params.resources&.gpu_type
338
352
  create_sandbox.gpu_type =
data/lib/daytona/otel.rb CHANGED
@@ -179,5 +179,17 @@ module Daytona
179
179
  end
180
180
  end
181
181
  end
182
+
183
+ private
184
+
185
+ # Records the block with the span and duration metric of the instrumented +method_name+, for code that
186
+ # does that method's work without calling it.
187
+ #
188
+ # @param method_name [String, Symbol]
189
+ # @param component [String] component name for span/metric attributes
190
+ # @return [Object] The block's return value
191
+ def instrument_as(method_name, component:, &)
192
+ ::Daytona.with_instrumentation(otel_state, component, method_name.to_s, &)
193
+ end
182
194
  end
183
195
  end