Skip to content

Commit 0e01b18

Browse files
committed
fix(sdk): complete resource model lint contracts
Document exported resource models and converters, format the client interface, and retain fixture keyword arguments while distinguishing template and ordinary clients for type checking. Refs NVIDIA#5111 Signed-off-by: Shiju <[email protected]>
1 parent f78b6f8 commit 0e01b18

6 files changed

Lines changed: 21 additions & 2 deletions

File tree

‎python/openshell/sandbox_test.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2014,6 +2014,7 @@ def __init__(
20142014
def Health(
20152015
self, request: object, timeout: float | None = None
20162016
) -> openshell_pb2.HealthResponse:
2017+
_ = request, timeout
20172018
return openshell_pb2.HealthResponse(
20182019
supports_sampled_resource_budget=self.sampled_budget_ack
20192020
)
@@ -2370,10 +2371,10 @@ def test_sampled_budget_requires_gateway_acknowledgement(template: bool) -> None
23702371
stub = _FakeSandboxStub()
23712372
budget = sandbox_pb2.SampledResourceBudget(resident_bytes=4096)
23722373
if template:
2373-
client = _template_client_with_fake_stub(stub)
2374+
template_client = _template_client_with_fake_stub(stub)
23742375

23752376
def write() -> object:
2376-
return client.create(
2377+
return template_client.create(
23772378
workspace="default", name="budget", sampled_budget=budget
23782379
)
23792380
else:

‎sdk/go/openshell/v1/health.go‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,17 @@ type HealthInterface interface {
5454
GetCurrentUser(ctx context.Context) (*CurrentUser, error)
5555
}
5656

57+
// ResourceCapabilities reports the configured compute driver's resource guarantees.
5758
type ResourceCapabilities = types.ResourceCapabilities
59+
60+
// ResourceDomainCapabilities describes resource limit and request enforcement.
5861
type ResourceDomainCapabilities = types.ResourceDomainCapabilities
62+
63+
// ResourceEnforcement identifies the mechanism and scope of a resource guarantee.
5964
type ResourceEnforcement = types.ResourceEnforcement
65+
66+
// GPUResourceCapabilities describes supported GPU selection methods.
6067
type GPUResourceCapabilities = types.GPUResourceCapabilities
68+
69+
// SampledBudgetCapabilities describes supported sampled workload budgets.
6170
type SampledBudgetCapabilities = types.SampledBudgetCapabilities

‎sdk/go/openshell/v1/internal/converter/sandbox.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,7 @@ func resourceDurationToProto(d *types.ResourceDuration) *durationpb.Duration {
640640
return &durationpb.Duration{Seconds: d.Seconds, Nanos: d.Nanos}
641641
}
642642

643+
// SampledBudgetFromProto copies a protobuf budget into the SDK model.
643644
func SampledBudgetFromProto(b *sb.SampledResourceBudget) *types.SampledResourceBudget {
644645
if b == nil {
645646
return nil
@@ -651,6 +652,8 @@ func SampledBudgetFromProto(b *sb.SampledResourceBudget) *types.SampledResourceB
651652
}
652653
return result
653654
}
655+
656+
// SampledBudgetToProto copies an SDK budget into its protobuf form.
654657
func SampledBudgetToProto(b *types.SampledResourceBudget) *sb.SampledResourceBudget {
655658
if b == nil {
656659
return nil

‎sdk/go/openshell/v1/resource.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
// SPDX-License-Identifier: Apache-2.0
3+
34
package v1
45

56
import (

‎sdk/go/openshell/v1/sandbox.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ type SandboxSuspendResumeInterface interface {
122122
// WaitSuspended polls until the sandbox reaches the Suspended phase.
123123
WaitSuspended(ctx context.Context, workspace, name string, opts ...WaitOptions) (*Sandbox, error)
124124
}
125+
125126
// ResourceDuration preserves protobuf duration precision and range.
126127
type ResourceDuration = types.ResourceDuration
127128

‎sdk/go/openshell/v1/types/health.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,23 +77,27 @@ type ResourceCapabilities struct {
7777
SampledBudget *SampledBudgetCapabilities
7878
}
7979

80+
// ResourceDomainCapabilities describes resource limit and request enforcement.
8081
type ResourceDomainCapabilities struct {
8182
LimitSupported bool
8283
LimitEnforcement *ResourceEnforcement
8384
RequestEnforcement *ResourceEnforcement
8485
}
8586

87+
// ResourceEnforcement identifies the mechanism and scope of a resource guarantee.
8688
type ResourceEnforcement struct {
8789
// Unknown enum values are preserved as "Unknown", never inferred as support.
8890
Kind string
8991
Scope string
9092
}
9193

94+
// GPUResourceCapabilities describes supported GPU selection methods.
9295
type GPUResourceCapabilities struct {
9396
DefaultSelectionSupported bool
9497
CountSelectionSupported bool
9598
}
9699

100+
// SampledBudgetCapabilities describes supported sampled workload budgets.
97101
type SampledBudgetCapabilities struct {
98102
CPUTimeSupported bool
99103
ResidentBytesSupported bool

0 commit comments

Comments
 (0)