| | | 1 | | using System.ComponentModel; |
| | | 2 | | using Spectre.Console; |
| | | 3 | | using Spectre.Console.Cli; |
| | | 4 | | |
| | | 5 | | namespace Orchestrator.Commands.Observability.PrepareRepeatedMatchSlice; |
| | | 6 | | |
| | | 7 | | public sealed class PrepareRepeatedMatchSliceSettings : CommandSettings |
| | | 8 | | { |
| | | 9 | | [CommandOption("--community-context")] |
| | | 10 | | [Description("Community context used to scope persisted historical match outcomes")] |
| | 1 | 11 | | public string CommunityContext { get; set; } = string.Empty; |
| | | 12 | | |
| | | 13 | | [CommandOption("--matchdays")] |
| | | 14 | | [Description("Optional comma-separated list of matchdays to sample from. Defaults to all Bundesliga matchdays.")] |
| | | 15 | | public string? Matchdays { get; set; } |
| | | 16 | | |
| | | 17 | | [CommandOption("--match-count")] |
| | | 18 | | [Description("Number of distinct fixtures to sample")] |
| | | 19 | | [DefaultValue(5)] |
| | 1 | 20 | | public int MatchCount { get; set; } = 5; |
| | | 21 | | |
| | | 22 | | [CommandOption("--repetitions")] |
| | | 23 | | [Description("Number of repeated predictions to materialize per selected fixture")] |
| | | 24 | | [DefaultValue(4)] |
| | 1 | 25 | | public int Repetitions { get; set; } = 4; |
| | | 26 | | |
| | | 27 | | [CommandOption("--sample-seed")] |
| | | 28 | | [Description("Optional deterministic seed for random fixture selection. Defaults to the current UTC date in yyyyMMdd |
| | | 29 | | public int? SampleSeed { get; set; } |
| | | 30 | | |
| | | 31 | | [CommandOption("--starts-after")] |
| | | 32 | | [Description("Optional match start cutoff in NodaTime invariant ZonedDateTime 'G' format. Only matches strictly afte |
| | | 33 | | public string? StartsAfter { get; set; } |
| | | 34 | | |
| | | 35 | | [CommandOption("--slice-key")] |
| | | 36 | | [Description("Optional slice key override. Defaults to random-<match-count>x<repetitions>-seed-<sample-seed>")] |
| | | 37 | | public string? SliceKey { get; set; } |
| | | 38 | | |
| | | 39 | | [CommandOption("--source-pool-key")] |
| | | 40 | | [Description("Optional source pool identifier used in dataset names and output paths. Defaults to all-matchdays")] |
| | | 41 | | public string? SourcePoolKey { get; set; } |
| | | 42 | | |
| | | 43 | | [CommandOption("--dataset-name")] |
| | | 44 | | [Description("Optional hosted dataset name override for the prepared repeated-match slice")] |
| | | 45 | | public string? DatasetName { get; set; } |
| | | 46 | | |
| | | 47 | | [CommandOption("--dataset-description")] |
| | | 48 | | [Description("Optional short note describing this repeated-match slice dataset")] |
| | | 49 | | public string? DatasetDescription { get; set; } |
| | | 50 | | |
| | | 51 | | [CommandOption("--output-directory")] |
| | | 52 | | [Description("Optional output directory override. Defaults to artifacts/langfuse-experiments/repeated-match-slices/< |
| | | 53 | | public string? OutputDirectory { get; set; } |
| | | 54 | | |
| | | 55 | | public override ValidationResult Validate() |
| | | 56 | | { |
| | 1 | 57 | | if (string.IsNullOrWhiteSpace(CommunityContext)) |
| | | 58 | | { |
| | 0 | 59 | | return ValidationResult.Error("--community-context is required"); |
| | | 60 | | } |
| | | 61 | | |
| | 1 | 62 | | if (MatchCount < 1) |
| | | 63 | | { |
| | 1 | 64 | | return ValidationResult.Error("--match-count must be at least 1"); |
| | | 65 | | } |
| | | 66 | | |
| | 1 | 67 | | if (Repetitions < 1) |
| | | 68 | | { |
| | 1 | 69 | | return ValidationResult.Error("--repetitions must be at least 1"); |
| | | 70 | | } |
| | | 71 | | |
| | 1 | 72 | | if (!string.IsNullOrWhiteSpace(StartsAfter)) |
| | | 73 | | { |
| | | 74 | | try |
| | | 75 | | { |
| | 0 | 76 | | _ = EvaluationTimeParser.Parse(StartsAfter); |
| | 0 | 77 | | } |
| | | 78 | | catch (ArgumentException ex) |
| | | 79 | | { |
| | 0 | 80 | | return ValidationResult.Error(ex.Message); |
| | | 81 | | } |
| | | 82 | | } |
| | | 83 | | |
| | 1 | 84 | | if (string.IsNullOrWhiteSpace(Matchdays)) |
| | | 85 | | { |
| | 0 | 86 | | return ValidationResult.Success(); |
| | | 87 | | } |
| | | 88 | | |
| | 1 | 89 | | var segments = Matchdays.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); |
| | 1 | 90 | | if (segments.Length == 0) |
| | | 91 | | { |
| | 0 | 92 | | return ValidationResult.Error("--matchdays must contain at least one matchday number when provided"); |
| | | 93 | | } |
| | | 94 | | |
| | 1 | 95 | | foreach (var segment in segments) |
| | | 96 | | { |
| | 1 | 97 | | if (!int.TryParse(segment, out var matchday) || matchday is < 1 or > 34) |
| | | 98 | | { |
| | 0 | 99 | | return ValidationResult.Error($"Invalid matchday '{segment}'. Expected an integer between 1 and 34."); |
| | | 100 | | } |
| | | 101 | | } |
| | | 102 | | |
| | 1 | 103 | | return ValidationResult.Success(); |
| | 0 | 104 | | } |
| | | 105 | | } |