public static void RegisterServices()
        {
            BuildConfig();
            // register service provider
            // Dependencies.ServiceCollection.AddSingleton<IServiceProvider>();
            // register utilities
            Dependencies.ServiceCollection.AddTransient <ILogger, Logger>();
            Dependencies.ServiceCollection.AddSingleton <IConfiguration>(Dependencies.Configuration);
            // register CLI handlers
            Dependencies.ServiceCollection.AddSingleton <IBlobHandler, BlobHandler>();
            Dependencies.ServiceCollection.AddSingleton <IConfigureHandler, ConfigureHandler>();
            Dependencies.ServiceCollection.AddSingleton <ITestHandler, TestHandler>();
            Dependencies.ServiceCollection.AddSingleton <ICreateDatasetHandler, CreateDatasetHandler>();
            Dependencies.ServiceCollection.AddSingleton <IReadDatasetHandler, ReadDatasetHandler>();
            Dependencies.ServiceCollection.AddSingleton <IUpdateDatasetHandler, UpdateDatasetHandler>();
            Dependencies.ServiceCollection.AddSingleton <IDeleteDatasetHandler, DeleteDatasetHandler>();
            Dependencies.ServiceCollection.AddSingleton <IListDatasetHandler, ListDatasetHandler>();
            // register services
            Dependencies.ServiceCollection.AddSingleton <IDatasetService, FileSystemDatasetService>();
            Dependencies.ServiceCollection.AddTransient <IDatasetResolverService, DatasetResolverService>();
            Dependencies.ServiceCollection.AddTransient <IFileParserService, FileParserService>();
            Dependencies.ServiceCollection.AddTransient <ITestingService>(a => new TestingService(a));
            Dependencies.ServiceCollection.AddSingleton <ITestResultStore, MLFLowResultStore>();
            Dependencies.UseMLFlow();
            Dependencies.ServiceCollection.Configure <MLFlowConfiguration>
                (Dependencies.Configuration.GetSection("MLFlow"));
            // register testers
            Dependencies.ServiceCollection.AddTransient <ICustomVisionTester, CustomVisionTester>();
            // register targets
            Dependencies.ServiceCollection.AddSingleton <ITestTarget, CustomVisionTarget>();
            Dependencies.ServiceCollection.AddSingleton <IStorageService, AzureService>();
            Dependencies.ServiceCollection.AddTransient <ISingleClassImageDataset, SampleSingleClassObjectDetectionDataset>();

            Dependencies.Build();
        }
Example #2
0
        public void PreRunTest()
        {
            var parserInstance = new FormulaParser();
            var builder        = new ParserBuilder <FormulaToken, IFormula>();
            var parserResult   = builder.BuildParser(parserInstance, ParserType.EBNF_LL_RECURSIVE_DESCENT, "formulae");

            Assert.True(parserResult.IsOk);
            var source = @"

aaa = bbb + 1
bbb = ccc + 2
ccc = 3 + 3 


";
            var t      = parserResult.Result.Parse(source);

            Assert.True(t.IsOk);

            var  form       = t.Result as Formulae;
            var  depbuilder = new Dependencies();
            bool isCyclic   = depbuilder.Build(t.Result as Formulae);

            Assert.False(isCyclic);
            var checker = new TypeChecker();

            checker.Type(form, depbuilder.DependenciesDictionary);
        }
Example #3
0
        private static void Main(string[] args)
        {
            var parserInstance = new FormulaParser();
            var builder        = new ParserBuilder <FormulaToken, IFormula>();
            var parserResult   = builder.BuildParser(parserInstance, ParserType.EBNF_LL_RECURSIVE_DESCENT, "formulae");

            Console.WriteLine(parserResult.Result.Configuration.Dump());
            if (parserResult.IsOk)
            {
                var source = @"

ddd = aaa == 1 
aaa = bbb + 1
bbb = ccc + 2
ccc = 3 + 3 


";
                var fsm    = (parserResult.Result.Lexer as GenericLexer <FormulaToken>).FSMBuilder.Fsm;

                var grpah = fsm.ToGraphViz();

                var t = parserResult.Result.Parse(source);
                if (t.IsOk)
                {
                    var form       = t.Result as Formulae;
                    var depbuilder = new Dependencies();
                    depbuilder.Build(t.Result as Formulae);
                    depbuilder.Dump();
                    var checker = new TypeChecker();
                    checker.Type(form, depbuilder.DependenciesDictionary);

                    var formulaeEngine = new FormulaeEngine(depbuilder, form);
                    Console.WriteLine(formulaeEngine.ToString());
                    // Assert.Equal(6.0, formulaeEngine.GetValue("C"));
                    // Assert.Equal(8.0, formulaeEngine.GetValue("B"));
                    // Assert.Equal(9.0, formulaeEngine.GetValue("A"));
                    formulaeEngine.Set("C", 10.0);
                    // Assert.Equal(10.0, formulaeEngine.GetValue("C"));
                    // Assert.Equal(12.0, formulaeEngine.GetValue("B"));
                    // Assert.Equal(13.0, formulaeEngine.GetValue("A"));
                    Console.WriteLine(formulaeEngine.ToString());
                    ;
                }
                else
                {
                    t.Errors.ForEach(e => Console.WriteLine(e.ErrorMessage));
                }
            }
            else
            {
                parserResult.Errors.ForEach(e => Console.WriteLine(e.Level + " - " + e.Message));
                ;
            }
        }
Example #4
0
        public void SetupDependencies()
        {
            var builder = new ConfigurationBuilder()
                          .AddInMemoryCollection(configs);

            Dependencies.Configuration = builder.Build();

            Dependencies.ServiceCollection.AddSingleton <ILogger, TestLogger>();
            Dependencies.ServiceCollection.AddSingleton <IConfiguration>(Dependencies.Configuration);

            Dependencies.ServiceCollection.AddSingleton <ITestHandler, TestHandler>();

            // register services
            Dependencies.ServiceCollection.AddSingleton <ITestingService, TestingService>();

            Dependencies.Build();
        }
Example #5
0
        public void RunTest()
        {
            var parserInstance = new FormulaParser();
            var builder        = new ParserBuilder <FormulaToken, IFormula>();
            var parserResult   = builder.BuildParser(parserInstance, ParserType.EBNF_LL_RECURSIVE_DESCENT, "formulae");

            Assert.True(parserResult.IsOk);
            var source = @"

aaa = -1 * (bbb + 1)
bbb = ccc + 2
ccc = 3 + 3 


";
            var t      = parserResult.Result.Parse(source);

            Assert.True(t.IsOk);

            var  form       = t.Result as Formulae;
            var  depBuilder = new Dependencies();
            bool isCyclic   = depBuilder.Build(t.Result as Formulae);

            Assert.False(isCyclic);
            var checker = new TypeChecker();

            checker.Type(form, depBuilder.DependenciesDictionary);

            var formulaeEngine = new FormulaeEngine(depBuilder, form);

            Assert.Equal(6.0, formulaeEngine.GetValue("ccc"));
            Assert.Equal(8.0, formulaeEngine.GetValue("bbb"));
            Assert.Equal(-9.0, formulaeEngine.GetValue("aaa"));
            formulaeEngine.Set("ccc", 10.0);
            Assert.Equal(10.0, formulaeEngine.GetValue("ccc"));
            Assert.Equal(12.0, formulaeEngine.GetValue("bbb"));
            Assert.Equal(-13.0, formulaeEngine.GetValue("aaa"));
        }
Example #6
0
        public void SetupDependencies()
        {
            var builder = new ConfigurationBuilder()
                          .AddInMemoryCollection(configs);

            Dependencies.Configuration = builder.Build();

            Dependencies.ServiceCollection.AddSingleton <ILogger, TestLogger>();
            Dependencies.ServiceCollection.AddSingleton <IConfiguration>(Dependencies.Configuration);
            // all the dataset handlers
            Dependencies.ServiceCollection.AddSingleton <IListDatasetHandler, ListDatasetHandler>();
            Dependencies.ServiceCollection.AddSingleton <ICreateDatasetHandler, CreateDatasetHandler>();
            Dependencies.ServiceCollection.AddSingleton <IUpdateDatasetHandler, UpdateDatasetHandler>();
            Dependencies.ServiceCollection.AddSingleton <IReadDatasetHandler, ReadDatasetHandler>();
            Dependencies.ServiceCollection.AddSingleton <IDeleteDatasetHandler, DeleteDatasetHandler>();

            // register services
            Dependencies.ServiceCollection.AddSingleton <IFileParserService, FileParserService>(); // hm, this is used even in memory
            Dependencies.ServiceCollection.AddSingleton <IDatasetService, InMemoryDatasetService>();
            Dependencies.ServiceCollection.AddSingleton <IDatasetResolverService, DatasetResolverService>();

            Dependencies.Build();
        }
 public async Task GetAndSet_fileSystem()
 {
     Dependencies.ServiceCollection.AddSingleton <IDatasetService, FileSystemDatasetService>();
     Dependencies.Build();
     await AssertGetAndSet();
 }
 public async Task GetAndSet_inMemory()
 {
     Dependencies.ServiceCollection.AddSingleton <IDatasetService, InMemoryDatasetService>();
     Dependencies.Build();
     await AssertGetAndSet();
 }