Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/cli/DeepInfra.CLI/Commands/AccountApiGroupCommand.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public static Command Create()
command.Subcommands.Add(AccountAccountGpuPoolCommandApiCommand.Create());
command.Subcommands.Add(AccountAccountRateLimitCommandApiCommand.Create());
command.Subcommands.Add(AccountAccountUpdateDetailsCommandApiCommand.Create());
command.Subcommands.Add(AccountCancelGpuPoolRequestCommandApiCommand.Create());
command.Subcommands.Add(AccountDeleteAccountCommandApiCommand.Create());
command.Subcommands.Add(AccountGpuPoolGpuTypesCommandApiCommand.Create());
command.Subcommands.Add(AccountMeCommandApiCommand.Create());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#nullable enable
#pragma warning disable CS0618

using System.CommandLine;

namespace DeepInfra.CLI.Commands;

internal static partial class AccountCancelGpuPoolRequestCommandApiCommand
{
private static Argument<string> RequestId { get; } = new(
name: @"request-id")
{
Description = @"",
};

private static Option<string?> XiApiKey { get; } = new(
name: @"--xi-api-key")
{
Description = @"",
};

private static Option<string?> XApiKey { get; } = new(
name: @"--x-api-key")
{
Description = @"",
};

private static string FormatResponse(ParseResult parseResult, string value, global::System.Text.Json.Serialization.JsonSerializerContext context, bool truncateLongStrings)
{
string? text = null;
CustomizeResponseText(parseResult, value, ref text);
if (!string.IsNullOrWhiteSpace(text))
{
return text;
}

var hints = new Dictionary<string, CliFormatHint>(StringComparer.OrdinalIgnoreCase)
{
};
CustomizeResponseFormatHints(hints);
return CliRuntime.FormatHumanReadable(value, context, truncateLongStrings, hints);
}

static partial void CustomizeResponseText(ParseResult parseResult, string value, ref string? text);
static partial void CustomizeResponseFormatHints(Dictionary<string, CliFormatHint> hints);


public static Command Create()
{
var command = new Command(@"cancel-gpu-pool-request", @"Cancel Gpu Pool Request
Withdraw the caller's open request.");
command.Arguments.Add(RequestId);
command.Options.Add(XiApiKey);
command.Options.Add(XApiKey);


command.SetAction(async (ParseResult parseResult, CancellationToken cancellationToken) =>
await CliRuntime.RunAsync(async () =>
{
var requestId = parseResult.GetRequiredValue(RequestId);
var xiApiKey = parseResult.GetValue(XiApiKey);
var xApiKey = parseResult.GetValue(XApiKey);
using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false);


var response = await client.Account.CancelGpuPoolRequestAsync(
requestId: requestId,
xiApiKey: xiApiKey,
xApiKey: xApiKey,
cancellationToken: cancellationToken).ConfigureAwait(false);


await CliRuntime.WriteResponseAsync(
parseResult,
response,
global::DeepInfra.SourceGenerationContext.Default,
FormatResponse,
cancellationToken).ConfigureAwait(false);
}, cancellationToken).ConfigureAwait(false));
return command;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,26 @@ internal static partial class AccountRequestGpuPoolChangeCommandApiCommand
private static Option<string> Reason { get; } = new(
name: @"--reason")
{
Description = @"",
Description = @"Why you need the change. Shown to the reviewer.",
Required = true,
};

private static Option<global::System.Collections.Generic.Dictionary<string, int>?> RequestedMin { get; } = new(
name: @"--requested-min")
{
Description = @"",
Description = @"Guaranteed capacity.",
};

private static Option<global::System.Collections.Generic.Dictionary<string, int>?> RequestedMax { get; } = new(
name: @"--requested-max")
{
Description = @"",
Description = @"Desired max GPUs per type, e.g. {""H100-80GB"": 16}. REPLACES the contents of your pending request, so send every entry you still want changed.",
};

private static Option<string?> ExpectedRequestId { get; } = new(
name: @"--expected-request-id")
{
Description = @"Id of the pending request you are editing, from GET /v1/me/gpu_pool (pending_request.id), or null if you have none.",
};
private static Option<string?> Input { get; } = new(@"--input")
{
Expand All @@ -54,7 +60,7 @@ internal static partial class AccountRequestGpuPoolChangeCommandApiCommand
Hidden = true,
};

private static string FormatResponse(ParseResult parseResult, string value, global::System.Text.Json.Serialization.JsonSerializerContext context, bool truncateLongStrings)
private static string FormatResponse(ParseResult parseResult, global::DeepInfra.GpuPoolPendingRequestOut value, global::System.Text.Json.Serialization.JsonSerializerContext context, bool truncateLongStrings)
{
string? text = null;
CustomizeResponseText(parseResult, value, ref text);
Expand All @@ -70,18 +76,20 @@ private static string FormatResponse(ParseResult parseResult, string value, glob
return CliRuntime.FormatHumanReadable(value, context, truncateLongStrings, hints);
}

static partial void CustomizeResponseText(ParseResult parseResult, string value, ref string? text);
static partial void CustomizeResponseText(ParseResult parseResult, global::DeepInfra.GpuPoolPendingRequestOut value, ref string? text);
static partial void CustomizeResponseFormatHints(Dictionary<string, CliFormatHint> hints);


public static Command Create()
{
var command = new Command(@"request-gpu-pool-change", @"Request Gpu Pool Change");
var command = new Command(@"request-gpu-pool-change", @"Request Gpu Pool Change
File or amend the caller's single open GPU limit request.");
command.Options.Add(XiApiKey);
command.Options.Add(XApiKey);
command.Options.Add(Reason);
command.Options.Add(RequestedMin);
command.Options.Add(RequestedMax);
command.Options.Add(ExpectedRequestId);
command.Options.Add(Input);
command.Options.Add(RequestJson);
command.Options.Add(RequestFile);
Expand Down Expand Up @@ -112,6 +120,7 @@ await CliRuntime.RunAsync(async () =>
var reason = parseResult.GetRequiredValue(Reason);
var requestedMin = CliRuntime.WasSpecified(parseResult, RequestedMin) ? parseResult.GetValue(RequestedMin) : (__requestBase is { } __RequestedMinBaseValue ? __RequestedMinBaseValue.RequestedMin : default);
var requestedMax = CliRuntime.WasSpecified(parseResult, RequestedMax) ? parseResult.GetValue(RequestedMax) : (__requestBase is { } __RequestedMaxBaseValue ? __RequestedMaxBaseValue.RequestedMax : default);
var expectedRequestId = CliRuntime.WasSpecified(parseResult, ExpectedRequestId) ? parseResult.GetValue(ExpectedRequestId) : (__requestBase is { } __ExpectedRequestIdBaseValue ? __ExpectedRequestIdBaseValue.ExpectedRequestId : default);
using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false);


Expand All @@ -121,6 +130,7 @@ await CliRuntime.RunAsync(async () =>
reason: reason,
requestedMin: requestedMin,
requestedMax: requestedMax,
expectedRequestId: expectedRequestId,
cancellationToken: cancellationToken).ConfigureAwait(false);


Expand Down
Loading