| | | 1 | | using System.Text.Json; |
| | | 2 | | using Microsoft.Extensions.Logging; |
| | | 3 | | using Orchestrator.Infrastructure.Factories; |
| | | 4 | | using Orchestrator.Infrastructure.Langfuse; |
| | | 5 | | using Spectre.Console; |
| | | 6 | | using Spectre.Console.Cli; |
| | | 7 | | |
| | | 8 | | namespace Orchestrator.Commands.Observability.Experiments; |
| | | 9 | | |
| | | 10 | | public sealed class RunCommunityToDateCommand : AsyncCommand<RunCommunityToDateSettings> |
| | | 11 | | { |
| | | 12 | | private readonly IAnsiConsole _console; |
| | | 13 | | private readonly PreparedExperimentRunExecutor _executor; |
| | | 14 | | private readonly ILogger<RunCommunityToDateCommand> _logger; |
| | | 15 | | |
| | 1 | 16 | | public RunCommunityToDateCommand( |
| | 1 | 17 | | IAnsiConsole console, |
| | 1 | 18 | | IFirebaseServiceFactory firebaseServiceFactory, |
| | 1 | 19 | | IOpenAiServiceFactory openAiServiceFactory, |
| | 1 | 20 | | ILangfusePublicApiClient langfuseClient, |
| | 1 | 21 | | ILogger<RunCommunityToDateCommand> logger) |
| | | 22 | | { |
| | 1 | 23 | | _console = console; |
| | 1 | 24 | | _executor = new PreparedExperimentRunExecutor(firebaseServiceFactory, openAiServiceFactory, langfuseClient); |
| | 1 | 25 | | _logger = logger; |
| | 1 | 26 | | } |
| | | 27 | | |
| | | 28 | | protected override async Task<int> ExecuteAsync(CommandContext context, RunCommunityToDateSettings settings, Cancell |
| | | 29 | | { |
| | | 30 | | try |
| | | 31 | | { |
| | 1 | 32 | | var summary = await _executor.ExecuteCommunityToDateAsync( |
| | 1 | 33 | | new PreparedExperimentCommunityRunRequest( |
| | 1 | 34 | | settings.ManifestPath, |
| | 1 | 35 | | settings.RunFamilyName, |
| | 1 | 36 | | settings.RunDescription, |
| | 1 | 37 | | settings.DatasetName, |
| | 1 | 38 | | settings.ReplaceRuns, |
| | 1 | 39 | | settings.BatchSize, |
| | 1 | 40 | | settings.ParticipantLimit, |
| | 1 | 41 | | settings.GetParticipantIdFilter()), |
| | 1 | 42 | | cancellationToken); |
| | | 43 | | |
| | 1 | 44 | | _console.WriteLine(JsonSerializer.Serialize(summary, PreparedExperimentCommandSupport.JsonOptions)); |
| | 1 | 45 | | return 0; |
| | | 46 | | } |
| | 0 | 47 | | catch (Exception ex) |
| | | 48 | | { |
| | 0 | 49 | | _logger.LogError(ex, "Error executing run-community-to-date command"); |
| | 0 | 50 | | _console.MarkupLine($"[red]Error:[/] {Markup.Escape(ex.Message)}"); |
| | 0 | 51 | | return 1; |
| | | 52 | | } |
| | 1 | 53 | | } |
| | | 54 | | } |