Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into ralphe/refactor_azcli…
Browse files Browse the repository at this point in the history
…_to_interface
  • Loading branch information
ralph-msft committed Apr 1, 2024
2 parents ce4f9b7 + f0aac19 commit 2c0811a
Show file tree
Hide file tree
Showing 126 changed files with 1,777 additions and 1,781 deletions.
25 changes: 12 additions & 13 deletions .azure/pipelines/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pr:
- main

pool:
name: SkymanUbuntu2004Hosted
name: $(UbuntuPipelineName)

parameters:
- name: signNugetPackages
Expand Down Expand Up @@ -79,16 +79,15 @@ stages:
projects: 'src/ai/ai-cli.csproj'
arguments: '--configuration Release -p:CLIAssemblyVersion=$(AICLISemVerVersion) -p:CLIAssemblyInformationalVersion=$(AICLIVersion) -p:PackageVersion=$(AICLIVersion) -o "$(Build.ArtifactStagingDirectory)"'
- task: UseDotNet@2
displayName: 'Use .NET Core 2.1 (signing requirement)'
displayName: 'Use .NET Core 6.0 (signing requirement for EsrpCodeSigning@4)'
inputs:
packageType: 'sdk'
version: '2.1.x'
- ${{ if eq(parameters.signNugetPackages, true) }}:
- template: sign-nuget.yaml
parameters:
displayName: 'Sign AI CLI NuGet package'
folderPath: '$(Build.ArtifactStagingDirectory)'
pattern: '$(AICLINuPkgFileName)'
version: '6.0.x'
- template: sign-nuget.yaml
parameters:
displayName: 'Sign AI CLI NuGet package'
folderPath: '$(Build.ArtifactStagingDirectory)'
pattern: '$(AICLINuPkgFileName)'
- task: Bash@3
displayName: 'Create installation script'
inputs:
Expand Down Expand Up @@ -117,14 +116,14 @@ stages:
- task: AzureCLI@2
displayName: Upload NuGet package
inputs:
azureSubscription: 'Carbon Dropper (CSSpeechStorage Drop)'
azureSubscription: 'Carbon Dropper2 (CSSpeechStorage Drop)'
scriptType: 'bash'
arguments: '$(Build.ArtifactStagingDirectory)/$(AICLINuPkgFileName) private/ai/$(AICLINuPkgFileName)'
scriptPath: './.azure/pipelines/scripts/upload-file.sh'
- task: AzureCLI@2
displayName: Upload installation script
inputs:
azureSubscription: 'Carbon Dropper (CSSpeechStorage Drop)'
azureSubscription: 'Carbon Dropper2 (CSSpeechStorage Drop)'
scriptType: 'bash'
arguments: '$(Build.ArtifactStagingDirectory)/InstallAzureAICLIDeb-$(AICLIVersion).sh private/ai/InstallAzureAICLIDeb-$(AICLIVersion).sh'
scriptPath: './.azure/pipelines/scripts/upload-file.sh'
Expand Down Expand Up @@ -220,7 +219,7 @@ stages:
dependsOn: SetupStage
condition: and(succeeded(), or(eq(variables['IsRelease'], 'true'), eq(variables['PublishDevBuild'], 'true')))
pool:
name: SkymanWS2022Compliant
name: $(WindowsPipelineName)
jobs:
- job: BuildWindowsInstaller
variables:
Expand Down Expand Up @@ -270,7 +269,7 @@ stages:

- task: AzureCLI@2
inputs:
azureSubscription: 'Carbon Dropper (CSSpeechStorage Drop)'
azureSubscription: 'Carbon Dropper2 (CSSpeechStorage Drop)'
scriptType: 'bash'
arguments: '$(Build.ArtifactStagingDirectory)/Azure-AI-CLI-Setup-$(AICLIVersion)-x64.exe private/ai/Azure-AI-CLI-Setup-$(AICLIVersion)-x64.exe'
scriptPath: './.azure/pipelines/scripts/upload-file.sh'
Expand Down
2 changes: 1 addition & 1 deletion .azure/pipelines/sign-dll-exe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ parameters:
default: true

steps:
- task: EsrpCodeSigning@2
- task: EsrpCodeSigning@4
displayName: ${{ parameters.displayName }}
inputs:
ConnectedServiceName: 'Speech SDK ESRP Signing Alternate'
Expand Down
2 changes: 1 addition & 1 deletion .azure/pipelines/sign-nuget.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ parameters:
default: true

steps:
- task: EsrpCodeSigning@1
- task: EsrpCodeSigning@4
displayName: ${{ parameters.displayName }}
inputs:
ConnectedServiceName: 'Speech SDK ESRP Signing Alternate'
Expand Down
33 changes: 0 additions & 33 deletions .github/workflows/ado-sync.yaml

This file was deleted.

25 changes: 0 additions & 25 deletions .github/workflows/sync-to-ado.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions NuGet.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="CarbonSpx" value="https://msasg.pkgs.visualstudio.com/Skyman/_packaging/CarbonSpx/nuget/v3/index.json" />
<clear />
<add key="CarbonPre" value="https://pkgs.dev.azure.com/speedme/_packaging/CarbonPre/nuget/v3/index.json" />
</packageSources>
</configuration>
60 changes: 25 additions & 35 deletions src/ai/Program_AI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,49 +18,39 @@ public class AiProgram
{
static async Task<int> Main(string[] args)
{
IProgramData data = null;
bool isDebug = args.Length > 0 && args[0] == "debug";
if (isDebug) Console.WriteLine($"StopWatch: Started at {DateTime.Now}");

Stopwatch stopwatch = new Stopwatch();
int exitCode = int.MinValue;
stopwatch.Start();

try
{
bool isDebug = args.Length > 0 && args[0] == "debug";
if (isDebug)
{
Console.WriteLine($"StopWatch: Started at {DateTime.Now}");
}
var exitCode = TryCatchHelpers.TryCatchNoThrow(() => Program.Main(new AiProgramData(), args), -1, out var ex);

stopwatch.Start();
stopwatch.Stop();
var elapsed = stopwatch.Elapsed;
if (isDebug) Console.WriteLine($"StopWatch: Stopped at {DateTime.Now} ({GetStopWatchElapsedAsString(elapsed)})");

data = new AiProgramData();
exitCode = Program.Main(data, args);
stopwatch.Stop();
stopwatch.Restart();
await LogExitEventAsync(elapsed, exitCode);

if (isDebug)
{
Console.WriteLine($"StopWatch: Stopped at {DateTime.Now} ({GetStopWatchElapsedAsString(stopwatch.Elapsed)})");
}
stopwatch.Stop();
if (isDebug) Console.WriteLine($"StopWatch: Telemetry completed at {DateTime.Now} ({GetStopWatchElapsedAsString(stopwatch.Elapsed)})");

return exitCode;
}
catch (Exception)
{
exitCode = -1;
throw;
}
finally
if (ex != null) throw ex;
return exitCode;
}

static async Task LogExitEventAsync(TimeSpan elapsed, int exitCode)
{
if (Program.Telemetry != null)
{
if (data?.Telemetry != null)
Program.Telemetry.LogEvent(new ExitedTelemetryEvent()
{
data.Telemetry.LogEvent(new ExitedTelemetryEvent()
{
ExitCode = exitCode,
Elapsed = stopwatch.Elapsed
});

await data.Telemetry.DisposeAsync()
.ConfigureAwait(false);
}
ExitCode = exitCode,
Elapsed = elapsed
});

await Program.Telemetry.DisposeAsync();
}
}

Expand Down
21 changes: 10 additions & 11 deletions src/ai/commands/chat_command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ namespace Azure.AI.Details.Common.CLI
{
public class ChatCommand : Command
{
internal ChatCommand(ICommandValues values)
internal ChatCommand(ICommandValues values) : base(values)
{
_values = values.ReplaceValues();
_quiet = _values.GetOrDefault("x.quiet", false);
_verbose = _values.GetOrDefault("x.verbose", true);
}
Expand Down Expand Up @@ -1067,35 +1066,35 @@ private void StartCommand()
// _display = new DisplayHelper(_values);

// _output = new OutputHelper(_values);
// _output.StartOutput();
// _output!.StartOutput();

// var id = _values["chat.input.id"];
// _output.EnsureOutputAll("chat.input.id", id);
// _output.EnsureOutputEach("chat.input.id", id);
// _output!.EnsureOutputAll("chat.input.id", id);
// _output!.EnsureOutputEach("chat.input.id", id);

_lock = new SpinLock();
_lock.StartLock();
}

private void StopCommand()
{
_lock.StopLock(5000);
_lock!.StopLock(5000);

LogHelpers.EnsureStopLogFile(_values);
// _output.CheckOutput();
// _output.StopOutput();
// _output!.CheckOutput();
// _output!.StopOutput();

_stopEvent.Set();
}

private SpinLock _lock = null;
private SpinLock? _lock = null;
private readonly bool _quiet = false;
private readonly bool _verbose = false;

private AzureEventSourceListener _azureEventSourceListener;

// OutputHelper _output = null;
// DisplayHelper _display = null;
// OutputHelper? _output = null;
// DisplayHelper? _display = null;

#nullable enable
private int? TryParse(string? s, int? defaultValue)
Expand Down
13 changes: 6 additions & 7 deletions src/ai/commands/dev_command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ namespace Azure.AI.Details.Common.CLI
{
public class DevCommand : Command
{
internal DevCommand(ICommandValues values)
internal DevCommand(ICommandValues values) : base(values)
{
_values = values.ReplaceValues();
_quiet = _values.GetOrDefault("x.quiet", false);
_verbose = _values.GetOrDefault("x.verbose", false);
}
Expand Down Expand Up @@ -206,24 +205,24 @@ private void StartCommand()
// _display = new DisplayHelper(_values);

// _output = new OutputHelper(_values);
// _output.StartOutput();
// _output!.StartOutput();

_lock = new SpinLock();
_lock.StartLock();
}

private void StopCommand()
{
_lock.StopLock(5000);
_lock!.StopLock(5000);

// LogHelpers.EnsureStopLogFile(_values);
// _output.CheckOutput();
// _output.StopOutput();
// _output!.CheckOutput();
// _output!.StopOutput();

_stopEvent.Set();
}

private SpinLock _lock = null;
private SpinLock? _lock = null;
private readonly bool _quiet;
private readonly bool _verbose;
}
Expand Down
3 changes: 1 addition & 2 deletions src/ai/commands/eval_command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ namespace Azure.AI.Details.Common.CLI
{
public class EvalCommand : Command
{
internal EvalCommand(ICommandValues values)
internal EvalCommand(ICommandValues values) : base(values)
{
_values = values.ReplaceValues();
_quiet = _values.GetOrDefault("x.quiet", false);
_verbose = _values.GetOrDefault("x.verbose", true);
}
Expand Down
Loading

0 comments on commit 2c0811a

Please sign in to comment.