Skip to content

Commit

Permalink
Fully refactored the analysis pipelne
Browse files Browse the repository at this point in the history
The AnalysisCoordinator now no longer makes assumptions about the
location of file segments, or that they are local, or that they are even
from the same file. Additionally, the AnalysisCoordinator is for the
first time fully unit tested!

Please note: multiple old IAnalyser analyses have been broken in this
patch. They should be ported to the newer EventRecognizer format when
time permits.

This patch also splits AnalysisSettings into two classes. Now values in
AnalysisSettings will always be invariant to the entire analysis. The
new SegmentSettings class contains values that change for each segment
analyzed.
  • Loading branch information
atruskie committed Aug 25, 2017
1 parent 6ddf105 commit e68b33a
Show file tree
Hide file tree
Showing 97 changed files with 2,570 additions and 3,493 deletions.
10 changes: 5 additions & 5 deletions Acoustics/Acoustics.Shared/Acoustics.Shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="CsvHelper, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8c4959082be5c823, processorArchitecture=MSIL">
<HintPath>..\..\AudioAnalysis\packages\CsvHelper.2.16.3.0\lib\net40\CsvHelper.dll</HintPath>
<HintPath>..\..\AudioAnalysis\packages\CsvHelper.2.16.2.0\lib\net40\CsvHelper.dll</HintPath>
</Reference>
<Reference Include="DotSpinners, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\AudioAnalysis\packages\DotSpinners.1.0.0-CI00002\lib\net40\DotSpinners.dll</HintPath>
<Reference Include="DotSpinners, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\AudioAnalysis\packages\DotSpinners.1.2.0\lib\net40\DotSpinners.dll</HintPath>
</Reference>
<Reference Include="envdte, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<SpecificVersion>False</SpecificVersion>
Expand Down Expand Up @@ -179,8 +179,8 @@
<HintPath>..\..\AudioAnalysis\packages\fasterflect.2.1.3\lib\net40\Fasterflect.dll</HintPath>
</Reference>
<Reference Include="FSharp.Core, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="JetBrains.Annotations, Version=10.4.0.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325, processorArchitecture=MSIL">
<HintPath>..\..\AudioAnalysis\packages\JetBrains.Annotations.10.4.0\lib\net\JetBrains.Annotations.dll</HintPath>
<Reference Include="JetBrains.Annotations, Version=11.0.0.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325, processorArchitecture=MSIL">
<HintPath>..\..\AudioAnalysis\packages\JetBrains.Annotations.11.0.0\lib\net20\JetBrains.Annotations.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\..\AudioAnalysis\packages\log4net.2.0.8\lib\net40-full\log4net.dll</HintPath>
Expand Down
1 change: 1 addition & 0 deletions Acoustics/Acoustics.Shared/Csv/Csv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public static CsvConfiguration DefaultConfiguration
var settings = new CsvConfiguration()
{
HasHeaderRecord = true,

};
foreach (var classMap in ClassMapsToRegister)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,5 +323,15 @@ public static DateTimeOffset Round(this DateTimeOffset date, TimeSpan roundingIn
return date.AddTicks(halfIntervalTicks - ((date.Ticks + halfIntervalTicks) % roundingInterval.Ticks));
}

public static TimeSpan Min(this TimeSpan t1, TimeSpan t2)
{
return t1 <= t2 ? t1 : t2;
}

public static TimeSpan Max(this TimeSpan t1, TimeSpan t2)
{
return t1 >= t2 ? t1 : t2;
}

}
}
21 changes: 21 additions & 0 deletions Acoustics/Acoustics.Shared/Extensions/FileInfoExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ public static void CreateParentDirectories(this FileInfo file)
}
}

public static DirectoryInfo Combine(this DirectoryInfo directoryInfo, IEnumerable<string> str)
{
Contract.Requires(directoryInfo != null);
Contract.Requires(str != null);

string merged = Path.Combine(str.Prepend(directoryInfo.FullName).ToArray());

return new DirectoryInfo(merged);
}

public static DirectoryInfo Combine(this DirectoryInfo directoryInfo, params string[] str)
{
Contract.Requires(directoryInfo != null);
Expand Down Expand Up @@ -135,6 +145,17 @@ public static bool TryCreate(this DirectoryInfo file)

return false;
}

public static FileInfo Touch(this FileInfo info)
{
using (File.OpenWrite(info.FullName))
{
}

info.Refresh();

return info;
}
}

public class FileInfoNameComparer : IComparer<FileInfo>, IEqualityComparer<FileInfo>
Expand Down
37 changes: 18 additions & 19 deletions Acoustics/Acoustics.Shared/Logging/Logging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,30 +122,29 @@ public static string Prompt(string prompt, bool forPassword = false, TimeSpan? t
if (IsInteractive)
{
WriteLine(prompt);

var t = TaskEx.Run(() =>
{
if (forPassword)
var d = new Func<string>(() =>
{
return ReadHiddenLine();
}

return Console.ReadLine();
});

var success = t.Wait(timeout ?? PromptTimeout);
if (!success)
if (forPassword)
{
return ReadHiddenLine();
}
var line = System.Console.ReadLine();
return line;
});
IAsyncResult result = d.BeginInvoke(null, null);
result.AsyncWaitHandle.WaitOne(timeout ?? PromptTimeout);
if (result.IsCompleted)
{
throw new TimeoutException($"Timed out waiting for user input to prompt: \"{prompt}\"");
var endInvoke = d.EndInvoke(result);
return endInvoke;
}

return t.Result;
}
else
{
Log.Warn("User prompt \"" + prompt + "\" suppressed because session is not interactive");
return null;
throw new TimeoutException($"Timed out waiting for user input to prompt: \"{prompt}\"");
}


Log.Warn("User prompt \"" + prompt + "\" suppressed because session is not interactive");
return null;
}

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions Acoustics/Acoustics.Shared/packages.config
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CsvHelper" version="2.16.3.0" targetFramework="net40" />
<package id="DotSpinners" version="1.0.0-CI00002" targetFramework="net40" />
<package id="CsvHelper" version="2.16.2.0" targetFramework="net40" />
<package id="DotSpinners" version="1.2.0" targetFramework="net40" />
<package id="fasterflect" version="2.1.3" targetFramework="net4" />
<package id="JetBrains.Annotations" version="10.4.0" targetFramework="net40" />
<package id="JetBrains.Annotations" version="11.0.0" targetFramework="net40" />
<package id="log4net" version="2.0.8" targetFramework="net40" />
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net40" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net40" />
Expand Down
3 changes: 2 additions & 1 deletion Acoustics/Acoustics.Shared/spinners.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ Matrix,70,|: :: :: :: ::,:| :: :: :: ::,:: |: :: :: ::,:: :| :: :: ::,:: :: |: :
Flippie,90,_,`,',´,`,^,´
Loading,120,L______,_O_____,__A____,___D___,____I__,_____N_,______G,LOADING,_______,LOADING,_______
Unspecified,50,¤¤¤,_¤¤,¤_¤,¤¤_,¤¤¤,¤_¤,_¤¤
Money,120,$,€,£
Money,120,$,€,£
Ball,70,o , o , o , o , o, o , o , o , o
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Acoustics.Test.AcousticWorkbench
{
using System;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;

[TestClass]
Expand All @@ -13,6 +14,9 @@ public class AuthenticationServiceTests
[TestMethod]
public void TestMethod1()
{
var task = TaskEx.Delay(1.5.Seconds());

task.Wait(60.Seconds());
}
}
}
Loading

0 comments on commit e68b33a

Please sign in to comment.