├── .gitignore ├── .nuget ├── NuGet.Config ├── NuGet.exe └── NuGet.targets ├── AzureDataLake ├── DecisionServiceDB │ ├── CB.usql │ ├── CB_E2E.usql │ ├── CCB.usql │ ├── CCB_E2E.usql │ ├── CCB_E2E_fast.usql │ ├── DanglingRewards.usql │ ├── DecisionServiceDB.usqldbproj │ ├── DecisionServiceExtractor.usql │ └── Statistics.usql ├── DecisionServiceExtractor.Test │ ├── CcbJsonParserTest.cs │ ├── DecisionServiceExtractor.Test.csproj │ ├── JsonParserTest.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── packages.config ├── DecisionServiceExtractor │ ├── CCBExtractor.cs │ ├── CbParser.cs │ ├── CcbParser.cs │ ├── ColumnInfo.cs │ ├── DecisionServiceExtractor.csproj │ ├── DecisionServiceExtractor.sln │ ├── FieldExpression.cs │ ├── HeaderOnly.cs │ ├── Helpers.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── SafeJsonReader.cs │ └── packages.config └── Scripts │ ├── ADF │ ├── CBStats.usql │ ├── CBStats.usql.cs │ ├── CCBStats.usql │ └── CCBStats.usql.cs │ ├── AggregateStatistics.usql │ ├── AggregateStatistics.usql.cs │ ├── DanglingRewardsAnalysis.usql │ ├── DanglingRewardsAnalysis.usql.cs │ ├── DanglingRewardsCCB.usql │ ├── DanglingRewardsCCB.usql.cs │ ├── Process.usql │ ├── Process.usql.cs │ ├── ProcessCCB.usql │ ├── ProcessCCB.usql.cs │ ├── Sample.usql │ ├── Sample.usql.cs │ └── Scripts.usqlproj ├── ContextExplorer ├── README.md ├── Simulated_Data_Generator │ ├── README.md │ ├── Simulated_Data_Generator.ipynb │ ├── config_data_generator.json │ └── vw_offline_utilities.py ├── config_context_explorer_example.json ├── context_explorer.py ├── report_template.html ├── run_context_explorer.py └── sample_output │ ├── Context_Explorer_NewTest_2020-02-13-2020-03-13_CallType_MediaType_NetworkType.html │ ├── ce_report_screenshot.PNG │ ├── log_all_contexts_NewTest_2020-02-13-2020-03-13_CallType_MediaType_NetworkType.xlsx │ └── pic │ ├── NewTest_1_1Audiowifi_2020-02-13-2020-03-13_CallType_MediaType_NetworkType.png │ ├── NewTest_1_1Audiowired_2020-02-13-2020-03-13_CallType_MediaType_NetworkType.png │ ├── NewTest_1_1Videowifi_2020-02-13-2020-03-13_CallType_MediaType_NetworkType.png │ ├── NewTest_1_1Videowired_2020-02-13-2020-03-13_CallType_MediaType_NetworkType.png │ ├── NewTest_All_2020-02-13-2020-03-13_CallType_MediaType_NetworkType.png │ ├── NewTest_GVCAudiowifi_2020-02-13-2020-03-13_CallType_MediaType_NetworkType.png │ ├── NewTest_GVCAudiowired_2020-02-13-2020-03-13_CallType_MediaType_NetworkType.png │ ├── NewTest_GVCVideowifi_2020-02-13-2020-03-13_CallType_MediaType_NetworkType.png │ └── NewTest_GVCVideowired_2020-02-13-2020-03-13_CallType_MediaType_NetworkType.png ├── Crawl ├── AzureMLTopic │ ├── AzureMLTopic.cs │ └── function.json ├── BlobCache.cs ├── BlobContent.cs ├── CacheItem.cs ├── CertificateUtil.cs ├── CognitiveService.cs ├── CognitiveServiceEmotion │ ├── CognitiveServiceEmotion.cs │ └── function.json ├── CognitiveServiceEntityLinking │ ├── CognitiveServiceEntityLinking.cs │ └── function.json ├── CognitiveServiceTextAnalytics │ ├── CognitiveServiceTextAnalytics.cs │ └── function.json ├── CognitiveServiceVision │ ├── CognitiveServiceVision.cs │ └── function.json ├── Constants.cs ├── Crawl.csproj ├── Crawl │ ├── Crawl.cs │ ├── HtmlExtractor.cs │ └── function.json ├── Data │ ├── CrawlRequest.cs │ ├── CrawlResponse.cs │ └── UrlHolder.cs ├── HttpCachedService.cs ├── KeyVaultHelper.cs ├── Properties │ └── AssemblyInfo.cs ├── RSS │ ├── RSS.cs │ └── function.json ├── RawStringConverter.cs ├── Services.cs ├── VideoIndexer │ ├── Breakdown │ │ ├── VideoBreakdown.cs │ │ ├── VideoBreakdownAudioEffects.cs │ │ ├── VideoBreakdownBreakdown.cs │ │ ├── VideoBreakdownContentModeration.cs │ │ ├── VideoBreakdownFace.cs │ │ ├── VideoBreakdownInsights.cs │ │ ├── VideoBreakdownSentiment.cs │ │ ├── VideoBreakdownSummarizedInsights.cs │ │ ├── VideoBreakdownTopic.cs │ │ ├── VideoBreakdownTranscriptBlock.cs │ │ └── VideoBreakdownTranscriptBlockLine.cs │ ├── Ooyala │ │ ├── JSON.cs │ │ ├── Ooyala.cs │ │ ├── OoyalaAPI.cs │ │ └── OoyalaVideo.cs │ ├── Search │ │ ├── VideoIndexerSearchResult.cs │ │ └── VideoIndexerSearchResultItem.cs │ ├── VideoIndexer.cs │ ├── VideoIndexerFeaturizer.cs │ └── function.json ├── Web.Debug.config ├── Web.Release.config ├── Web.config ├── host.json ├── packages.config └── readme.MD ├── DataScience ├── ActionSetVisualization.py ├── AzureUtil.py ├── DashboardMpi │ ├── dashboard_e2e.py │ └── helpers │ │ ├── command.py │ │ ├── constant.py │ │ ├── dashboard.py │ │ ├── environment.py │ │ ├── grid.py │ │ ├── input_provider.py │ │ ├── logger.py │ │ ├── pool.py │ │ ├── preprocessing.py │ │ ├── runtime.py │ │ ├── sweep.py │ │ └── vw.py ├── DataScience.py ├── DataScience.pyproj ├── DownloadBatchWorkFiles.py ├── Eval.py ├── Experimentation.py ├── ExperimentationAzure.py ├── FeatureImportance.py ├── Featurization.py ├── GenerateSampleData.py ├── InsertModelIdIntoTrackback.py ├── LogDownloader.py ├── RankRewardAnalyzer.py ├── Step1.py ├── Step2.py ├── ValidateSingleModel.py ├── common.py ├── dashboard.html ├── dashboard_readme.md ├── dashboard_utils.py ├── ds.config ├── ds_parse.py ├── index_data.py ├── list_vw_args.py ├── requirements.txt ├── summary.py └── vw_audit_pp.py ├── Experimentation ├── AzureBlobDownloader.cs ├── Experimentation.csproj ├── FileTransformBlock.cs ├── JsonTransform.cs ├── MetricResult.cs ├── Metrics.cs ├── OfflineTrainer.cs ├── Properties │ └── AssemblyInfo.cs ├── TupleList.cs ├── Util.cs ├── VowpalWabbitJsonToString.cs ├── VowpalWabbitStreamWriter.cs ├── app.config └── packages.config ├── ExperimentationConsole ├── App.config ├── ExperimentationConsole.csproj ├── Program.cs ├── Properties │ └── AssemblyInfo.cs └── packages.config ├── ExperimentationTest ├── ExperimentationTest.csproj ├── Properties │ └── AssemblyInfo.cs ├── TestContext.cs ├── WrapperTest.cs ├── app.config ├── packages.config └── vw.exe ├── HostedExamples ├── ClientLibraryExample │ ├── App.config │ ├── ApplicationInsights.config │ ├── ClientLibraryExample.csproj │ ├── ClientLibraryExample.sln │ ├── Context.cs │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── ULongEncoder.cs │ └── packages.config └── RESTExample │ ├── App.config │ ├── Context.cs │ ├── Example1.cs │ ├── Example2.cs │ ├── Program.cs │ ├── Properties │ └── AssemblyInfo.cs │ ├── RESTExample.csproj │ ├── RESTExample.sln │ └── packages.config ├── JavascriptClient ├── README.md ├── decision-service.js ├── package.json └── test │ └── test.js ├── LicenseForSourceCode.txt ├── LogCookig ├── LogCookig.vcxproj ├── LogCookig.vcxproj.filters ├── main.cpp └── packages.config ├── MWTDecisionServiceEULA-DoesNotApplyToSourceCode.pdf ├── README.md ├── SECURITY.md ├── client ├── ClientDecisionService │ ├── App.config │ ├── ApplicationInsights.config │ ├── AzureBlobBackgroundDownloader.cs │ ├── ClientDecisionService.Static.csproj │ ├── ClientDecisionService.csproj │ ├── ClientDecisionService.nuspec │ ├── DecisionService.UntilModelReady.cs │ ├── DecisionService.cs │ ├── DecisionServiceClient.cs │ ├── DecisionServiceConfiguration.cs │ ├── DecisionServiceConstants.cs │ ├── DecisionServiceHttpModule.cs │ ├── DecisionServiceLocal.cs │ ├── DecisionServiceStaticClient.cs │ ├── IDecisionServiceClient.cs │ ├── ILogger.cs │ ├── InMemoryLogger.cs │ ├── JoinServerType.cs │ ├── JoinServiceLogger.cs │ ├── ModelNotFoundException.cs │ ├── PerformanceCounters.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── app.config.transform │ ├── packages.config │ └── web.config.transform ├── ClientDecisionServiceSample │ ├── App.config │ ├── ClientDecisionServiceSample.csproj │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Sample.cs │ ├── SampleActionDependentFeature.cs │ ├── SampleHosted.cs │ └── packages.config ├── ClientDecisionServiceTest │ ├── ActionDependentFeaturesTest.cs │ ├── Authorization.cs │ ├── AzureStorageEmulatorManager.cs │ ├── AzureStorageHelper.cs │ ├── ClientDecisionServiceTest.Static.csproj │ ├── ClientDecisionServiceTest.csproj │ ├── Common.cs │ ├── ConfigTests.cs │ ├── DecisionServiceUploadTests.cs │ ├── DevelopmentModeTest.cs │ ├── EpsilonGreedySlateTest.cs │ ├── InitialFullExploration.cs │ ├── LocalModeTest.cs │ ├── MockCommandCenter.cs │ ├── MockCommandTestBase.cs │ ├── MockHttpServer.cs │ ├── MockJoinServer.cs │ ├── ModelUpdateTests.cs │ ├── ModularTests.cs │ ├── MultiRequestReferenceResolverTests.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── RawStringConverter.cs │ ├── StartStopAzureEmulator.cs │ ├── UploaderTest.cs │ ├── VWTest.cs │ ├── WebAPITest.cs │ ├── app.config │ └── packages.config ├── ClientDecisionServiceVowpalWabbit │ ├── ClientDecisionServiceVowpalWabbit.Static.csproj │ ├── ClientDecisionServiceVowpalWabbit.csproj │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── VWBaseContextMapper.cs │ ├── VWExplorer.cs │ ├── VWJson.cs │ ├── VWJsonExplorer.cs │ ├── VWPolicy.cs │ ├── VWRanker.cs │ ├── VWState.cs │ ├── app.config │ └── packages.config ├── ClientDecisionServiceWebStandalone │ ├── App.config │ ├── ApplicationInsights.config │ ├── ClientDecisionServiceWebStandalone.csproj │ ├── Configuration.cs │ ├── DecisionServiceController.cs │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Startup.cs │ ├── config.json │ └── packages.config ├── CreateLocalNuget.bat ├── Doxyfile ├── JoinServerUploader │ ├── .gitignore │ ├── App.config │ ├── BaseEventUploader.cs │ ├── BatchingConfiguration.cs │ ├── CachingReferenceResolver.cs │ ├── Constants.cs │ ├── DecisionServiceTransientErrorDetectionStrategy.cs │ ├── EventHandlers.cs │ ├── EventUploader.cs │ ├── EventUploaderAsa.cs │ ├── Events.cs │ ├── Extensions.cs │ ├── IEventUploader.cs │ ├── IHttpClient.cs │ ├── IHttpResponse.cs │ ├── InteractionJsonConverter.cs │ ├── JoinServerUploader.csproj │ ├── JoinServerUploader.nuspec │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── RawStringConverter.cs │ ├── StrictTypedEqualityComparer.cs │ ├── UploaderHttpClient.cs │ ├── UploaderHttpResponse.cs │ └── packages.config ├── MultiWorldTestingServiceContract │ ├── ApplicationBlobConstants.cs │ ├── ApplicationMetadataUtil.cs │ ├── ApplicationSettingConstants.cs │ ├── ApplicationTransferMetadata.cs │ ├── MultiWorldTestingServiceContract.csproj │ ├── MultiWorldTestingServiceContract.nuspec │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── ServiceConstants.cs │ └── packages.config ├── appveyor.yml ├── docgen.bat ├── explore │ ├── BaseExplorer.cs │ ├── BootstrapExplorer.cs │ ├── Decision.cs │ ├── EpsilonGreedyExplorer.cs │ ├── EpsilonGreedySlateExplorer.cs │ ├── Explore.csproj │ ├── Feature.cs │ ├── GenericExplorer.cs │ ├── GenericTopSlotExplorer.cs │ ├── InitialExplorer.cs │ ├── Interface.cs │ ├── MultiActionHelper.cs │ ├── MurMurHash3.cs │ ├── MwtExplorer.cs │ ├── PRG.cs │ ├── PermutationExplorer.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── SimpleContext.cs │ ├── SoftmaxExplorer.cs │ ├── StringRecorder.cs │ ├── TauFirstExplorer.cs │ ├── TopSlotExplorer.cs │ ├── UniformRandomExploration.cs │ └── packages.config └── version.props ├── forkify.ps1 ├── hosted.js ├── .vscode │ ├── launch.json │ └── tasks.json ├── README.md ├── Webpack.config.js ├── karma.conf.js ├── package.json ├── src │ ├── DecisionService.Interfaces.ts │ ├── DecisionService.ts │ ├── DecisionServiceClient.ts │ └── DecisionServiceRequestUtil.ts ├── test │ ├── DecisionServiceClientTest.ts │ ├── browser │ │ ├── test.canonial.js │ │ └── test.canonical.html │ └── test.html └── tsconfig.json ├── images ├── MWT-WhitePaper.pdf ├── StartDeployment.jpg ├── deploy-output.jpg ├── deploy-track-rg.jpg ├── deploy-track.jpg ├── deploybutton.png ├── directory.png ├── msa.png └── org.png ├── mc ├── App_Data │ ├── OnlineTrainerConfiguration.cscfg │ └── SASTokenGenerator.json ├── App_Start │ ├── BundleConfig.cs │ └── RouteConfig.cs ├── ApplicationInsights.config ├── Attributes │ └── NoCacheAttribute.cs ├── Classes │ ├── ApplicationMetadataStore.cs │ ├── ApplicationSettings.cs │ ├── DecisionServiceClientFactory.cs │ ├── EvalD3.cs │ ├── EvalResult.cs │ └── TimeoutWebClient.cs ├── Content │ ├── Demo.css │ ├── Site.css │ ├── bootstrap.css │ ├── bootstrap.min.css │ ├── img │ │ └── jsoneditor-icons.svg │ └── jsoneditor.min.css ├── Controllers │ ├── APIController.cs │ ├── APIUtil.cs │ ├── AutomationController.cs │ ├── DecisionServiceClientFactory.cs │ ├── DeploymentController.cs │ └── HomeController.cs ├── DecisionClient.ps1 ├── DecisionServicePrivateWeb.SetParameters.xml ├── DecisionServicePrivateWeb.SourceManifest.xml ├── DecisionServicePrivateWeb.csproj ├── DecisionServicePrivateWeb.csproj.user ├── DecisionServicePrivateWeb.deploy-readme.txt ├── DecisionServicePrivateWeb.deploy.cmd ├── DownloadAppSettings.ps1 ├── Global.asax ├── Global.asax.cs ├── GlobalSuppressions.cs ├── HelpText.Designer.cs ├── HelpText.resx ├── Models │ ├── EvaluationViewModel.cs │ ├── IndexViewModel.cs │ ├── SettingsSaveModel.cs │ ├── SettingsViewModel.cs │ └── SimulationViewModel.cs ├── Properties │ ├── AssemblyInfo.cs │ └── PublishProfiles │ │ ├── arm.pubxml │ │ ├── arm.pubxml.user │ │ └── mc-mcdel5spqfpsfzclank - Web Deploy.pubxml ├── Scripts │ ├── api-guide.js │ ├── api-simulator.js │ ├── api-test-drive.js │ ├── bootstrap.js │ ├── bootstrap.min.js │ ├── d3.js │ ├── d3.min.js │ ├── eval.js │ ├── jquery-1.10.2.intellisense.js │ ├── jquery-1.10.2.js │ ├── jquery-1.10.2.min.js │ ├── jquery-1.10.2.min.map │ ├── jsoneditor.map │ ├── jsoneditor.min.js │ ├── modernizr-2.6.2.js │ ├── moment-with-locales.js │ ├── moment-with-locales.min.js │ ├── moment.js │ ├── moment.min.js │ ├── nv.d3.js │ └── site.js ├── Validations │ └── UnitIntervalAttribute.cs ├── Views │ ├── Home │ │ ├── APIGuide.cshtml │ │ ├── APITest.cshtml │ │ ├── APITestDrive.cshtml │ │ ├── Evaluation.cshtml │ │ ├── Index.cshtml │ │ └── Settings.cshtml │ ├── Shared │ │ ├── _Layout.cshtml │ │ ├── _LoginPartial.cshtml │ │ ├── _OpenSvg.cshtml │ │ ├── _ResetSvg.cshtml │ │ └── _TestDriveLayout.cshtml │ ├── _ViewStart.cshtml │ └── web.config ├── Web.Debug.config ├── Web.Release.config ├── Web.config ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.svg │ ├── glyphicons-halflings-regular.ttf │ └── glyphicons-halflings-regular.woff ├── game.html ├── guide.html ├── index.html ├── packages.config └── playground.html ├── mwt-ds.sln └── provisioning ├── WebLoadTesting ├── DefaultLoadTest.loadtest ├── FloatFeaturesWebTest.cs ├── PolicyDecision.cs ├── ProbabilisticConditional.cs ├── Properties │ └── AssemblyInfo.cs ├── ResponseConditional.cs ├── TestDriveWebTest.cs ├── WebLoadTesting.csproj └── packages.config ├── azuredeploy.json ├── metadata.json ├── templates ├── AppInsightsTemplate.json ├── DeploymentFinished.json ├── EmptyTemplate.json ├── EventHubNamespaceTemplate.json ├── EventHubTemplate.json ├── OnlineTrainerEmptyTemplate.json ├── OnlineTrainerTemplate.json ├── PasswordGeneratorTemplate.json ├── SecureSettings.json ├── StorageTemplate.json ├── StreamAnalyticsEvalTemplate.json ├── StreamAnalyticsJoinTemplate.json ├── WebEmptyTemplate.json ├── WebManageTemplate.json ├── WebManageUpgradeTemplate.json └── WebSourceControlTemplate.json ├── test ├── APITestDriveTest.cs ├── DecisionServiceDeployment.cs ├── EndToEndOnlineTrainerTest.cs ├── Local.testsettings ├── Properties │ └── AssemblyInfo.cs ├── ProvisioningBaseTest.cs ├── ProvisioningTest.cs ├── ProvisioningUtil.cs ├── SimplePolicyHttpTest.cs ├── SimplePolicyTest.cs ├── app.config ├── ds-provisioning.csproj └── packages.config ├── upgrade.json └── validate.ps1 /.gitignore: -------------------------------------------------------------------------------- 1 | # This .gitignore is an agglomeration from several projects, so there might be duplicate entries. 2 | 3 | **/bin/Debug 4 | **/.vs/config 5 | **/obj/Debug 6 | **/test/packages 7 | **/x64/Debug 8 | *.suo 9 | *.user 10 | **/bin 11 | **/obj 12 | **/.vs 13 | **/packages 14 | 15 | # build folders 16 | **/x64 17 | **/obj 18 | **/Debug 19 | **/Release 20 | **/dll 21 | **/ipch 22 | **/packages 23 | **/bin 24 | **/__pycache__ 25 | 26 | # VS test results 27 | **/TestResults 28 | 29 | # VS files 30 | *.opensdf 31 | *.suo 32 | *.sdf 33 | *.user 34 | *.so 35 | *.nupkg 36 | 37 | # doxygen output folders 38 | html 39 | latex 40 | 41 | /AppSettingsSecrets.config 42 | -------------------------------------------------------------------------------- /.nuget/NuGet.Config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.nuget/NuGet.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/mwt-ds/86f552e7a592df6fb41e46e22f3473088660612e/.nuget/NuGet.exe -------------------------------------------------------------------------------- /AzureDataLake/DecisionServiceDB/CB_E2E.usql: -------------------------------------------------------------------------------- 1 | CREATE PROCEDURE IF NOT EXISTS [dbo].[CB_E2E](@_account string, @_appId string, @_model string, @_start DateTime, @_end DateTime, @_adlsPath string) 2 | AS 3 | BEGIN 4 | DECLARE @InputFile string = "wasb://" + @_appId + "@" + @_account + ".blob.core.windows.net/{model}/data/{date:yyyy}/{date:MM}/{date:dd}_{filename}.json"; 5 | 6 | DECLARE @OutputFolder string = @_adlsPath + @_appId + "/{model}/"; //your output folder 7 | DECLARE @OutputFileInteractions string = @OutputFolder + "interactions-{date:yyyy}-{date:MM}-{date:dd}.csv"; 8 | DECLARE @OutputFileDangling string = @OutputFolder + "dangling-{date:yyyy}-{date:MM}-{date:dd}.csv"; 9 | DECLARE @OutputFileStatistics string = @OutputFolder + "statistics-{date:yyyy}-{date:MM}-{date:dd}.csv"; 10 | 11 | (@Interactions, @Dangling) = ParseCB(@InputFile, @_model, @_start, @_end); 12 | 13 | @Statistics = 14 | CBStats 15 | ( 16 | @Interactions 17 | ); 18 | 19 | OUTPUT @Statistics 20 | TO @OutputFileStatistics 21 | USING Outputters.Csv(outputHeader:true); 22 | 23 | OUTPUT @Interactions 24 | TO @OutputFileInteractions 25 | USING Outputters.Csv(outputHeader:true); 26 | 27 | OUTPUT @Dangling 28 | TO @OutputFileDangling 29 | USING Outputters.Csv(outputHeader:true); 30 | END; 31 | -------------------------------------------------------------------------------- /AzureDataLake/DecisionServiceDB/CCB_E2E.usql: -------------------------------------------------------------------------------- 1 | CREATE PROCEDURE IF NOT EXISTS [dbo].[CCB_E2E](@_account string, @_appId string, @_model string, @_start DateTime, @_end DateTime, @_adlsPath string) 2 | AS 3 | BEGIN 4 | DECLARE @InputFile string = "wasb://" + @_appId + "@" + @_account + ".blob.core.windows.net/{model}/data/{date:yyyy}/{date:MM}/{date:dd}_{filename}.json"; 5 | 6 | DECLARE @OutputFolder string = @_adlsPath + @_appId + "/{model}/"; //your output folder 7 | DECLARE @OutputFileInteractions string = @OutputFolder + "interactions-{date:yyyy}-{date:MM}-{date:dd}.csv"; 8 | DECLARE @OutputFileDangling string = @OutputFolder + "dangling-{date:yyyy}-{date:MM}-{date:dd}.csv"; 9 | DECLARE @OutputFileStatistics string = @OutputFolder + "statistics-{date:yyyy}-{date:MM}-{date:dd}.csv"; 10 | 11 | (@Interactions, @Dangling) = ParseCCB(@InputFile, @_model, @_start, @_end); 12 | 13 | @Statistics = 14 | CCBStats 15 | ( 16 | @Interactions 17 | ); 18 | 19 | OUTPUT @Statistics 20 | TO @OutputFileStatistics 21 | USING Outputters.Csv(outputHeader:true); 22 | 23 | OUTPUT @Interactions 24 | TO @OutputFileInteractions 25 | USING Outputters.Csv(outputHeader:true); 26 | 27 | OUTPUT @Dangling 28 | TO @OutputFileDangling 29 | USING Outputters.Csv(outputHeader:true); 30 | END; 31 | -------------------------------------------------------------------------------- /AzureDataLake/DecisionServiceDB/CCB_E2E_fast.usql: -------------------------------------------------------------------------------- 1 | CREATE PROCEDURE IF NOT EXISTS [dbo].[CCB_E2E_fast](@_appId string, @_model string, @_start DateTime, @_end DateTime, @_adlsPath string) 2 | AS 3 | BEGIN 4 | DECLARE @Folder string = @_adlsPath + @_appId + "/{model}/"; //your folder 5 | DECLARE @InputFile string = @Folder + "interactions-{date:yyyy}-{date:MM}-{date:dd}.csv"; 6 | DECLARE @OutputFileStatistics string = @Folder + "statistics-{date:yyyy}-{date:MM}-{date:dd}.csv"; 7 | 8 | @Interactions = ExtractCCBDecisions(@InputFile, @_model, @_start, @_end); 9 | 10 | @Statistics = 11 | CCBStats 12 | ( 13 | @Interactions 14 | ); 15 | 16 | OUTPUT @Statistics 17 | TO @OutputFileStatistics 18 | USING Outputters.Csv(outputHeader:true); 19 | END; 20 | -------------------------------------------------------------------------------- /AzureDataLake/DecisionServiceDB/DanglingRewards.usql: -------------------------------------------------------------------------------- 1 | CREATE FUNCTION IF NOT EXISTS [dbo].ExtractDanglingRewards(@InputFile string, @_model string, @_start DateTime, @_end DateTime) 2 | RETURNS 3 | @DanglingRewards TABLE( 4 | EventId string, 5 | EnqueuedTimeUtc DateTime, 6 | RewardValue float?, 7 | model string, 8 | date DateTime) 9 | AS 10 | BEGIN 11 | @DanglingRewards = EXTRACT 12 | EventId string, 13 | EnqueuedTimeUtc DateTime, 14 | RewardValue float?, 15 | model string, 16 | date DateTime 17 | FROM @InputFile 18 | USING Extractors.Csv(skipFirstNRows:1); 19 | 20 | @DanglingRewards = SELECT EventId, 21 | EnqueuedTimeUtc.ToUniversalTime() AS EnqueuedTimeUtc, 22 | RewardValue, 23 | model, 24 | date 25 | FROM @DanglingRewards 26 | WHERE date >= @_start AND date < @_end AND model == @_model; 27 | RETURN; 28 | END; 29 | -------------------------------------------------------------------------------- /AzureDataLake/DecisionServiceDB/DecisionServiceExtractor.usql: -------------------------------------------------------------------------------- 1 | CREATE ASSEMBLY [DecisionServiceExtractor] 2 | FROM @_DeployTempDirectory + @"/DecisionServiceExtractor/DecisionServiceExtractor.dll" 3 | WITH ADDITIONAL FILES = ( 4 | @_DeployTempDirectory + @"/DecisionServiceExtractor/Newtonsoft.Json.dll" 5 | ); -------------------------------------------------------------------------------- /AzureDataLake/DecisionServiceExtractor.Test/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("DecisionServiceExtractor.Test")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("DecisionServiceExtractor.Test")] 13 | [assembly: AssemblyCopyright("Copyright © 2018")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("ff0e542a-681a-412d-877e-82d739e686e6")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /AzureDataLake/DecisionServiceExtractor.Test/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /AzureDataLake/DecisionServiceExtractor/CCBExtractor.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Analytics.Interfaces; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | 6 | namespace DecisionServiceExtractor 7 | { 8 | [SqlUserDefinedExtractor(AtomicFileProcessing = false)] 9 | public class CcbExtractor : IExtractor 10 | { 11 | public CcbExtractor() 12 | { 13 | } 14 | 15 | 16 | public override IEnumerable Extract(IUnstructuredReader input, IUpdatableRow output) 17 | { 18 | var parser = new CcbParser(output.Schema); 19 | foreach (Stream current in input.Split((byte)'\n')) 20 | { 21 | foreach (var row in parser.ParseEvent(output, current)) 22 | yield return row; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /AzureDataLake/DecisionServiceExtractor/ColumnInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Analytics.Interfaces; 3 | 4 | namespace DecisionServiceExtractor 5 | { 6 | internal class ColumnInfo 7 | { 8 | private int idx = -1; 9 | 10 | public int Idx => idx; 11 | 12 | public bool IsRequired => (idx >= 0); 13 | 14 | public ColumnInfo(ISchema schema, string name, Type type) 15 | { 16 | this.idx = schema.IndexOf(name); 17 | 18 | if (idx >= 0) 19 | { 20 | var column = schema[idx]; 21 | if (column.IsReadOnly || column.Type != type) 22 | { 23 | this.idx = -1; 24 | } 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /AzureDataLake/DecisionServiceExtractor/FieldExpression.cs: -------------------------------------------------------------------------------- 1 | namespace DecisionServiceExtractor 2 | { 3 | class FieldExpression 4 | { 5 | public string FieldName; 6 | 7 | public string JsonPath; 8 | 9 | public int Idx; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /AzureDataLake/DecisionServiceExtractor/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("DecisionServiceExtractor")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("DecisionServiceExtractor")] 13 | [assembly: AssemblyCopyright("Copyright © 2018")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("0e10be56-eb3d-4ec9-bf31-a1b9f649a9f2")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /AzureDataLake/DecisionServiceExtractor/SafeJsonReader.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System; 3 | 4 | namespace DecisionServiceExtractor 5 | { 6 | internal static class SafeJsonReader 7 | { 8 | public static bool Read(JsonTextReader reader, ref string errorMessage) 9 | { 10 | bool result = false; 11 | try 12 | { 13 | result = reader.Read(); 14 | } 15 | catch (Exception e) 16 | { 17 | errorMessage = e.Message; 18 | return false; 19 | } 20 | return result; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /AzureDataLake/DecisionServiceExtractor/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /AzureDataLake/Scripts/ADF/CBStats.usql: -------------------------------------------------------------------------------- 1 | SET @@FeaturePreviews = "DataPartitionedOutput:on"; 2 | 3 | USE DATABASE [DecisionServiceDB]; 4 | 5 | DECLARE @_appId string = ""; //your appId 6 | DECLARE @_account string = ""; // your account name 7 | DECLARE @_model string = ""; // your model 8 | 9 | DECLARE @_start DateTime = new DateTime(2020, 04, 28); //your inclusive start date 10 | DECLARE @_end DateTime = new DateTime(2020, 04, 29); //your non-inclusive end date 11 | 12 | DECLARE @_adlsPath = "/daily/"; 13 | 14 | DecisionServiceDB.dbo.CB_E2E(@_account, @_appId, @_model, @_start, @_end, @_adlsPath); -------------------------------------------------------------------------------- /AzureDataLake/Scripts/ADF/CBStats.usql.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Analytics.Interfaces; 2 | using Microsoft.Analytics.Types.Sql; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Text; 8 | 9 | namespace Scripts 10 | { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /AzureDataLake/Scripts/ADF/CCBStats.usql: -------------------------------------------------------------------------------- 1 | SET @@FeaturePreviews = "DataPartitionedOutput:on"; 2 | 3 | USE DATABASE [DecisionServiceDB]; 4 | 5 | DECLARE @_appId string = ""; //your appId 6 | DECLARE @_account string = ""; // your account name 7 | DECLARE @_model string = ""; 8 | 9 | DECLARE @_start DateTime = new DateTime(2020, 04, 28); //your inclusive start date 10 | DECLARE @_end DateTime = new DateTime(2020, 04, 29); //your non-inclusive end date 11 | 12 | DECLARE @_adlsPath = "/daily/"; 13 | 14 | DecisionServiceDB.dbo.CCB_E2E(@_account, @_appId, @_model, @_start, @_end, @_adlsPath); 15 | 16 | 17 | -------------------------------------------------------------------------------- /AzureDataLake/Scripts/ADF/CCBStats.usql.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Analytics.Interfaces; 2 | using Microsoft.Analytics.Types.Sql; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Text; 8 | 9 | namespace Scripts 10 | { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /AzureDataLake/Scripts/AggregateStatistics.usql.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Analytics.Interfaces; 2 | using Microsoft.Analytics.Types.Sql; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Text; 8 | 9 | namespace Scripts 10 | { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /AzureDataLake/Scripts/DanglingRewardsAnalysis.usql.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Analytics.Interfaces; 2 | using Microsoft.Analytics.Types.Sql; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Text; 8 | 9 | namespace Scripts 10 | { 11 | } 12 | -------------------------------------------------------------------------------- /AzureDataLake/Scripts/DanglingRewardsCCB.usql.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Analytics.Interfaces; 2 | using Microsoft.Analytics.Types.Sql; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Text; 8 | 9 | namespace Scripts 10 | { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /AzureDataLake/Scripts/Process.usql.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Analytics.Interfaces; 2 | using Microsoft.Analytics.Interfaces.Streaming; 3 | using Microsoft.Analytics.Types.Sql; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.IO; 7 | using System.Linq; 8 | using System.Text; 9 | 10 | namespace Scripts 11 | { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /AzureDataLake/Scripts/ProcessCCB.usql.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Analytics.Interfaces; 2 | using Microsoft.Analytics.Types.Sql; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Text; 8 | 9 | namespace Scripts 10 | { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /AzureDataLake/Scripts/Sample.usql: -------------------------------------------------------------------------------- 1 | SET @@FeaturePreviews = "DataPartitionedOutput:on"; 2 | 3 | DECLARE @_appId string = ""; //your appId 4 | DECLARE @_account string = ""; // your account name 5 | 6 | DECLARE @_start DateTime = new DateTime(2020, 02, 14); //your inclusive start date 7 | DECLARE @_end DateTime = new DateTime(2020, 02, 19); //your non-inclusive end date 8 | 9 | DECLARE @_sample float = 0.01f; 10 | 11 | DECLARE @OutputFolder string = "/daily/" + @_appId + "/sample/"; //your output folder 12 | 13 | DECLARE @InputFile string = "wasb://"+ @_appId +"@" + @_account + ".blob.core.windows.net/{model}/data/{date:yyyy}/{date:MM}/{date:dd}_{filename}.json"; 14 | 15 | DECLARE @OutputFileSample string = @OutputFolder + "{model}/{date:yyyy}-{date:MM}-{date:dd}.csv"; 16 | 17 | @Events = 18 | EXTRACT Line string, 19 | model string, //virtual column 20 | date DateTime, 21 | filename string //virtual column 22 | FROM @InputFile 23 | USING Extractors.Tsv(); 24 | 25 | @Events = SELECT Line, model, date FROM @Events WHERE date >= @_start AND date < @_end; 26 | 27 | @Events = SELECT * FROM @Events SAMPLE UNIFORM (@_sample); 28 | 29 | OUTPUT @Events 30 | TO @OutputFileSample 31 | USING Outputters.Text(quoting: false, outputHeader:false); 32 | -------------------------------------------------------------------------------- /AzureDataLake/Scripts/Sample.usql.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Analytics.Interfaces; 2 | using Microsoft.Analytics.Types.Sql; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Text; 8 | 9 | namespace Scripts 10 | { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /ContextExplorer/Simulated_Data_Generator/config_data_generator.json: -------------------------------------------------------------------------------- 1 | { 2 | "dataset_name": "Test", 3 | "output_folder": "E:\\data\\20190729_context_explorer\\simulated_data", 4 | "reward_range": [-1, 1], 5 | "reward_dense_range": [0, 0.3], 6 | "actions": [1, 2, 3, 4, 5, 6, 7, 8], 7 | "contexts": { 8 | "CallType": ["1_1", "GVC"], 9 | "MediaType": ["Audio", "Video"], 10 | "NetworkType": ["wifi", "wired"] 11 | }, 12 | "context_action_size": 1000, 13 | "p_value": 0.001, 14 | "increase_winning_margin": 0.02, 15 | "center": true, 16 | "random_state": 3, 17 | "model_parameters": { 18 | "batch_size_initial": 5000, 19 | "batch_size":5000, 20 | "iterations": 30, 21 | "default_action_index": 0, 22 | "add_control_group": false 23 | }, 24 | "vw_commands":{ 25 | "exploration_policy": "--epsilon 0.3", 26 | "cb_type": "ips", 27 | "interactions": "--interactions iFFF", 28 | "learning_rate": 0.001, 29 | "other_commands": "--power_t 0" 30 | } 31 | } -------------------------------------------------------------------------------- /ContextExplorer/config_context_explorer_example.json: -------------------------------------------------------------------------------- 1 | { 2 | "exps": { 3 | "NewTest": { 4 | "context_feature_namespace": ["Features"], 5 | "action_label_key": ["id"], 6 | "default_action_index": 0, 7 | "data_folder": "E:\\data\\20190729_context_explorer\\simulated_data\\logs" 8 | } 9 | }, 10 | "output_folder": "\\\\avdsp-share\\InputFiles\\p_learning\\Monitoring", 11 | "show_top_sensitive_contexts": 20, 12 | "min_daily_sample": 20, 13 | "reduce_numerics":{ 14 | "max_unique_numbers": 20, 15 | "n_buckets": 5 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /ContextExplorer/run_context_explorer.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from context_explorer import * 3 | 4 | def run_context_explorer(config_path): 5 | ce = ContextExplorer_DSJson(config_path) 6 | exp_data = ce.generate_report() 7 | 8 | if __name__ == "__main__": 9 | # Pass the path to the config file to run Context Explorer 10 | run_context_explorer(sys.argv[1]) 11 | -------------------------------------------------------------------------------- /ContextExplorer/sample_output/ce_report_screenshot.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/mwt-ds/86f552e7a592df6fb41e46e22f3473088660612e/ContextExplorer/sample_output/ce_report_screenshot.PNG -------------------------------------------------------------------------------- /ContextExplorer/sample_output/log_all_contexts_NewTest_2020-02-13-2020-03-13_CallType_MediaType_NetworkType.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/mwt-ds/86f552e7a592df6fb41e46e22f3473088660612e/ContextExplorer/sample_output/log_all_contexts_NewTest_2020-02-13-2020-03-13_CallType_MediaType_NetworkType.xlsx -------------------------------------------------------------------------------- /ContextExplorer/sample_output/pic/NewTest_1_1Audiowifi_2020-02-13-2020-03-13_CallType_MediaType_NetworkType.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/mwt-ds/86f552e7a592df6fb41e46e22f3473088660612e/ContextExplorer/sample_output/pic/NewTest_1_1Audiowifi_2020-02-13-2020-03-13_CallType_MediaType_NetworkType.png -------------------------------------------------------------------------------- /ContextExplorer/sample_output/pic/NewTest_1_1Audiowired_2020-02-13-2020-03-13_CallType_MediaType_NetworkType.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/mwt-ds/86f552e7a592df6fb41e46e22f3473088660612e/ContextExplorer/sample_output/pic/NewTest_1_1Audiowired_2020-02-13-2020-03-13_CallType_MediaType_NetworkType.png -------------------------------------------------------------------------------- /ContextExplorer/sample_output/pic/NewTest_1_1Videowifi_2020-02-13-2020-03-13_CallType_MediaType_NetworkType.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/mwt-ds/86f552e7a592df6fb41e46e22f3473088660612e/ContextExplorer/sample_output/pic/NewTest_1_1Videowifi_2020-02-13-2020-03-13_CallType_MediaType_NetworkType.png -------------------------------------------------------------------------------- /ContextExplorer/sample_output/pic/NewTest_1_1Videowired_2020-02-13-2020-03-13_CallType_MediaType_NetworkType.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/mwt-ds/86f552e7a592df6fb41e46e22f3473088660612e/ContextExplorer/sample_output/pic/NewTest_1_1Videowired_2020-02-13-2020-03-13_CallType_MediaType_NetworkType.png -------------------------------------------------------------------------------- /ContextExplorer/sample_output/pic/NewTest_All_2020-02-13-2020-03-13_CallType_MediaType_NetworkType.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/mwt-ds/86f552e7a592df6fb41e46e22f3473088660612e/ContextExplorer/sample_output/pic/NewTest_All_2020-02-13-2020-03-13_CallType_MediaType_NetworkType.png -------------------------------------------------------------------------------- /ContextExplorer/sample_output/pic/NewTest_GVCAudiowifi_2020-02-13-2020-03-13_CallType_MediaType_NetworkType.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/mwt-ds/86f552e7a592df6fb41e46e22f3473088660612e/ContextExplorer/sample_output/pic/NewTest_GVCAudiowifi_2020-02-13-2020-03-13_CallType_MediaType_NetworkType.png -------------------------------------------------------------------------------- /ContextExplorer/sample_output/pic/NewTest_GVCAudiowired_2020-02-13-2020-03-13_CallType_MediaType_NetworkType.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/mwt-ds/86f552e7a592df6fb41e46e22f3473088660612e/ContextExplorer/sample_output/pic/NewTest_GVCAudiowired_2020-02-13-2020-03-13_CallType_MediaType_NetworkType.png -------------------------------------------------------------------------------- /ContextExplorer/sample_output/pic/NewTest_GVCVideowifi_2020-02-13-2020-03-13_CallType_MediaType_NetworkType.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/mwt-ds/86f552e7a592df6fb41e46e22f3473088660612e/ContextExplorer/sample_output/pic/NewTest_GVCVideowifi_2020-02-13-2020-03-13_CallType_MediaType_NetworkType.png -------------------------------------------------------------------------------- /ContextExplorer/sample_output/pic/NewTest_GVCVideowired_2020-02-13-2020-03-13_CallType_MediaType_NetworkType.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/mwt-ds/86f552e7a592df6fb41e46e22f3473088660612e/ContextExplorer/sample_output/pic/NewTest_GVCVideowired_2020-02-13-2020-03-13_CallType_MediaType_NetworkType.png -------------------------------------------------------------------------------- /Crawl/AzureMLTopic/function.json: -------------------------------------------------------------------------------- 1 | { 2 | "scriptFile": "..\\bin\\Crawl.dll", 3 | "entryPoint": "Microsoft.DecisionService.Crawl.AzureMLTopic.Run", 4 | "bindings": [ 5 | { 6 | "authLevel": "function", 7 | "name": "req", 8 | "type": "httpTrigger", 9 | "direction": "in" 10 | }, 11 | { 12 | "name": "$return", 13 | "type": "http", 14 | "direction": "out" 15 | } 16 | ], 17 | "disabled": false 18 | } 19 | -------------------------------------------------------------------------------- /Crawl/BlobContent.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | using Newtonsoft.Json.Linq; 8 | using System; 9 | 10 | namespace Microsoft.DecisionService.Crawl 11 | { 12 | public sealed class BlobContent 13 | { 14 | public string Value { get; set; } 15 | 16 | public DateTime Expires { get; set; } 17 | 18 | public JObject Output { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Crawl/CacheItem.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | using Newtonsoft.Json; 8 | using System; 9 | 10 | namespace Microsoft.DecisionService.Crawl 11 | { 12 | public sealed class CacheItem 13 | { 14 | [JsonProperty("nextRefreshTimestamp")] 15 | public DateTime NextRefreshTimestamp { get; set; } 16 | 17 | [JsonProperty("input")] 18 | [JsonConverter(typeof(RawStringConverter))] 19 | public string Input { get; set; } 20 | 21 | [JsonProperty("output")] 22 | [JsonConverter(typeof(RawStringConverter))] 23 | public string Output { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Crawl/CertificateUtil.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Security.Cryptography.X509Certificates; 4 | 5 | namespace Microsoft.DecisionService.Crawl 6 | { 7 | public static class CertificateUtil 8 | { 9 | public static X509Certificate2 FindCertificateByThumbprint(StoreLocation storeLocation, string thumbprint) 10 | { 11 | X509Store store = new X509Store(StoreName.My, storeLocation); 12 | try 13 | { 14 | store.Open(OpenFlags.ReadOnly); 15 | X509Certificate2Collection col = store.Certificates.Find( 16 | X509FindType.FindByThumbprint, 17 | thumbprint, 18 | validOnly:false); // Don't validate certs as they're self-signed 19 | if (col == null || col.Count == 0) 20 | { 21 | var availableCertThumbprints = string.Join(",", store.Certificates.OfType().Select(c => c.Thumbprint)); 22 | throw new Exception($"Cannot find certificate in My\\{storeLocation} with thumbprint '{thumbprint}'. Available certs are {availableCertThumbprints}"); 23 | } 24 | return col[0]; 25 | } 26 | finally 27 | { 28 | store.Close(); 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Crawl/CognitiveService.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | using System; 8 | using System.Threading.Tasks; 9 | 10 | namespace Microsoft.DecisionService.Crawl 11 | { 12 | public class CognitiveService : HttpCachedService 13 | { 14 | private readonly string queryParams; 15 | 16 | public CognitiveService(string containerName, string queryParams = null, string apiKey = null) : base(containerName, apiKey) 17 | { 18 | this.queryParams = queryParams; 19 | } 20 | 21 | protected override void Initialize() 22 | { 23 | // TODO: need to re-create client (can't just update base address if the key changes...) 24 | //if (this.client.DefaultRequestHeaders.Contains("Ocp-Apim-Subscription-Key")) 25 | // this.client.DefaultRequestHeaders.Remove("Ocp-Apim-Subscription-Key"); 26 | 27 | this.client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", apiKey); 28 | 29 | if (!string.IsNullOrEmpty(queryParams)) 30 | this.client.BaseAddress = new Uri(this.client.BaseAddress.ToString() + queryParams); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Crawl/CognitiveServiceEmotion/function.json: -------------------------------------------------------------------------------- 1 | { 2 | "scriptFile": "..\\bin\\Crawl.dll", 3 | "entryPoint": " Microsoft.DecisionService.Crawl.CognitiveServiceEmotion.Run", 4 | "bindings": [ 5 | { 6 | "authLevel": "function", 7 | "name": "req", 8 | "type": "httpTrigger", 9 | "direction": "in" 10 | }, 11 | { 12 | "name": "$return", 13 | "type": "http", 14 | "direction": "out" 15 | } 16 | ], 17 | "disabled": false 18 | } -------------------------------------------------------------------------------- /Crawl/CognitiveServiceEntityLinking/function.json: -------------------------------------------------------------------------------- 1 | { 2 | "scriptFile": "..\\bin\\Crawl.dll", 3 | "entryPoint": "Microsoft.DecisionService.Crawl.CognitiveServiceEntityLinking.Run", 4 | "bindings": [ 5 | { 6 | "authLevel": "function", 7 | "name": "req", 8 | "type": "httpTrigger", 9 | "direction": "in" 10 | }, 11 | { 12 | "name": "$return", 13 | "type": "http", 14 | "direction": "out" 15 | } 16 | ], 17 | "disabled": false 18 | } 19 | -------------------------------------------------------------------------------- /Crawl/CognitiveServiceTextAnalytics/function.json: -------------------------------------------------------------------------------- 1 | { 2 | "scriptFile": "..\\bin\\Crawl.dll", 3 | "entryPoint": "Microsoft.DecisionService.Crawl.CognitiveServiceTextAnalytics.Run", 4 | "bindings": [ 5 | { 6 | "authLevel": "function", 7 | "name": "req", 8 | "type": "httpTrigger", 9 | "direction": "in" 10 | }, 11 | { 12 | "name": "$return", 13 | "type": "http", 14 | "direction": "out" 15 | } 16 | ], 17 | "disabled": false 18 | } 19 | -------------------------------------------------------------------------------- /Crawl/CognitiveServiceVision/function.json: -------------------------------------------------------------------------------- 1 | { 2 | "scriptFile": "..\\bin\\Crawl.dll", 3 | "entryPoint": "Microsoft.DecisionService.Crawl.CognitiveServiceVision.Run", 4 | "bindings": [ 5 | { 6 | "authLevel": "function", 7 | "name": "req", 8 | "type": "httpTrigger", 9 | "direction": "in" 10 | }, 11 | { 12 | "name": "$return", 13 | "type": "http", 14 | "direction": "out" 15 | } 16 | ], 17 | "disabled": false 18 | } 19 | -------------------------------------------------------------------------------- /Crawl/Constants.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | using Microsoft.WindowsAzure.Storage; 8 | using Microsoft.WindowsAzure.Storage.Blob; 9 | using Newtonsoft.Json; 10 | using System; 11 | using System.Text; 12 | using System.Threading; 13 | using System.Threading.Tasks; 14 | 15 | namespace Microsoft.DecisionService.Crawl 16 | { 17 | internal static class Constants 18 | { 19 | public const int MaxRequestSizeAnsi = 10240; 20 | public const int MaxRequestSizeUtf16 = MaxRequestSizeAnsi / 2; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Crawl/Crawl/function.json: -------------------------------------------------------------------------------- 1 | { 2 | "scriptFile": "..\\bin\\Crawl.dll", 3 | "entryPoint": "Microsoft.DecisionService.Crawl.Crawl.Run", 4 | "bindings": [ 5 | { 6 | "authLevel": "function", 7 | "name": "req", 8 | "type": "httpTrigger", 9 | "direction": "in" 10 | }, 11 | { 12 | "name": "$return", 13 | "type": "http", 14 | "direction": "out" 15 | } 16 | ], 17 | "disabled": false 18 | } 19 | -------------------------------------------------------------------------------- /Crawl/Data/CrawlRequest.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | using Newtonsoft.Json; 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Linq; 11 | using System.Web; 12 | 13 | namespace Microsoft.DecisionService.Crawl.Data 14 | { 15 | public class CrawlRequest 16 | { 17 | [JsonProperty("site")] 18 | public string Site { get; set; } 19 | 20 | [JsonProperty("id")] 21 | public string Id { get; set; } 22 | 23 | [JsonProperty("url")] 24 | public string Url { get; set; } 25 | 26 | [JsonProperty("etag")] 27 | public string ETag { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Crawl/Data/UrlHolder.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | using Newtonsoft.Json; 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Linq; 11 | using System.Web; 12 | 13 | namespace Microsoft.DecisionService.Crawl.Data 14 | { 15 | public class UrlHolder 16 | { 17 | [JsonProperty("url")] 18 | public string Url { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Crawl/KeyVaultHelper.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.IdentityModel.Clients.ActiveDirectory; 2 | using System; 3 | using System.Security.Cryptography.X509Certificates; 4 | using System.Threading.Tasks; 5 | 6 | namespace Microsoft.DecisionService.Crawl 7 | { 8 | /// 9 | /// see https://azure.microsoft.com/en-us/documentation/articles/key-vault-use-from-web-application/. 10 | /// 11 | public class KeyVaultHelper 12 | { 13 | private readonly ClientAssertionCertificate assertionCert; 14 | 15 | public KeyVaultHelper(StoreLocation storeLocation, string clientId, string thumbprint) 16 | { 17 | var clientAssertionCertPfx = CertificateUtil.FindCertificateByThumbprint(storeLocation, thumbprint); 18 | this.assertionCert = new ClientAssertionCertificate(clientId, clientAssertionCertPfx); 19 | } 20 | 21 | public async Task GetAccessToken(string authority, string resource, string scope) 22 | { 23 | var context = new AuthenticationContext(authority, TokenCache.DefaultShared); 24 | return (await context.AcquireTokenAsync(resource, assertionCert)).AccessToken; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Crawl/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Crawl")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Crawl")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("28285b58-63a5-48f9-99da-7498e0e3ab22")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /Crawl/RSS/function.json: -------------------------------------------------------------------------------- 1 | { 2 | "scriptFile": "..\\bin\\Crawl.dll", 3 | "entryPoint": "Microsoft.DecisionService.Crawl.RSS.Run", 4 | "bindings": [ 5 | { 6 | "authLevel": "function", 7 | "name": "req", 8 | "type": "httpTrigger", 9 | "direction": "in" 10 | }, 11 | { 12 | "name": "$return", 13 | "type": "http", 14 | "direction": "out" 15 | } 16 | ], 17 | "disabled": false 18 | } 19 | -------------------------------------------------------------------------------- /Crawl/VideoIndexer/Breakdown/VideoBreakdown.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | using Newtonsoft.Json; 8 | 9 | namespace Microsoft.DecisionService.Crawl 10 | { 11 | public class VideoBreakdownResult 12 | { 13 | [JsonProperty("state")] // processed 14 | public string State { get; set; } 15 | 16 | [JsonProperty("durationInSeconds")] 17 | public int DurationInSeconds { get; set; } 18 | 19 | [JsonProperty("breakdowns")] 20 | public VideoBreakdownResultBreakdown[] Breakdowns { get; set; } 21 | 22 | 23 | [JsonProperty("summarizedInsights")] 24 | public VideoBreakdownResultSummarizedInsights SummarizedInsights { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Crawl/VideoIndexer/Breakdown/VideoBreakdownAudioEffects.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | using Newtonsoft.Json; 8 | 9 | namespace Microsoft.DecisionService.Crawl 10 | { 11 | public class VideoBreakdownResultAudioEffects 12 | { 13 | [JsonProperty("audioEffectKey")] 14 | public string AudioEffectKey { get; set; } 15 | 16 | [JsonProperty("seenDuration")] 17 | public float SeenDuration { get; set; } 18 | 19 | [JsonProperty("seenDurationRatio")] 20 | public float SeenDurationRatio { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Crawl/VideoIndexer/Breakdown/VideoBreakdownBreakdown.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | using Newtonsoft.Json; 8 | 9 | namespace Microsoft.DecisionService.Crawl 10 | { 11 | public class VideoBreakdownResultBreakdown 12 | { 13 | [JsonProperty("externalId")] 14 | public string ExternalId { get; set; } 15 | 16 | [JsonProperty("insights")] 17 | public VideoBreakdownResultInsights Insight { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Crawl/VideoIndexer/Breakdown/VideoBreakdownContentModeration.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | using Newtonsoft.Json; 8 | 9 | namespace Microsoft.DecisionService.Crawl 10 | { 11 | public class VideoBreakdownResultContentModeration 12 | { 13 | [JsonProperty("adultClassifierValue")] 14 | public float AdultClassifierValue { get; set; } 15 | 16 | [JsonProperty("bannedWordsCount")] 17 | public int BannedWordsCount { get; set; } 18 | 19 | [JsonProperty("isSuspectedAsAdult")] 20 | public bool IsSuspectedAsAdult { get; set; } 21 | 22 | [JsonProperty("isAdult")] 23 | public bool IsAdult { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Crawl/VideoIndexer/Breakdown/VideoBreakdownFace.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | using Newtonsoft.Json; 8 | 9 | namespace Microsoft.DecisionService.Crawl 10 | { 11 | public class VideoBreakdownResultFace 12 | { 13 | [JsonProperty("name")] 14 | public string Name { get; set; } // // Unknown #1 15 | 16 | [JsonProperty("seenDuration")] 17 | public float SeenDuration { get; set; } 18 | 19 | [JsonProperty("seenDurationRatio")] 20 | public float SeenDurationRatio { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Crawl/VideoIndexer/Breakdown/VideoBreakdownInsights.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | using Newtonsoft.Json; 8 | 9 | namespace Microsoft.DecisionService.Crawl 10 | { 11 | public class VideoBreakdownResultInsights 12 | { 13 | [JsonProperty("contentModeration")] 14 | public VideoBreakdownResultContentModeration ContentModeration { get; set; } 15 | 16 | [JsonProperty("viewToken")] 17 | public string ViewToken { get; set; } 18 | 19 | [JsonProperty("language")] 20 | public string Language { get; set; } 21 | 22 | [JsonProperty("transcriptBlocks")] 23 | public VideoBreakdownResultTranscriptBlock[] TranscriptBlocks { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Crawl/VideoIndexer/Breakdown/VideoBreakdownSentiment.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | using Newtonsoft.Json; 8 | 9 | namespace Microsoft.DecisionService.Crawl 10 | { 11 | public class VideoBreakdownResultSentiment 12 | { 13 | [JsonProperty("sentimentKey")] 14 | public string SentimentKey { get; set; } 15 | 16 | [JsonProperty("seenDurationRatio")] 17 | public float SeenDurationRatio { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Crawl/VideoIndexer/Breakdown/VideoBreakdownSummarizedInsights.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | using Newtonsoft.Json; 8 | 9 | namespace Microsoft.DecisionService.Crawl 10 | { 11 | public class VideoBreakdownResultSummarizedInsights 12 | { 13 | [JsonProperty("faces")] 14 | public VideoBreakdownResultFace[] Faces { get; set; } 15 | 16 | [JsonProperty("topics")] 17 | public VideoBreakdownResultTopic[] Topics { get; set; } 18 | 19 | [JsonProperty("sentiments")] 20 | public VideoBreakdownResultSentiment[] Sentiments { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Crawl/VideoIndexer/Breakdown/VideoBreakdownTopic.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | using Newtonsoft.Json; 8 | 9 | namespace Microsoft.DecisionService.Crawl 10 | { 11 | public class VideoBreakdownResultTopic 12 | { 13 | [JsonProperty("name")] 14 | public string Name { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Crawl/VideoIndexer/Breakdown/VideoBreakdownTranscriptBlock.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | using Newtonsoft.Json; 8 | 9 | namespace Microsoft.DecisionService.Crawl 10 | { 11 | public class VideoBreakdownResultTranscriptBlock 12 | { 13 | [JsonProperty("lines")] 14 | public VideoBreakdownResultTranscriptBlockLine[] Lines { get; set; } 15 | 16 | [JsonProperty("sentiment")] 17 | public float Sentiment { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Crawl/VideoIndexer/Breakdown/VideoBreakdownTranscriptBlockLine.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | using Newtonsoft.Json; 8 | 9 | namespace Microsoft.DecisionService.Crawl 10 | { 11 | public class VideoBreakdownResultTranscriptBlockLine 12 | { 13 | [JsonProperty("text")] 14 | public string Text { get; set; } 15 | 16 | [JsonProperty("sentiment")] 17 | public float Confidence { get; set; } 18 | } 19 | } -------------------------------------------------------------------------------- /Crawl/VideoIndexer/Ooyala/OoyalaVideo.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Crawl.VideoIndexer.Ooyala 4 | { 5 | public class OoyalaVideo 6 | { 7 | public string Url { get; set; } 8 | 9 | public List Keywords { get; set; } 10 | 11 | public string Description { get; set; } 12 | 13 | public string Title { get; set; } 14 | } 15 | } -------------------------------------------------------------------------------- /Crawl/VideoIndexer/Search/VideoIndexerSearchResult.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | using Newtonsoft.Json; 8 | 9 | namespace Microsoft.DecisionService.Crawl 10 | { 11 | public class VideoIndexerSearchResult 12 | { 13 | [JsonProperty("results")] 14 | public VideoIndexerSearchResultItem[] Results { get; set; } 15 | } 16 | } -------------------------------------------------------------------------------- /Crawl/VideoIndexer/Search/VideoIndexerSearchResultItem.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | using Newtonsoft.Json; 8 | 9 | namespace Microsoft.DecisionService.Crawl 10 | { 11 | /// 12 | /// There are more fields here 13 | /// 14 | public class VideoIndexerSearchResultItem 15 | { 16 | [JsonProperty("id")] 17 | public string Id { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Crawl/VideoIndexer/function.json: -------------------------------------------------------------------------------- 1 | { 2 | "scriptFile": "..\\bin\\Crawl.dll", 3 | "entryPoint": "Microsoft.DecisionService.Crawl.VideoIndexer.Run", 4 | "bindings": [ 5 | { 6 | "authLevel": "function", 7 | "name": "req", 8 | "type": "httpTrigger", 9 | "direction": "in" 10 | }, 11 | { 12 | "name": "$return", 13 | "type": "http", 14 | "direction": "out" 15 | } 16 | ], 17 | "disabled": false 18 | } 19 | -------------------------------------------------------------------------------- /Crawl/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /Crawl/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /Crawl/host.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "ce294cb2fbbc45d7a3473d6160d08a7c" 3 | } -------------------------------------------------------------------------------- /Crawl/readme.MD: -------------------------------------------------------------------------------- 1 | Install Azure Function CLI tools 2 | 3 | 4 | npm install -g azure-functions-cli 5 | 6 | Run on command line from Crawl directory 7 | 8 | %AppData%\npm\func run . 9 | 10 | 11 | You can attach VS to func.exe. 12 | 13 | appsettings.json has the Configuration Manager settings. 14 | 15 | (Invoke-WebRequest -Method Post -Body $r.Content -ContentType 'application/json' 'http://localhost:7071/api/CognitiveServiceVision').Content 16 | 17 | 18 | curl -v -X POST http://localhost:7071/api/CognitiveServiceVision -H "Content-Type: application/json" -d @vision.json -H "Accept: application/json" -------------------------------------------------------------------------------- /DataScience/DashboardMpi/helpers/command.py: -------------------------------------------------------------------------------- 1 | import functools 2 | import itertools 3 | import json 4 | import re 5 | 6 | 7 | def serialize(opts): 8 | if not isinstance(opts, dict): 9 | raise Error('opts are not dict') 10 | return json.dumps(opts) 11 | 12 | 13 | def deserialize(s): 14 | candidate = json.loads(s) 15 | if not isinstance(candidate, dict): 16 | raise Error('candidate opts are not dict') 17 | return candidate 18 | 19 | 20 | def to_commandline(opts): 21 | command = 'vw' 22 | for key, val in opts.items(): 23 | command = ' '.join([ 24 | command, 25 | key if not key.startswith('#') else '', str(val) 26 | ]) 27 | return re.sub(' +', ' ', command) 28 | 29 | 30 | def generalize(c): 31 | c.pop('-f', None) 32 | c.pop('-i', None) 33 | c.pop('--cache_file', None) 34 | c.pop('-p', None) 35 | c.pop('-d', None) 36 | 37 | 38 | def apply(first, second): 39 | return dict(first, **second) 40 | 41 | 42 | def product(*dimensions): 43 | result = functools.reduce( 44 | lambda d1, d2: map( 45 | lambda tuple: apply(tuple[0], tuple[1]), 46 | itertools.product(d1, d2) 47 | ), dimensions) 48 | return list({to_commandline(c): c for c in result}.values()) 49 | 50 | 51 | def dimension(name, values): 52 | return list(map(lambda v: dict([(name, str(v))]), values)) 53 | 54 | 55 | if __name__ == '__main__': 56 | multiprocessing.freeze_support() 57 | -------------------------------------------------------------------------------- /DataScience/DashboardMpi/helpers/constant.py: -------------------------------------------------------------------------------- 1 | LOG_CHUNK_SIZE = 5 * 10 ** 10 2 | -------------------------------------------------------------------------------- /DataScience/DashboardMpi/helpers/dashboard.py: -------------------------------------------------------------------------------- 1 | import dashboard_utils 2 | 3 | def create(path, env, commands, enable_sweep, log_type): 4 | d = {} 5 | for log_path in env.local_logs_provider.list(): 6 | predictions = env.predictions_provider.list(log_path) 7 | d = dashboard_utils.create_stats(log_path, log_type, d, predictions, is_summary=True, report_progress=False) 8 | dashboard_utils.output_dashboard_data(d, path, commands) 9 | -------------------------------------------------------------------------------- /DataScience/DashboardMpi/helpers/environment.py: -------------------------------------------------------------------------------- 1 | import os 2 | from DashboardMpi.helpers import logger, runtime, pool 3 | from DashboardMpi.helpers.input_provider import CachesProvider, LocalLogsProvider, ModelsProvider, PredictionsProvider 4 | 5 | 6 | class Environment: 7 | def __init__(self, runtime_mode, procs, log_level, tmp_folder): 8 | rt = runtime.mpi() if runtime_mode == 'mpi' else runtime.local() 9 | 10 | self.runtime = rt 11 | self.job_pool = pool.multiproc_pool(procs) if procs > 1 else pool.seq_pool() 12 | self.logger = logger.console_logger(rt.get_node_id(), log_level) 13 | 14 | self.local_logs_provider = LocalLogsProvider( 15 | os.path.join(tmp_folder, 'logs') 16 | ) 17 | self.caches_provider = CachesProvider( 18 | os.path.join(tmp_folder, 'caches') 19 | ) 20 | self.models_provider = ModelsProvider( 21 | os.path.join(tmp_folder, 'models') 22 | ) 23 | self.predictions_provider = PredictionsProvider( 24 | os.path.join(tmp_folder, 'predictions') 25 | ) 26 | -------------------------------------------------------------------------------- /DataScience/DashboardMpi/helpers/grid.py: -------------------------------------------------------------------------------- 1 | from DashboardMpi.helpers import command 2 | from DashboardMpi.helpers.command import dimension, product 3 | 4 | 5 | class configuration: 6 | def __init__(self, name, promote=1, output=1): 7 | self.name = name 8 | self.promote = promote 9 | self.output = output 10 | 11 | 12 | class grid: 13 | def __init__(self, points, config): 14 | self.points = points 15 | self.config = config 16 | 17 | 18 | def generate(interactions_grid, marginals_grid): 19 | hyper_points = product( 20 | dimension('--power_t', [0]), # fixing power_t to 0 since this is what should be used online 21 | # TODO: known bug in vw, --l1 is not working properly with --save_resume. Should uncomment this once it's fixed 22 | # dimension('--l1', [1e-09, 1e-07, 1e-05, 0.001, 0.1]), 23 | dimension('-l', [1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2, 1e-1, 0.5, 1, 10]), 24 | dimension('--cb_type', ['ips', 'mtr']), 25 | marginals_grid[:2] 26 | ) 27 | 28 | return [ 29 | grid(hyper_points, configuration(name='hyper1', output=1, promote=1)), 30 | grid(interactions_grid, configuration(name='interactions', output=1, promote=1)), 31 | grid(hyper_points, configuration(name='hyper2', output=1, promote=1)) 32 | ] 33 | 34 | 35 | if __name__ == '__main__': 36 | multiprocessing.freeze_support() 37 | -------------------------------------------------------------------------------- /DataScience/DashboardMpi/helpers/logger.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import time 3 | 4 | 5 | # def console_logger(node_id, level='INFO'): 6 | # logger = logging.getLogger('dashboard_logger') 7 | # stream_handler = logging.StreamHandler(sys.stdout) 8 | # formatter = logging.Formatter('[%(node_id)s][%(asctime)s]: %(message)s') 9 | # stream_handler.setFormatter(formatter) 10 | # logger.setLevel(logging.getLevelName(level)) 11 | # logger.addHandler(stream_handler) 12 | # extra = {'node_id': str(node_id)} 13 | # return logging.LoggerAdapter(logger, extra) 14 | 15 | # workaround for logger pickling 16 | 17 | class console_logger: 18 | def __init__(self, node_id, level='INFO'): 19 | self.node_id = node_id 20 | self.level = logging.getLevelName(level) 21 | 22 | def debug(self, message): 23 | if self.level <= logging.DEBUG: self._trace(message) 24 | 25 | def info(self, message): 26 | if self.level <= logging.INFO: self._trace(message) 27 | 28 | def warning(self, message): 29 | if self.level <= logging.WARNING: self._trace(message) 30 | 31 | def error(self, message): 32 | if self.level <= logging.ERROR: self._trace(message) 33 | 34 | def critical(self, message): 35 | if self.level <= logging.CRITICAL: self._trace(message) 36 | 37 | def _trace(self, message): 38 | prefix = '[' + str(self.node_id) + '][' + time.strftime("%d-%m-%Y %H:%M:%S", time.localtime(time.time())) + ']' 39 | print(prefix + message) 40 | -------------------------------------------------------------------------------- /DataScience/DashboardMpi/helpers/pool.py: -------------------------------------------------------------------------------- 1 | import multiprocessing 2 | 3 | 4 | class seq_pool: 5 | def map(self, task, inputs): 6 | result = [] 7 | for i in inputs: 8 | result.append(task(i)) 9 | return result 10 | 11 | 12 | class multiproc_pool: 13 | def __init__(self, procs): 14 | self.procs = procs 15 | 16 | def map(self, task, inputs): 17 | p = multiprocessing.Pool(self.procs) 18 | result = p.imap_unordered(task, inputs) 19 | p.close() 20 | p.join() 21 | return result 22 | -------------------------------------------------------------------------------- /DataScience/DashboardMpi/helpers/runtime.py: -------------------------------------------------------------------------------- 1 | try: 2 | from mpi4py import MPI 3 | except Exception as e: 4 | print(e) 5 | print('MPI mode is not supported') 6 | 7 | 8 | class local: 9 | def map(self, elements): 10 | return elements 11 | 12 | def reduce(self, elements): 13 | return elements 14 | 15 | def is_master(self): 16 | return True 17 | 18 | def get_node_id(self): 19 | return 0 20 | 21 | 22 | class mpi: 23 | def map(self, elements): 24 | result = [] 25 | i = self.get_node_id() 26 | step = MPI.COMM_WORLD.Get_size() 27 | while i < len(elements): 28 | result.append(elements[i]) 29 | i = i + step 30 | return result 31 | 32 | def reduce(self, elements): 33 | return MPI.COMM_WORLD.allreduce(elements, MPI.SUM) 34 | 35 | def is_master(self): 36 | return MPI.COMM_WORLD.Get_rank() == 0 37 | 38 | def get_node_id(self): 39 | return MPI.COMM_WORLD.Get_rank() 40 | -------------------------------------------------------------------------------- /DataScience/DownloadBatchWorkFiles.py: -------------------------------------------------------------------------------- 1 | from AzureUtil import AzureUtil 2 | import argparse 3 | import os, sys 4 | 5 | if __name__ == '__main__': 6 | parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter) 7 | parser.add_argument('--system_conn_string', help="storage account connection string where source/output files are stored", required=True) 8 | parser.add_argument('--system_files_container', help="storage account container where source files are stored", required=True) 9 | parser.add_argument('--local_working_dir', help="local dir where source files are stored", required=True) 10 | main_args = parser.parse_args(sys.argv[1:]) 11 | if not os.path.exists(main_args.local_working_dir): 12 | os.makedirs(main_args.local_working_dir) 13 | azure_util = AzureUtil(main_args.system_conn_string) 14 | azure_util.download_all_blobs(main_args.system_files_container, main_args.local_working_dir) -------------------------------------------------------------------------------- /DataScience/Featurization.py: -------------------------------------------------------------------------------- 1 | import json, sys 2 | 3 | # Identify namespaces and detect marginal features 4 | if len(sys.argv) < 3: 5 | print("Usage: python experimenter.py {source_data_unmodified} {dest_data_featurized}. Where source_data_unmodified is the Decision Service data you want to featurize and \ 6 | dest_data_featurized is the name of the featurized data file you are creating.") 7 | sys.exit() 8 | 9 | source_file_name = sys.argv[1] 10 | dest_file_name = sys.argv[2] 11 | 12 | readerFile = open(source_file_name,"r") 13 | writerFile = open(dest_file_name,"w") 14 | 15 | counter = 0 16 | 17 | print("Starting featurization") 18 | 19 | for event in readerFile: 20 | if counter % 500000 == 0: 21 | print("counter: " + str(counter)) 22 | 23 | # Parse event 24 | parsedEvent = json.loads(event) 25 | 26 | if "_tag" in event: 27 | continue 28 | 29 | # Featurize shared context 30 | # Sample: Separate device type and age group into different namespaces 31 | parsedEvent["Device"] = {"deviceType" : parsedEvent["UserFeatures"]["deviceType"]} 32 | parsedEvent["User"] = {"ageGroup" : parsedEvent["UserFeatures"]["ageGroup"]} 33 | 34 | del parsedEvent["UserFeatures"] 35 | 36 | # Featurize actions 37 | actionList = parsedEvent["_multi"] 38 | 39 | for action in actionList: 40 | # Change "id" feature into the format required for marginal features 41 | action["VideoId"] = {"constant": 1, "id": action["Video"]["id"]} 42 | del action["Video"] 43 | 44 | writerFile.write(json.dumps(parsedEvent) + "\n") 45 | 46 | counter += 1 47 | 48 | print("Done") -------------------------------------------------------------------------------- /DataScience/InsertModelIdIntoTrackback.py: -------------------------------------------------------------------------------- 1 | import os 2 | import os.path 3 | from vowpalwabbit import pyvw 4 | import configparser 5 | 6 | def line_prepender(filename, line): 7 | with open(filename, 'r+') as f: 8 | content = f.read() 9 | f.seek(0, 0) 10 | f.write(line.rstrip('\r\n') + '\n' + content) 11 | 12 | config = configparser.ConfigParser() 13 | config.read('ds.config') 14 | ds = config['DecisionService'] 15 | cache_folder = ds['CacheFolder'] 16 | 17 | for root, subdirs, files in os.walk(os.path.join(cache_folder, 'onlinetrainer')): 18 | print('looking at folder {0}'.format(root)) 19 | model = None 20 | trackback = None 21 | for file in files: 22 | if file == 'model': 23 | model = os.path.join(root, file) 24 | continue 25 | if file == 'model.trackback': 26 | trackback = os.path.join(root, file) 27 | continue 28 | 29 | if model is None or trackback is None: 30 | continue 31 | 32 | print('looking at folder {0}'.format(root)) 33 | 34 | with open(trackback, 'r') as f: 35 | first_line = f.readline() 36 | if (first_line.startswith('modelid:')): 37 | continue 38 | 39 | vw = pyvw.vw("--quiet -i {0}".format(model)) 40 | id = vw.get_id() 41 | del vw 42 | 43 | line_prepender(trackback, 'modelid: {0}\n'.format(id)) 44 | -------------------------------------------------------------------------------- /DataScience/Step1.py: -------------------------------------------------------------------------------- 1 | import ntpath 2 | import os 3 | import os.path 4 | import sys 5 | import configparser 6 | from azure.storage.blob import BlockBlobService 7 | import re 8 | import itertools 9 | import time 10 | import sys 11 | import common 12 | 13 | if __name__ == '__main__': 14 | 15 | start_time = time.time() 16 | 17 | # Parse start and end dates for getting data 18 | if len(sys.argv) < 3: 19 | print("Start and end dates are expected. Example: python datascience.py 20161122 20161130") 20 | 21 | data_set = common.DataSet.fromstrings(sys.argv[1], sys.argv[2]) 22 | 23 | data_set.download_events() 24 | data_set.build_model_history() 25 | 26 | data_set.create_files() 27 | -------------------------------------------------------------------------------- /DataScience/ds.config: -------------------------------------------------------------------------------- 1 | [DecisionService] 2 | ManagementCenterURL: https://your-management-center-url.azurewebsites.net 3 | WebServiceToken: WebServiceToken 4 | CacheFolder: . 5 | JoinedExamplesContainer: joined-examples 6 | ExperimentalUnitDurationDays: 1 7 | 8 | [AzureStorageAuthentication] 9 | $Default: connectionString1 10 | appId1: connectionString2 11 | appId2: connectionString2 12 | appId3: connectionString3 13 | -------------------------------------------------------------------------------- /DataScience/list_vw_args.py: -------------------------------------------------------------------------------- 1 | import ntpath 2 | import os 3 | import os.path 4 | import sys 5 | from vowpalwabbit import pyvw 6 | 7 | if len(sys.argv) < 1: 8 | print("Folder expected. Example: python list_vw_args.py ") 9 | 10 | for root, subdirs, files in os.walk(sys.argv[1]): 11 | for file in files: 12 | if file == 'model': 13 | model = os.path.join(root, file) 14 | vw = pyvw.vw("--quiet -i {0}".format(model)) 15 | print(vw.get_arguments()) 16 | del vw -------------------------------------------------------------------------------- /DataScience/requirements.txt: -------------------------------------------------------------------------------- 1 | applicationinsights==0.11.9 2 | psutil==5.6.3 3 | azure.storage.blob==1.3.0 4 | numpy==1.17.0 5 | pandas==0.24.2 -------------------------------------------------------------------------------- /Experimentation/MetricResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Experimentation 8 | { 9 | public class MetricResult 10 | { 11 | public string Name { get; set; } 12 | 13 | public float Value { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Experimentation/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Experimentation")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Experimentation")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("c55c3b83-2745-474a-a3bd-8903771a2bee")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Experimentation/TupleList.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Experimentation 5 | { 6 | public class TupleList : List> 7 | { 8 | public void Add(T1 item, T2 item2) 9 | { 10 | Add(new Tuple(item, item2)); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Experimentation/VowpalWabbitStreamWriter.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Text; 3 | using VW; 4 | using VW.Serializer; 5 | 6 | namespace Experimentation 7 | { 8 | public class VowpalWabbitStreamWriter : StreamWriter 9 | { 10 | private VowpalWabbit vw; 11 | 12 | public VowpalWabbitStreamWriter(Stream stream, Encoding encoding, string arguments) : base(stream, encoding) 13 | { 14 | vw = new VowpalWabbit(new VowpalWabbitSettings { Arguments = arguments, EnableStringExampleGeneration = true, EnableStringFloatCompact = true }); 15 | } 16 | 17 | public override void WriteLine(string value) 18 | { 19 | using (var jsonSerializer = new VowpalWabbitJsonSerializer(vw)) 20 | using (var example = jsonSerializer.ParseAndCreate(value)) 21 | { 22 | if (example == null) 23 | throw new InvalidDataException($"Invalid example: {value}"); 24 | 25 | var str = example.VowpalWabbitString; 26 | if (example is VowpalWabbitMultiLineExampleCollection) 27 | str += "\n"; 28 | 29 | base.WriteLine(str); 30 | } 31 | } 32 | 33 | public override void Close() 34 | { 35 | vw.Dispose(); 36 | base.Close(); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Experimentation/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /ExperimentationConsole/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ExperimentationConsole")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ExperimentationConsole")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("e5e1575d-cfc5-4c1b-a252-c25f484e1955")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /ExperimentationConsole/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /ExperimentationTest/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ExperimentationTest")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ExperimentationTest")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("44979f3f-0ce2-4add-86d9-d8f9853683a5")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /ExperimentationTest/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /ExperimentationTest/vw.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/mwt-ds/86f552e7a592df6fb41e46e22f3473088660612e/ExperimentationTest/vw.exe -------------------------------------------------------------------------------- /HostedExamples/ClientLibraryExample/ClientLibraryExample.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27004.2009 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClientLibraryExample", "ClientLibraryExample.csproj", "{918527DE-8B65-4050-9A99-8288BE6BC78B}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Release|x64 = Release|x64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {918527DE-8B65-4050-9A99-8288BE6BC78B}.Debug|x64.ActiveCfg = Debug|x64 15 | {918527DE-8B65-4050-9A99-8288BE6BC78B}.Debug|x64.Build.0 = Debug|x64 16 | {918527DE-8B65-4050-9A99-8288BE6BC78B}.Release|x64.ActiveCfg = Release|x64 17 | {918527DE-8B65-4050-9A99-8288BE6BC78B}.Release|x64.Build.0 = Release|x64 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | EnterpriseLibraryConfigurationToolBinariesPathV6 = packages\EnterpriseLibrary.TransientFaultHandling.6.0.1304.0\lib\portable-net45+win+wp8 24 | SolutionGuid = {F6BA0AD8-CC1A-4290-BEA5-14DAB7D7D762} 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /HostedExamples/ClientLibraryExample/Context.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | using Newtonsoft.Json; 8 | 9 | namespace Microsoft.CustomDecisionService.ClientLibraryExample 10 | { 11 | public class DecisionContext 12 | { 13 | /// 14 | /// From SharedContext (REST) 15 | /// 16 | public DemographicNamespace Demographics { get; set; } 17 | 18 | /// 19 | /// From SharedContext (REST) 20 | /// 21 | public LocationNamespace Location { get; set; } 22 | 23 | /// 24 | /// The action array must be annotated as _multi property. 25 | /// 26 | [JsonProperty("_multi")] 27 | public ActionDependentFeatures[] Actions { get; set; } 28 | } 29 | 30 | public class DemographicNamespace 31 | { 32 | public string Gender { get; set; } 33 | } 34 | 35 | public class LocationNamespace 36 | { 37 | public string Country { get; set; } 38 | 39 | public string City { get; set; } 40 | } 41 | 42 | public class ActionDependentFeatures 43 | { 44 | public TopicNamespace Topic { get; set; } 45 | } 46 | 47 | public class TopicNamespace 48 | { 49 | public string Category { get; set; } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /HostedExamples/ClientLibraryExample/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ClientLibraryExample")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ClientLibraryExample")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("918527de-8b65-4050-9a99-8288be6bc78b")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /HostedExamples/RESTExample/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /HostedExamples/RESTExample/Context.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | namespace Microsoft.CustomDecisionService.RESTExample 8 | { 9 | public class SharedContext 10 | { 11 | public DemographicNamespace Demographics { get; set; } 12 | 13 | public LocationNamespace Location { get; set; } 14 | } 15 | 16 | public class DemographicNamespace 17 | { 18 | public string Gender { get; set; } 19 | } 20 | 21 | public class LocationNamespace 22 | { 23 | public string Country { get; set; } 24 | 25 | public string City { get; set; } 26 | } 27 | 28 | public class ActionDependentFeatures 29 | { 30 | public TopicNamespace Topic { get; set; } 31 | } 32 | 33 | public class TopicNamespace 34 | { 35 | public string Category { get; set; } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /HostedExamples/RESTExample/Program.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | using Microsoft.DecisionService.Client; 8 | using Microsoft.DecisionService.Client.Models; 9 | using System.Collections.Generic; 10 | 11 | namespace Microsoft.CustomDecisionService.RESTExample 12 | { 13 | class Program 14 | { 15 | static void Main(string[] args) 16 | { 17 | Example1.Run(); 18 | // Example2.Run(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /HostedExamples/RESTExample/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("RESTExample")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("RESTExample")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("60adaa0e-d4cb-4a62-885b-73228dd50493")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /HostedExamples/RESTExample/RESTExample.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27004.2009 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RESTExample", "RESTExample.csproj", "{60ADAA0E-D4CB-4A62-885B-73228DD50493}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {60ADAA0E-D4CB-4A62-885B-73228DD50493}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {60ADAA0E-D4CB-4A62-885B-73228DD50493}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {60ADAA0E-D4CB-4A62-885B-73228DD50493}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {60ADAA0E-D4CB-4A62-885B-73228DD50493}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {80D4369D-CAEE-4D0B-B1DB-C7ACB5993335} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /HostedExamples/RESTExample/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /JavascriptClient/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/mwt-ds/86f552e7a592df6fb41e46e22f3473088660612e/JavascriptClient/README.md -------------------------------------------------------------------------------- /JavascriptClient/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "decision-service", 3 | "version": "0.0.1", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git@gitlab.complexmedianetwork.com:researchdevelopment/ds-api-url-builder.git" 12 | }, 13 | "author": "", 14 | "license": "ISC", 15 | "dependencies": { 16 | "mocha": "^3.2.0" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LicenseForSourceCode.txt: -------------------------------------------------------------------------------- 1 | Copyright © Microsoft Corp 2012-2014, Yahoo! Inc. 2007-2016, and many 2 | individual contributors. 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source form, with or without modification, 7 | is permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, 10 | this list of conditions and the following disclaimer. 11 | 12 | * Neither the name of the Microsoft Corp nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /LogCookig/LogCookig.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Source Files 23 | 24 | 25 | -------------------------------------------------------------------------------- /LogCookig/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /MWTDecisionServiceEULA-DoesNotApplyToSourceCode.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/mwt-ds/86f552e7a592df6fb41e46e22f3473088660612e/MWTDecisionServiceEULA-DoesNotApplyToSourceCode.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Client Build Status](https://vowpalwabbit.visualstudio.com/_apis/public/build/definitions/926d5bad-e0be-4f52-9550-12f94358bae9/6/badge)](https://vowpalwabbit.visualstudio.com/Vowpal%20Wabbit/_build?_a=completed&definitionId=6) 2 | [![Join the chat at https://gitter.im/Microsoft/mwt-ds](https://badges.gitter.im/Microsoft/mwt-ds.svg)](https://gitter.im/Microsoft/mwt-ds?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 3 | [![NuGet version (Multiworld.Testing)](https://img.shields.io/nuget/v/Microsoft.Research.MultiWorldTesting.ClientLibrary.svg?style=flat-square)](https://www.nuget.org/packages/Microsoft.Research.MultiWorldTesting.ClientLibrary/) 4 | 5 | Umbrella repository for projects related to the [MWT Decision Service](https://aka.ms/mwt). 6 | 7 | The [documentation is in the wiki, including Tutorials, Troubleshooting Guide, White Papers, HOWTOs, FAQ List, API References, etc.](https://github.com/Microsoft/mwt-ds/wiki/). 8 | 9 | View our deployment notice. 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /client/ClientDecisionService/ApplicationInsights.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /client/ClientDecisionService/DecisionService.UntilModelReady.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Research.MultiWorldTesting.ExploreLibrary; 2 | using System.ComponentModel; 3 | 4 | namespace Microsoft.Research.MultiWorldTesting.ClientLibrary 5 | { 6 | [EditorBrowsable(EditorBrowsableState.Never)] 7 | public static class DecisionService_UntilModelReady 8 | { 9 | public static DecisionServiceClient 10 | ExploitUntilModelReady 11 | (this DecisionServiceClient that, IContextMapper initialPolicy) 12 | { 13 | that.InitialPolicy = initialPolicy; 14 | return that; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /client/ClientDecisionService/DecisionServiceConstants.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Microsoft.Research.MultiWorldTesting.ClientLibrary 4 | { 5 | public static class DecisionServiceConstants 6 | { 7 | // TODO: needed to run eventuploader stand alone... 8 | public static readonly string RedirectionBlobLocation = "http://decisionservicestorage.blob.core.windows.net/app-locations/{0}"; 9 | internal static readonly TimeSpan PollDelay = TimeSpan.FromSeconds(5); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /client/ClientDecisionService/DecisionServiceHttpModule.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.Diagnostics; 3 | using System.Web; 4 | 5 | namespace Microsoft.Research.MultiWorldTesting.ClientLibrary 6 | { 7 | [EditorBrowsable(EditorBrowsableState.Never)] // Hide this from VS code browsing 8 | class DecisionServiceHttpModule : IHttpModule 9 | { 10 | public void Init(HttpApplication context) 11 | { 12 | /* do nothing */ 13 | Trace.TraceInformation("Decision Service Cache detected Init event."); 14 | } 15 | 16 | public void Dispose() 17 | { 18 | DecisionServiceStaticClient.EvictAll(); 19 | Trace.TraceInformation("Decision Service Cache detected Dispose event."); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /client/ClientDecisionService/IDecisionServiceClient.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Research.MultiWorldTesting.ExploreLibrary; 2 | using System; 3 | using System.IO; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | 7 | namespace Microsoft.Research.MultiWorldTesting.ClientLibrary 8 | { 9 | public interface IDecisionServiceClient : IDisposable 10 | { 11 | Task DownloadModelAndUpdate(CancellationToken cancellationToken); 12 | 13 | Task ChooseRankingAsync(string uniqueKey, TContext context, IRanker defaultRanker); 14 | 15 | Task ChooseRankingAsync(string uniqueKey, TContext context, IRanker defaultRanker, bool doNotLog); 16 | 17 | Task ChooseRankingAsync(string uniqueKey, TContext context, int[] defaultActions); 18 | 19 | Task ChooseRankingAsync(string uniqueKey, TContext context, int[] defaultActions, bool doNotLog); 20 | 21 | Task ChooseRankingAsync(string uniqueKey, TContext context); 22 | 23 | Task ChooseRankingAsync(string uniqueKey, TContext context, bool doNotLog); 24 | 25 | void ReportReward(float reward, string uniqueKey); 26 | 27 | void ReportOutcome(object outcome, string uniqueKey); 28 | 29 | void UpdateModel(Stream model); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /client/ClientDecisionService/ILogger.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.Research.MultiWorldTesting.ClientLibrary 2 | { 3 | using MultiWorldTesting.ExploreLibrary; 4 | 5 | public interface ILogger 6 | { 7 | void ReportReward(string uniqueKey, float reward); 8 | 9 | void ReportOutcome(string uniqueKey, object outcome); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /client/ClientDecisionService/JoinServerType.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.Research.MultiWorldTesting.ClientLibrary 2 | { 3 | /// 4 | /// Collection of different Join Server implementation types. 5 | /// 6 | public enum JoinServerType 7 | { 8 | /// 9 | /// Azure Stream Analytics implementation. 10 | /// 11 | AzureStreamAnalytics = 0, 12 | 13 | /// 14 | /// Custom Azure implementation. 15 | /// 16 | CustomSolution 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /client/ClientDecisionService/ModelNotFoundException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Microsoft.Research.MultiWorldTesting.ClientLibrary 4 | { 5 | /// 6 | /// When a model cannot be found. 7 | /// 8 | public class ModelNotFoundException : Exception 9 | { 10 | /// 11 | /// Creates a new instance. 12 | /// 13 | public ModelNotFoundException(string message) : base(message) { } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /client/ClientDecisionService/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | [assembly: System.Reflection.AssemblyTitle("Microsoft.Research.MultiWorldTesting.ClientLibrary")] 12 | [assembly: System.Reflection.AssemblyCompany("Microsoft Corp")] 13 | [assembly: System.Reflection.AssemblyProduct("Microsoft.Research.MultiWorldTesting.ClientLibrary")] 14 | [assembly: System.Reflection.AssemblyCopyright("Copyright (C) Microsoft Corp 2014-2016")] 15 | [assembly: System.Runtime.InteropServices.ComVisible(false)] 16 | [assembly: System.CLSCompliant(false)] 17 | [assembly: System.Runtime.InteropServices.Guid("a991c863-165c-4fd5-b388-45b13df358a8")] 18 | [assembly: System.Reflection.AssemblyVersion("2.0.0.6")] 19 | [assembly: System.Reflection.AssemblyFileVersion("2.0.0.6")] 20 | 21 | 22 | -------------------------------------------------------------------------------- /client/ClientDecisionService/app.config.transform: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /client/ClientDecisionService/web.config.transform: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /client/ClientDecisionServiceSample/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Research.MultiWorldTesting.ClientLibrary; 2 | using Microsoft.Research.MultiWorldTesting.JoinUploader; 3 | using Microsoft.Research.MultiWorldTesting.ExploreLibrary; 4 | using Microsoft.Research.MultiWorldTesting.ExploreLibrary.SingleAction; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Diagnostics; 8 | using System.Linq; 9 | using System.Net; 10 | using System.Threading; 11 | 12 | namespace ClientDecisionServiceSample 13 | { 14 | class Program 15 | { 16 | static void Main(string[] args) 17 | { 18 | Trace.Listeners.Add(new ConsoleTraceListener()); 19 | 20 | // Sample code showing how to use the simple interface of the client library 21 | // to perform news recommendation. This example assumes the set of topics 22 | // is constant for each decision varies. 23 | //Sample.NewsRecommendation().Wait(); 24 | 25 | // Sample code showing how to use the simple interface of the client library 26 | // to perform news recommendation. This example assumes each topic has its 27 | // own set of features and the set of topics available for each decision varies. 28 | //SampleActionDependentFeature.NewsRecommendation().Wait(); 29 | 30 | SampleHosted.Sample().Wait(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /client/ClientDecisionServiceSample/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ClientDecisionServiceSample")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ClientDecisionServiceSample")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("c80e4ec8-7d28-4718-b65f-e32bc11e4f4b")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /client/ClientDecisionServiceSample/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /client/ClientDecisionServiceTest/AzureStorageHelper.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.WindowsAzure.Storage; 2 | using Microsoft.WindowsAzure.Storage.Blob; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Threading.Tasks; 6 | 7 | namespace ClientDecisionServiceTest 8 | { 9 | public class AzureStorageHelper 10 | { 11 | public static void CleanCompleteBlobs() 12 | { 13 | // Delete all joined data 14 | CloudStorageAccount storageAccount = CloudStorageAccount.Parse(MockCommandCenter.StorageConnectionString); 15 | CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); 16 | IEnumerable completeContainers = blobClient.ListContainers("complete"); 17 | 18 | var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount * 2 }; 19 | foreach (CloudBlobContainer container in completeContainers) 20 | { 21 | Parallel.ForEach(container.ListBlobs(), parallelOptions, blob => ((CloudBlockBlob)blob).Delete()); 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /client/ClientDecisionServiceTest/MockCommandTestBase.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace ClientDecisionServiceTest 9 | { 10 | [TestClass] 11 | public class MockCommandTestBase 12 | { 13 | [TestInitialize] 14 | public void Setup() 15 | { 16 | joinServer = new MockJoinServer(MockJoinServer.MockJoinServerAddress); 17 | 18 | joinServer.Run(); 19 | 20 | commandCenter = new MockCommandCenter(); 21 | } 22 | 23 | [TestCleanup] 24 | public void CleanUp() 25 | { 26 | joinServer.Stop(); 27 | } 28 | 29 | protected MockJoinServer joinServer; 30 | protected MockCommandCenter commandCenter; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /client/ClientDecisionServiceTest/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ClientDecisionServiceTest")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ClientDecisionServiceTest")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("624df17a-6d9d-495c-a1b6-27ab88befab4")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /client/ClientDecisionServiceTest/StartStopAzureEmulator.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace ClientDecisionServiceTest 9 | { 10 | [TestClass] 11 | public sealed class StartStopAzureEmulator 12 | { 13 | private static bool _wasUp; 14 | 15 | [AssemblyInitialize] 16 | public static void StartAzureBeforeAllTestsIfNotUp(Microsoft.VisualStudio.TestTools.UnitTesting.TestContext context) 17 | { 18 | if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("StorageConnectionString"))) 19 | return; 20 | 21 | if (!AzureStorageEmulatorManager.IsProcessStarted()) 22 | { 23 | AzureStorageEmulatorManager.StartStorageEmulator(); 24 | _wasUp = false; 25 | } 26 | else 27 | { 28 | _wasUp = true; 29 | } 30 | 31 | } 32 | 33 | [AssemblyCleanup] 34 | public static void StopAzureAfterAllTestsIfWasDown() 35 | { 36 | if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("StorageConnectionString"))) 37 | return; 38 | 39 | if (!_wasUp) 40 | { 41 | AzureStorageEmulatorManager.StopStorageEmulator(); 42 | } 43 | else 44 | { 45 | // Leave as it was before testing... 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /client/ClientDecisionServiceTest/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /client/ClientDecisionServiceVowpalWabbit/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | [assembly: System.Reflection.AssemblyTitle("Microsoft.Research.MultiWorldTesting.ClientLibrary.VowpalWabbit")] 12 | [assembly: System.Reflection.AssemblyCompany("Microsoft Corp")] 13 | [assembly: System.Reflection.AssemblyProduct("Microsoft.Research.MultiWorldTesting.ClientLibrary")] 14 | [assembly: System.Reflection.AssemblyCopyright("Copyright (C) Microsoft Corp 2014-2016")] 15 | [assembly: System.Runtime.InteropServices.ComVisible(false)] 16 | [assembly: System.CLSCompliant(false)] 17 | [assembly: System.Runtime.InteropServices.Guid("a991c863-165c-4fd5-b388-45b13df358a8")] 18 | [assembly: System.Reflection.AssemblyVersion("2.0.0.6")] 19 | [assembly: System.Reflection.AssemblyFileVersion("2.0.0.6")] 20 | 21 | 22 | -------------------------------------------------------------------------------- /client/ClientDecisionServiceVowpalWabbit/VWState.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace Microsoft.Research.MultiWorldTesting.ClientLibrary 9 | { 10 | /// 11 | /// Defines the policy state for a VowpalWabbit model. 12 | /// 13 | [JsonObject(Id = "stvw")] 14 | public class VWState 15 | { 16 | /// 17 | /// The model id used at scoring time. 18 | /// 19 | [JsonProperty("m")] 20 | public string ModelId { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /client/ClientDecisionServiceVowpalWabbit/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /client/ClientDecisionServiceVowpalWabbit/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /client/ClientDecisionServiceWebStandalone/Configuration.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ClientDecisionServiceWebStandalone 8 | { 9 | public class Configuration 10 | { 11 | public string Url { get; set; } 12 | 13 | public string AppInsightsKey { get; set; } 14 | 15 | public string DecisionServiceUrl { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /client/ClientDecisionServiceWebStandalone/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.ApplicationInsights.Extensibility; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Newtonsoft.Json; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Diagnostics; 7 | using System.IO; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | namespace ClientDecisionServiceWebStandalone 13 | { 14 | class Program 15 | { 16 | static int Main(string[] args) 17 | { 18 | // Input parameters 19 | if (args.Length != 1) 20 | { 21 | Console.Error.WriteLine($"Usage: {Process.GetCurrentProcess().ProcessName} config.json"); 22 | return -1; 23 | } 24 | 25 | var config = JsonConvert.DeserializeObject(File.ReadAllText(args[0])); 26 | DecisionServiceController.Initialize(config.DecisionServiceUrl); 27 | 28 | TelemetryConfiguration.Active.InstrumentationKey = config.AppInsightsKey; 29 | 30 | var host = new WebHostBuilder() 31 | .UseKestrel() 32 | .UseStartup() 33 | .UseUrls(config.Url) 34 | .Build(); 35 | 36 | host.Run(); 37 | 38 | return 0; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /client/ClientDecisionServiceWebStandalone/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ClientDecisionServiceWebStandalone")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ClientDecisionServiceWebStandalone")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("76411507-1c8f-46bf-a563-c73a9017c066")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /client/ClientDecisionServiceWebStandalone/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "Url": "http://localhost:5000", 3 | "AppInsightsKey": "", 4 | "DecisionServiceUrl": "" 5 | } -------------------------------------------------------------------------------- /client/CreateLocalNuget.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set BuildNuget=true 3 | devenv Decision.sln /build 4 | xcopy /y bin\x64\Release\*.nupkg c:\work\LocalNugets 5 | 6 | -------------------------------------------------------------------------------- /client/JoinServerUploader/.gitignore: -------------------------------------------------------------------------------- 1 | *.nupkg -------------------------------------------------------------------------------- /client/JoinServerUploader/Constants.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Microsoft.Research.MultiWorldTesting.JoinUploader 4 | { 5 | internal static class Constants 6 | { 7 | internal static readonly TimeSpan ConnectionTimeOut = TimeSpan.FromMinutes(5); 8 | 9 | internal static readonly int RetryCount = 3; 10 | internal static readonly TimeSpan RetryMinBackoff = TimeSpan.FromMilliseconds(500); 11 | internal static readonly TimeSpan RetryMaxBackoff = TimeSpan.FromMilliseconds(4000); 12 | internal static readonly TimeSpan RetryDeltaBackoff = TimeSpan.FromMilliseconds(1000); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /client/JoinServerUploader/DecisionServiceTransientErrorDetectionStrategy.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling; 2 | using System; 3 | using System.Net; 4 | 5 | namespace Microsoft.Research.MultiWorldTesting.JoinUploader 6 | { 7 | class JoinServiceTransientErrorDetectionStrategy : ITransientErrorDetectionStrategy 8 | { 9 | public bool IsTransient(Exception ex) 10 | { 11 | if (ex is WebException) 12 | { 13 | WebException wex = ex as WebException; 14 | HttpWebResponse response = wex.Response as HttpWebResponse; 15 | if (response != null && response.StatusCode == HttpStatusCode.NotFound) 16 | { 17 | return false; 18 | } 19 | } 20 | return true; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /client/JoinServerUploader/Extensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reactive; 4 | using System.Reactive.Linq; 5 | 6 | namespace Microsoft.Research.MultiWorldTesting.JoinUploader 7 | { 8 | internal static class ExtensionMethods 9 | { 10 | internal static IObservable> Buffer(this IObservable source, int maxCount, int maxSize, Func measure) 11 | { 12 | return Observable.Create>(obs => 13 | { 14 | var state = new List(); 15 | var size = 0; 16 | return source.Subscribe( 17 | onNext: v => 18 | { 19 | size += measure(v); 20 | state.Add(v); 21 | 22 | if (size >= maxSize || state.Count >= maxCount) 23 | { 24 | obs.OnNext(state); 25 | 26 | state = new List(); 27 | size = 0; 28 | } 29 | }, 30 | onError: e => obs.OnError(e), 31 | onCompleted: () => 32 | { 33 | if (state.Count > 0) 34 | { 35 | obs.OnNext(state); 36 | } 37 | obs.OnCompleted(); 38 | }); 39 | }); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /client/JoinServerUploader/IHttpClient.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | 4 | namespace Microsoft.Research.MultiWorldTesting.JoinUploader 5 | { 6 | /// 7 | /// The custom HTTP client type for handling HTTP requests. 8 | /// 9 | public interface IHttpClient : IDisposable 10 | { 11 | /// 12 | /// Initializes the HTTP client with appropriate settings. 13 | /// 14 | /// The base address of the HTTP server. 15 | /// The object representing the timeout period. 16 | /// The authentication scheme. 17 | /// The authentication value. 18 | void Initialize(string baseAddress, TimeSpan timeout, string authenticationScheme, string authenticationValue); 19 | 20 | /// 21 | /// Post the 22 | /// 23 | /// Send a POST request to the specified address as an asynchronous operation. 24 | /// The JSON value to be included in the request. 25 | /// Returns a task representing the asynchronous operation. 26 | Task PostAsync(string postAddress, string json); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /client/JoinServerUploader/IHttpResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace Microsoft.Research.MultiWorldTesting.JoinUploader 4 | { 5 | /// 6 | /// Defines methods for custom HTTP response types. 7 | /// 8 | public interface IHttpResponse 9 | { 10 | /// 11 | /// Gets a value that indicates if the HTTP response was successful. 12 | /// 13 | bool IsSuccessStatusCode { get; } 14 | 15 | /// 16 | /// Write the HTTP content to a string as an asynchronous operation. 17 | /// 18 | /// Returns a task representing the asynchronous operation. 19 | Task GetContentAsync(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /client/JoinServerUploader/JoinServerUploader.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Multiworld Testing Decision Service Uploader 5 | Microsoft.Research.MultiWorldTesting.JoinUploader 6 | Multiworld Testing 7 | $version$ 8 | John Langford, Luong Hoang, Markus Cozowicz, Sarah Bird, Sid Sen (mwtdev@microsoft.com) 9 | Microsoft Research 10 | http://aka.ms/mwt 11 | https://github.com/JohnLangford/vowpal_wabbit/blob/master/LICENSE 12 | false 13 | Library for uploading events to Multiworld Testing Join Server. 14 | Copyright (C) 2015-2016 Microsoft Corporation 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /client/JoinServerUploader/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | [assembly: System.Reflection.AssemblyTitle("Microsoft.Research.MultiWorldTesting.JoinUploader")] 12 | [assembly: System.Reflection.AssemblyCompany("Microsoft Corp")] 13 | [assembly: System.Reflection.AssemblyProduct("Microsoft.Research.MultiWorldTesting.JoinUploader")] 14 | [assembly: System.Reflection.AssemblyCopyright("Copyright (C) Microsoft Corp 2014-2016")] 15 | [assembly: System.Runtime.InteropServices.ComVisible(false)] 16 | [assembly: System.CLSCompliant(true)] 17 | [assembly: System.Runtime.InteropServices.Guid("324bd225-38a8-476f-bc96-ad563697274d")] 18 | [assembly: System.Reflection.AssemblyVersion("2.0.0.6")] 19 | [assembly: System.Reflection.AssemblyFileVersion("2.0.0.6")] 20 | 21 | 22 | -------------------------------------------------------------------------------- /client/JoinServerUploader/RawStringConverter.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All Rights Reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | using System; 8 | using System.Globalization; 9 | using System.Text; 10 | using Newtonsoft.Json; 11 | 12 | namespace Microsoft.Research.MultiWorldTesting.JoinUploader 13 | { 14 | /// 15 | /// Custom JSON converter returning the underlying raw json (avoiding object allocation) 16 | /// 17 | internal class RawStringConverter : JsonConverter 18 | { 19 | public override bool CanConvert(Type objectType) 20 | { 21 | return true; 22 | } 23 | 24 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) 25 | { 26 | throw new NotImplementedException(); 27 | } 28 | 29 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) 30 | { 31 | var valueString = value as string; 32 | if (valueString != null) 33 | { 34 | writer.WriteRawValue(valueString); 35 | } 36 | else 37 | { 38 | serializer.Serialize(writer, value); 39 | } 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /client/JoinServerUploader/StrictTypedEqualityComparer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Microsoft.Research.MultiWorldTesting.JoinUploader 8 | { 9 | /// 10 | /// An equality comparer with type checking. 11 | /// 12 | /// The type of the object to compare. 13 | public class StrictTypedEqualityComparer : IEqualityComparer 14 | where T : class 15 | { 16 | private IEqualityComparer equalityComparer; 17 | 18 | /// 19 | /// Constructor. 20 | /// 21 | /// The comparer instance. 22 | public StrictTypedEqualityComparer(IEqualityComparer equalityComparer) 23 | { 24 | this.equalityComparer = equalityComparer; 25 | } 26 | 27 | bool IEqualityComparer.Equals(object x, object y) 28 | { 29 | if (x == null && y == null) 30 | { 31 | return false; 32 | } 33 | 34 | var xt = x as T; 35 | var yt = y as T; 36 | 37 | if (xt == null || yt == null) 38 | { 39 | return false; 40 | } 41 | 42 | return this.equalityComparer.Equals(xt, yt); 43 | } 44 | 45 | int IEqualityComparer.GetHashCode(object obj) 46 | { 47 | var objt = obj as T; 48 | if (objt == null) 49 | { 50 | return -1; 51 | } 52 | 53 | return this.equalityComparer.GetHashCode(objt); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /client/JoinServerUploader/UploaderHttpResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using System.Threading.Tasks; 3 | 4 | namespace Microsoft.Research.MultiWorldTesting.JoinUploader 5 | { 6 | /// 7 | /// Implementation of that wraps the object. 8 | /// 9 | internal class UploaderHttpResponse : IHttpResponse 10 | { 11 | internal UploaderHttpResponse(HttpResponseMessage response) 12 | { 13 | this.response = response; 14 | } 15 | 16 | public bool IsSuccessStatusCode 17 | { 18 | get 19 | { 20 | return response.IsSuccessStatusCode; 21 | } 22 | } 23 | 24 | public Task GetContentAsync() 25 | { 26 | return this.response.Content.ReadAsStringAsync(); 27 | } 28 | 29 | private HttpResponseMessage response; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /client/JoinServerUploader/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /client/MultiWorldTestingServiceContract/ApplicationMetadataUtil.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System; 3 | using System.IO; 4 | using System.Net; 5 | 6 | namespace Microsoft.Research.MultiWorldTesting.Contract 7 | { 8 | /// 9 | /// Helper class to download meta data. 10 | /// 11 | public static class ApplicationMetadataUtil 12 | { 13 | /// 14 | /// Download and deserialize settings. 15 | /// 16 | public static TMetadata DownloadMetadata(string blobUri) 17 | { 18 | string jsonMetadata = ""; 19 | try 20 | { 21 | using (var wc = new WebClient()) 22 | { 23 | jsonMetadata = wc.DownloadString(blobUri); 24 | return JsonConvert.DeserializeObject(jsonMetadata); 25 | } 26 | } 27 | catch (Exception ex) 28 | { 29 | throw new InvalidDataException("Unable to download metadata from specified blob uri " + blobUri + ", JSON: " + jsonMetadata, ex); 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /client/MultiWorldTestingServiceContract/ApplicationSettingConstants.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All Rights Reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | namespace Microsoft.Research.MultiWorldTesting.Contract 8 | { 9 | /// 10 | /// Unused class. 11 | /// 12 | public class ApplicationSettingConstants 13 | { 14 | /// 15 | /// Unused. 16 | /// 17 | public const string UseLatestModelSetting = "latest"; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /client/MultiWorldTestingServiceContract/MultiWorldTestingServiceContract.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Multiworld Testing Service Contract 5 | Microsoft.Research.MultiWorldTesting.Contract 6 | Multiworld Testing 7 | $version$ 8 | John Langford, Luong Hoang, Markus Cozowicz, Sarah Bird, Sid Sen (mwtdev@microsoft.com) 9 | Microsoft Research 10 | http://aka.ms/mwt 11 | https://github.com/JohnLangford/vowpal_wabbit/blob/master/LICENSE 12 | false 13 | Binding contract between components of Multiworld Testing Service. 14 | Copyright (C) 2015-2016 Microsoft Corporation 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /client/MultiWorldTestingServiceContract/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | [assembly: System.Reflection.AssemblyTitle("Microsoft.Research.MultiWorldTesting.Contract")] 12 | [assembly: System.Reflection.AssemblyCompany("Microsoft Corp")] 13 | [assembly: System.Reflection.AssemblyProduct("Microsoft.Research.MultiWorldTesting.Contract")] 14 | [assembly: System.Reflection.AssemblyCopyright("Copyright (C) Microsoft Corp 2014-2016")] 15 | [assembly: System.Runtime.InteropServices.ComVisible(false)] 16 | [assembly: System.CLSCompliant(true)] 17 | [assembly: System.Runtime.InteropServices.Guid("d9d80c55-19ce-48fa-a2ef-7eae466b1f9b")] 18 | [assembly: System.Reflection.AssemblyVersion("2.0.0.6")] 19 | [assembly: System.Reflection.AssemblyFileVersion("2.0.0.6")] 20 | 21 | 22 | -------------------------------------------------------------------------------- /client/MultiWorldTestingServiceContract/ServiceConstants.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All Rights Reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | namespace Microsoft.Research.MultiWorldTesting.Contract 8 | { 9 | /// 10 | /// Service constants used for old join service. 11 | /// 12 | public class ServiceConstants 13 | { 14 | /// 15 | /// public address of join server. 16 | /// 17 | public const string JoinAddress = "http://decisionservice.cloudapp.net"; 18 | 19 | /// 20 | /// Path for joining. 21 | /// 22 | public const string JoinPostAddress = "/join"; 23 | 24 | /// 25 | /// Authentication header. 26 | /// 27 | public const string TokenAuthenticationScheme = "Bearer"; 28 | 29 | /// 30 | /// Authentication scheme. 31 | /// 32 | public const string ConnectionStringAuthenticationScheme = "AzureStorage"; 33 | 34 | /// 35 | /// Azure container name. 36 | /// 37 | public const string IncompleteContainerPrefix = "incomplete"; 38 | 39 | /// 40 | /// Azure container name. 41 | /// 42 | public const string JoinedBlobContainerPrefix = "joined-examples"; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /client/MultiWorldTestingServiceContract/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /client/appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.0.{build} 2 | configuration: Release 3 | platform: x64 4 | build_script: 5 | - cd c:\projects\decision 6 | - .nuget\nuget install -o packages ClientDecisionService\packages.config 7 | - .nuget\nuget install -o packages ClientDecisionServiceTest\packages.config 8 | - .nuget\nuget install -o packages ClientDecisionServiceSample\packages.config 9 | - .nuget\nuget install -o packages explore\packages.config 10 | - .nuget\nuget install -o packages JoinServerUploader\packages.config 11 | - .nuget\nuget install -o packages MultiworldTestingServiceContract\packages.config 12 | - '"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" "c:\projects\decision\Decision.sln" /m /verbosity:normal /p:Configuration=Release;Platform=x64' 13 | test_script: 14 | - ps: vstest.console /Platform:x64 /inIsolation bin\x64\Release\ClientDecisionServiceTest.dll -------------------------------------------------------------------------------- /client/docgen.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | SET DOXY="C:\Program Files\doxygen\bin\doxygen.exe" 4 | 5 | if exist %DOXY% ( 6 | pushd 7 | cd /d %1 8 | call %DOXY% Doxyfile 9 | popd 10 | ) 11 | 12 | exit 0 -------------------------------------------------------------------------------- /client/explore/BaseExplorer.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.Research.MultiWorldTesting.ExploreLibrary 2 | { 3 | /// 4 | /// Base for explorer implementations. 5 | /// 6 | /// 7 | /// 8 | public abstract class BaseExplorer 9 | : IExplorer 10 | { 11 | protected bool explore; 12 | 13 | protected BaseExplorer() 14 | { 15 | this.explore = true; 16 | } 17 | 18 | /// 19 | /// Enable or disables exploration. 20 | /// 21 | /// True to enable exploration. 22 | public virtual void EnableExplore(bool explore) 23 | { 24 | this.explore = explore; 25 | } 26 | 27 | /// 28 | /// Maps a context to a decision. 29 | /// 30 | public abstract ExplorerDecision MapContext(PRG prg, TPolicyValue policyAction, int numActions); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /client/explore/Feature.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace Microsoft.Research.MultiWorldTesting.ExploreLibrary 5 | { 6 | /// 7 | /// Represents a feature in a sparse array. 8 | /// 9 | [StructLayout(LayoutKind.Sequential)] 10 | public struct Feature 11 | { 12 | public float Value; 13 | public UInt32 Id; 14 | }; 15 | } 16 | -------------------------------------------------------------------------------- /client/explore/InitialExplorer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Microsoft.Research.MultiWorldTesting.ExploreLibrary 8 | { 9 | public sealed class EpsilonGreedyInitialExplorer : IInitialExplorer 10 | { 11 | private float epsilon; 12 | 13 | public EpsilonGreedyInitialExplorer(float epsilon) 14 | { 15 | this.epsilon = epsilon; 16 | } 17 | 18 | public ActionProbability[] Explore(int[] defaultValues) 19 | { 20 | float prob = this.epsilon / defaultValues.Length; 21 | return defaultValues 22 | .Select(action => 23 | new ActionProbability 24 | { 25 | Action = action, 26 | Probability = action == defaultValues[0] ? prob + (1 - this.epsilon) : prob 27 | }) 28 | .ToArray(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /client/explore/PermutationExplorer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Microsoft.Research.MultiWorldTesting.ExploreLibrary 8 | { 9 | public sealed class PermutationExplorer : IFullExplorer 10 | { 11 | private readonly int maxPermutations; 12 | 13 | public PermutationExplorer(int maxPermutations = int.MaxValue) 14 | { 15 | this.maxPermutations = maxPermutations; 16 | } 17 | 18 | public ExplorerDecision Explore(PRG random, int numActionsVariable) 19 | { 20 | var ranking = Enumerable.Range(1, numActionsVariable).ToArray(); 21 | 22 | for (int i = 0; i < ranking.Length - 1 && i < maxPermutations; i++) 23 | { 24 | int swapIndex = random.UniformInt(i, ranking.Length - 1); 25 | 26 | int temp = ranking[swapIndex]; 27 | ranking[swapIndex] = ranking[i]; 28 | ranking[i] = temp; 29 | } 30 | 31 | return ExplorerDecision.Create( 32 | ranking, 33 | new GenericTopSlotExplorerState { Probabilities = Enumerable.Repeat(1f / numActionsVariable, numActionsVariable).ToArray() }, 34 | true); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /client/explore/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Resources; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | 6 | // General Information about an assembly is controlled through the following 7 | // set of attributes. Change these attribute values to modify the information 8 | // associated with an assembly. 9 | [assembly: AssemblyTitle("Explore")] 10 | [assembly: AssemblyDescription("")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("")] 13 | [assembly: AssemblyProduct("Explore")] 14 | [assembly: AssemblyCopyright("Copyright © 2015")] 15 | [assembly: AssemblyTrademark("")] 16 | [assembly: AssemblyCulture("")] 17 | [assembly: NeutralResourcesLanguage("en")] 18 | 19 | // Version information for an assembly consists of the following four values: 20 | // 21 | // Major Version 22 | // Minor Version 23 | // Build Number 24 | // Revision 25 | // 26 | // You can specify all the values or you can default the Build and Revision Numbers 27 | // by using the '*' as shown below: 28 | // [assembly: AssemblyVersion("1.0.*")] 29 | [assembly: AssemblyVersion("1.0.0.0")] 30 | [assembly: AssemblyFileVersion("1.0.0.0")] 31 | -------------------------------------------------------------------------------- /client/explore/SimpleContext.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Globalization; 3 | using System.Text; 4 | 5 | namespace Microsoft.Research.MultiWorldTesting.ExploreLibrary.SingleAction 6 | { 7 | /// 8 | /// A sample context class that stores a vector of Features. 9 | /// 10 | public class SimpleContext 11 | { 12 | public SimpleContext(float[] features) 13 | { 14 | this.Features = features; 15 | } 16 | 17 | public override string ToString() 18 | { 19 | return string.Join(" ", this.Features); 20 | } 21 | 22 | public float[] Features { get; set; } 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /client/explore/TopSlotExplorer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | 8 | namespace Microsoft.Research.MultiWorldTesting.ExploreLibrary 9 | { 10 | // TODO: what about removing this class entirely and refactor the Top Slot logic as static methods instead? 11 | public sealed class TopSlotExplorer : BaseExplorer 12 | { 13 | private readonly IExplorer explorer; 14 | 15 | public TopSlotExplorer(IExplorer explorer) 16 | { 17 | if (explorer == null) 18 | throw new ArgumentNullException("variableActionExplorer"); 19 | 20 | this.explorer = explorer; 21 | } 22 | 23 | public override ExplorerDecision MapContext(PRG prg, int[] ranking, int numActions) 24 | { 25 | if (ranking == null || ranking.Length < 1) 26 | throw new ArgumentException("Actions chosen by default policy must not be empty."); 27 | 28 | var decision = this.explorer.MapContext(prg, ranking[0], ranking.Length); 29 | MultiActionHelper.PutActionToList(decision.Value, ranking); 30 | 31 | return ExplorerDecision.Create(ranking, decision.ExplorerState, decision.ShouldRecord); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /client/explore/UniformRandomExploration.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Microsoft.Research.MultiWorldTesting.ExploreLibrary 8 | { 9 | 10 | // IFullExplorer foo = new UniformRandomExploration(); 11 | 12 | public sealed class UniformRandomExploration : IFullExplorer 13 | { 14 | public ExplorerDecision Explore(PRG random, int numActions) 15 | { 16 | return ExplorerDecision.Create( 17 | random.UniformInt(1, numActions), 18 | new GenericExplorerState { Probability = 1f }, 19 | shouldRecord: true); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /client/explore/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /client/version.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2.0.0.7 5 | 6 | 7 | -------------------------------------------------------------------------------- /forkify.ps1: -------------------------------------------------------------------------------- 1 | param ([string]$fork = "Microsoft") 2 | 3 | 4 | $f = (gc provisioning\azuredeploy.json) 5 | $f = ($f -replace 'https://raw.githubusercontent.com/.*/mwt-ds/master/provisioning/', "https://raw.githubusercontent.com/$fork/mwt-ds/master/provisioning/") 6 | $f | Out-File -Encoding "UTF8" provisioning\azuredeploy.json 7 | 8 | $f = (gc provisioning\test\ProvisioningUtil.cs) 9 | $f = ($f -replace "https://raw.githubusercontent.com/.*/mwt-ds/master/provisioning", "https://raw.githubusercontent.com/$fork/mwt-ds/master/provisioning") 10 | $f | Out-File -Encoding "UTF8" provisioning\test\ProvisioningBaseTest.cs 11 | 12 | $f = (gc provisioning\templates\WebManageTemplate.json) 13 | $f = ($f -replace "https://github.com/.*/mwt-ds.git", "https://github.com/$fork/mwt-ds.git") 14 | $f | Out-File -Encoding "UTF8" provisioning\templates\WebManageTemplate.json 15 | 16 | $f = (gc provisioning\templates\WebManageUpgradeTemplate.json) 17 | $f = ($f -replace "https://github.com/.*/mwt-ds.git", "https://github.com/$fork/mwt-ds.git") 18 | $f | Out-File -Encoding "UTF8" provisioning\templates\WebManageUpgradeTemplate.json 19 | -------------------------------------------------------------------------------- /hosted.js/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible Node.js debug attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "launch", 10 | "preLaunchTask": "tsc", 11 | "name": "Launch Program", 12 | "program": "${workspaceRoot}\\src\\DecisionService.js", 13 | "cwd": "${workspaceRoot}", 14 | "outFiles": [] 15 | }, 16 | { 17 | "type": "node", 18 | "request": "launch", 19 | "preLaunchTask": "tsc", 20 | "name": "Mocha Tests", 21 | "program": "${workspaceRoot}/node_modules/.bin/_mocha", 22 | "args": ["${workspaceRoot}/build/test/**/*.js"], 23 | "cwd": "${workspaceRoot}", 24 | "outFiles": [] 25 | } 26 | ] 27 | } -------------------------------------------------------------------------------- /hosted.js/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the tasks.json format 4 | "version": "0.1.0", 5 | "tasks": [ 6 | { 7 | "taskName": "tsc", 8 | "command": "${workspaceRoot}/node_modules/.bin/tsc", 9 | "isShellCommand": true, 10 | "args": [ 11 | "-p", 12 | "." 13 | ], 14 | "showOutput": "silent", 15 | "problemMatcher": "$tsc", 16 | "isBuildCommand": false 17 | }, 18 | { 19 | "command": "${workspaceRoot}/node_modules/.bin/webpack", 20 | "isShellCommand": true, 21 | "args": [ 22 | "--display-modules", 23 | "--progress", 24 | "-d" 25 | ], 26 | "suppressTaskName": true, 27 | "taskName": "webpack dev", 28 | "isBuildCommand": true 29 | }, 30 | { 31 | "command": "${workspaceRoot}/node_modules/.bin/_mocha", 32 | "isShellCommand": true, 33 | "isTestCommand": true, 34 | "args": [ 35 | "build/test/**/*.js", 36 | "--no-timeouts" 37 | ], 38 | "taskName": "mocha" 39 | }, 40 | { 41 | "command": "${workspaceRoot}/node_modules/.bin/karma", 42 | "isShellCommand": true, 43 | "isTestCommand": false, 44 | "args": [ 45 | "run" 46 | ], 47 | "taskName": "karma" 48 | } 49 | ] 50 | } -------------------------------------------------------------------------------- /hosted.js/README.md: -------------------------------------------------------------------------------- 1 | Some description -------------------------------------------------------------------------------- /hosted.js/Webpack.config.js: -------------------------------------------------------------------------------- 1 | var webpack = require("webpack"); 2 | 3 | module.exports = { 4 | entry: './src/DecisionService.ts', 5 | output: { 6 | filename: './build/DecisionService.js' 7 | }, 8 | resolve: { 9 | extensions: ['.Webpack.js', '.web.js', '.ts', '.js', '.tsx'] 10 | }, 11 | module: { 12 | loaders: [ 13 | { 14 | test: /\.ts(x?)$/, 15 | exclude: ['./node_modules/'], 16 | loader: 'ts-loader' 17 | } 18 | ] 19 | }, 20 | plugins: [ 21 | new webpack.optimize.UglifyJsPlugin({ minimize: true }) 22 | ] 23 | } -------------------------------------------------------------------------------- /hosted.js/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "decisionservice", 3 | "version": "0.0.1", 4 | "description": "Microsoft Decision Service", 5 | "main": "src/DecisionService.ts", 6 | "directories": { 7 | "test": "test" 8 | }, 9 | "dependencies": { 10 | "webpack": "^2.3.2", 11 | "ts-loader": "^2.0.3", 12 | "typescript": "^2.2.2", 13 | "jquery": "^3.2.1", 14 | "@types/chai": "^3.4.35", 15 | "@types/mocha": "^2.2.40", 16 | "mocha": "^3.2.0", 17 | "chai": "^3.5.0" 18 | }, 19 | "scripts": { 20 | "test": "mocha" 21 | }, 22 | "repository": { 23 | "type": "git", 24 | "url": "git://github.com/Microsoft/mwt-ds.git" 25 | }, 26 | "devDependencies": { 27 | "jasmine-core": "^2.5.2", 28 | "karma": "^1.5.0", 29 | "karma-chrome-launcher": "^2.0.0", 30 | "karma-fixture": "^0.2.6", 31 | "karma-html-detailed-reporter": "^1.1.20", 32 | "karma-jasmine": "^1.1.0", 33 | "karma-typescript": "git+https://github.com/monounity/karma-typescript.git#2.1.8" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /hosted.js/src/DecisionService.Interfaces.ts: -------------------------------------------------------------------------------- 1 | 2 | export interface DecisionServiceFeatures { 3 | 4 | ids: DecisionServiceReferenceId[]; 5 | 6 | features: any; 7 | 8 | lock: boolean; 9 | } 10 | 11 | export interface DecisionServiceReferenceId { 12 | // optional 13 | site: string; 14 | 15 | id: string; 16 | } 17 | 18 | export interface DecisionServiceActionSet { 19 | id: DecisionServiceReferenceId; 20 | 21 | param: string; 22 | } 23 | 24 | export class DecisionServiceClientOptions { 25 | public hostname: string = 'ds.microsoft.com'; 26 | public protocol: string = 'https'; 27 | } 28 | 29 | export interface DecisionServiceRankRequest { 30 | site: string; 31 | 32 | shared: DecisionServiceFeatures; 33 | 34 | actions: DecisionServiceFeatures[]; 35 | 36 | actionSets: DecisionServiceActionSet[]; 37 | } 38 | 39 | export interface DecisionServicePage { 40 | /** Site id or domain. If omitted resolved from canonical or window.location. */ 41 | site: string; 42 | 43 | /** Path to the article or object. */ 44 | path: string; 45 | } 46 | 47 | export interface DecisionServiceOutcome { 48 | /** Site id or domain. If omitted resolved from canonical or window.location. */ 49 | site: string; 50 | 51 | /** The event id for a decision. */ 52 | eventId: string; 53 | 54 | /** The outcome for the referenced decision. Defaults to 1. */ 55 | outcome: any; 56 | } -------------------------------------------------------------------------------- /hosted.js/test/browser/test.canonial.js: -------------------------------------------------------------------------------- 1 | // import "mocha"; 2 | // import { assert } from "chai"; 3 | // import fixture from "karma-fixture"; 4 | 5 | describe("DecisionServiceBrowser", () => { 6 | beforeEach(function() { 7 | fixture.setBase('/base/test/browser'); 8 | fixture.load('test.canonical.html'); 9 | }); 10 | 11 | it("Simple actions", () => { 12 | // var request = { 13 | // site: 'abc', 14 | // actions: [ 15 | // { ids: [{ id: '1' }] }, 16 | // { ids: [{ id: '2' }] }, 17 | // ], 18 | // actionSets: null, 19 | // shared: null 20 | // }; 21 | 22 | // assert.equal(DecisionServiceRequestUtil.requestToPath(request), '~abc/1/2'); 23 | }); 24 | 25 | 26 | }); -------------------------------------------------------------------------------- /hosted.js/test/browser/test.canonical.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /hosted.js/test/test.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 5 | 6 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 25 | 26 | 28 | 29 | 30 | 45 |
46 | 47 | Hello World! 48 | 49 | -------------------------------------------------------------------------------- /hosted.js/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "noImplicitAny": false, 5 | "removeComments": true, 6 | "preserveConstEnums": true, 7 | "sourceMap": true, 8 | "outDir": "build" 9 | }, 10 | "include": [ 11 | "src/**/*", 12 | "test/**/*" 13 | ], 14 | "exclude": [ 15 | "node_modules" 16 | ], 17 | "typeRoots": [ 18 | "node_modules/@types" 19 | ] 20 | } -------------------------------------------------------------------------------- /images/MWT-WhitePaper.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/mwt-ds/86f552e7a592df6fb41e46e22f3473088660612e/images/MWT-WhitePaper.pdf -------------------------------------------------------------------------------- /images/StartDeployment.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/mwt-ds/86f552e7a592df6fb41e46e22f3473088660612e/images/StartDeployment.jpg -------------------------------------------------------------------------------- /images/deploy-output.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/mwt-ds/86f552e7a592df6fb41e46e22f3473088660612e/images/deploy-output.jpg -------------------------------------------------------------------------------- /images/deploy-track-rg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/mwt-ds/86f552e7a592df6fb41e46e22f3473088660612e/images/deploy-track-rg.jpg -------------------------------------------------------------------------------- /images/deploy-track.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/mwt-ds/86f552e7a592df6fb41e46e22f3473088660612e/images/deploy-track.jpg -------------------------------------------------------------------------------- /images/deploybutton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/mwt-ds/86f552e7a592df6fb41e46e22f3473088660612e/images/deploybutton.png -------------------------------------------------------------------------------- /images/directory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/mwt-ds/86f552e7a592df6fb41e46e22f3473088660612e/images/directory.png -------------------------------------------------------------------------------- /images/msa.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/mwt-ds/86f552e7a592df6fb41e46e22f3473088660612e/images/msa.png -------------------------------------------------------------------------------- /images/org.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/mwt-ds/86f552e7a592df6fb41e46e22f3473088660612e/images/org.png -------------------------------------------------------------------------------- /mc/App_Data/OnlineTrainerConfiguration.cscfg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /mc/App_Data/SASTokenGenerator.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "resources": [ ], 5 | "outputs": { 6 | "SASTokenUriClientSettings": { 7 | "type": "string", 8 | "value": "$$ClientSettings$$" 9 | }, 10 | "SASTokenUriWebSettings": { 11 | "type": "string", 12 | "value": "$$WebSettings$$" 13 | }, 14 | "SASTokenOnlineTrainerCspkg": { 15 | "type": "string", 16 | "value": "$$OnlineTrainerCspkg$$" 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /mc/App_Start/BundleConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Web; 2 | using System.Web.Optimization; 3 | 4 | namespace DecisionServicePrivateWeb 5 | { 6 | public class BundleConfig 7 | { 8 | // For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862 9 | public static void RegisterBundles(BundleCollection bundles) 10 | { 11 | bundles.Add(new ScriptBundle("~/bundles/jquery").Include( 12 | "~/Scripts/jquery-{version}.js", 13 | "~/Scripts/site.js")); 14 | 15 | // Use the development version of Modernizr to develop with and learn from. Then, when you're 16 | // ready for production, use the build tool at http://modernizr.com to pick only the tests you need. 17 | bundles.Add(new ScriptBundle("~/bundles/modernizr").Include( 18 | "~/Scripts/modernizr-*")); 19 | 20 | bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include( 21 | "~/Scripts/bootstrap.js", 22 | "~/Scripts/respond.js")); 23 | 24 | bundles.Add(new StyleBundle("~/Content/css").Include( 25 | "~/Content/bootstrap.css", 26 | "~/Content/site.css")); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /mc/App_Start/RouteConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using System.Web.Routing; 7 | 8 | namespace DecisionServicePrivateWeb 9 | { 10 | public class RouteConfig 11 | { 12 | public static void RegisterRoutes(RouteCollection routes) 13 | { 14 | routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 15 | 16 | routes.MapRoute( 17 | name: "Default", 18 | url: "{controller}/{action}/{id}", 19 | defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } 20 | ); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /mc/Attributes/NoCacheAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Web; 3 | using System.Web.Mvc; 4 | 5 | namespace DecisionServicePrivateWeb.Attributes 6 | { 7 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] 8 | public sealed class NoCacheAttribute : ActionFilterAttribute 9 | { 10 | public override void OnResultExecuting(ResultExecutingContext filterContext) 11 | { 12 | filterContext.HttpContext.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1)); 13 | filterContext.HttpContext.Response.Cache.SetValidUntilExpires(false); 14 | filterContext.HttpContext.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches); 15 | filterContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache); 16 | filterContext.HttpContext.Response.Cache.SetNoStore(); 17 | 18 | base.OnResultExecuting(filterContext); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /mc/Classes/ApplicationSettings.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Research.MultiWorldTesting.Contract; 2 | 3 | namespace DecisionServicePrivateWeb.Classes 4 | { 5 | public class ApplicationSettings 6 | { 7 | public string SubscriptionId { get; set; } 8 | 9 | public string AzureResourceGroupName { get; set; } 10 | public string AppInsightsKey { get; set; } 11 | public DecisionType DecisionType { get; set; } 12 | 13 | public TrainFrequency TrainFrequency { get; set; } 14 | 15 | public string TrainArguments { get; set; } 16 | 17 | public string ApplicationID { get; set; } 18 | 19 | public string ConnectionString { get; set; } 20 | 21 | public string InterEventHubSendConnectionString { get; set; } 22 | 23 | public string ObserEventHubSendConnectionString { get; set; } 24 | 25 | public string ModelId { get; set; } 26 | 27 | public float InitialExplorationEpsilon { get; set; } 28 | 29 | public bool IsExplorationEnabled { get; set; } 30 | 31 | public int ExperimentalUnitDuration { get; set; } 32 | 33 | public string ModelBlobUri { get; set; } 34 | 35 | public string SettingsTokenUri1 { get; set; } 36 | 37 | public string SettingsTokenUri2 { get; set; } 38 | } 39 | } -------------------------------------------------------------------------------- /mc/Classes/EvalD3.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Web; 6 | 7 | namespace DecisionServicePrivateWeb.Classes 8 | { 9 | public class EvalD3 10 | { 11 | public string key { get; set; } 12 | 13 | public Dictionary values { get; set; } 14 | } 15 | } -------------------------------------------------------------------------------- /mc/Classes/EvalResult.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System; 3 | 4 | namespace DecisionServicePrivateWeb.Classes 5 | { 6 | /// 7 | /// Represents a single policy evaluation result. 8 | /// 9 | public class EvalResult 10 | { 11 | [JsonProperty(PropertyName = "name")] 12 | public string PolicyName { get; set; } 13 | 14 | [JsonProperty(PropertyName = "lastenqueuedtime")] 15 | public DateTime LastWindowTime { get; set; } 16 | 17 | [JsonProperty(PropertyName = "averagecost")] 18 | public float AverageCost { get; set; } 19 | 20 | [JsonProperty(PropertyName = "window")] 21 | public string WindowType { get; set; } 22 | } 23 | } -------------------------------------------------------------------------------- /mc/Classes/TimeoutWebClient.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | 4 | namespace DecisionServicePrivateWeb.Classes 5 | { 6 | public class TimeoutWebClient : WebClient 7 | { 8 | protected override WebRequest GetWebRequest(Uri uri) 9 | { 10 | WebRequest w = base.GetWebRequest(uri); 11 | w.Timeout = (int)TimeSpan.FromSeconds(2).TotalMilliseconds; 12 | return w; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /mc/Content/Demo.css: -------------------------------------------------------------------------------- 1 | body { 2 | 3 | background-color:#363179; 4 | color:white; 5 | font-family:'Segoe UI' 6 | } 7 | 8 | 9 | body { 10 | padding-top: 50px; 11 | padding-bottom: 20px; 12 | } 13 | 14 | p { 15 | font-size:20px; 16 | } 17 | 18 | code { 19 | background-color : transparent; 20 | } 21 | 22 | 23 | 24 | 25 | 26 | .lead { 27 | font-size:30px; 28 | } 29 | 30 | 31 | .body-content { 32 | padding-left: 15px; 33 | padding-right: 15px; 34 | } 35 | 36 | .content-item { 37 | overflow:hidden; 38 | width:200px; 39 | text-align: center; 40 | margin: 0 auto; 41 | display: table; 42 | } 43 | 44 | .disabled { 45 | opacity: 0.1; 46 | } 47 | 48 | a.thumb { 49 | cursor: pointer; 50 | } 51 | 52 | a.thumb:visited { 53 | color:#428bca; 54 | } 55 | 56 | a.thumb:hover { 57 | color:#2a6496; 58 | } -------------------------------------------------------------------------------- /mc/DecisionServicePrivateWeb.SetParameters.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /mc/DecisionServicePrivateWeb.SourceManifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /mc/DownloadAppSettings.ps1: -------------------------------------------------------------------------------- 1 | $url = Read-Host -Prompt "Management Center URL" 2 | $password = Read-Host -Prompt "Password" 3 | Invoke-WebRequest -Uri "$($url)/Automation/AppSettings" -Headers @{"auth"=$password} -OutFile ..\..\AppSettingsSecrets.config -------------------------------------------------------------------------------- /mc/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="DecisionServicePrivateWeb.MvcApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /mc/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using DecisionServicePrivateWeb.Classes; 2 | using Microsoft.ApplicationInsights.Extensibility; 3 | using System.Configuration; 4 | using System.Web.Mvc; 5 | using System.Web.Optimization; 6 | using System.Web.Routing; 7 | 8 | namespace DecisionServicePrivateWeb 9 | { 10 | public class MvcApplication : System.Web.HttpApplication 11 | { 12 | protected void Application_Start() 13 | { 14 | AreaRegistration.RegisterAllAreas(); 15 | RouteConfig.RegisterRoutes(RouteTable.Routes); 16 | BundleConfig.RegisterBundles(BundleTable.Bundles); 17 | TelemetryConfiguration.Active.InstrumentationKey = ConfigurationManager.AppSettings[ApplicationMetadataStore.AKAppInsightsKey]; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /mc/GlobalSuppressions.cs: -------------------------------------------------------------------------------- 1 | // This file is used by Code Analysis to maintain SuppressMessage 2 | // attributes that are applied to this project. 3 | // Project-level suppressions either have no target or are given 4 | // a specific target and scoped to a namespace, type, member, etc. 5 | // 6 | // To add a suppression to this file, right-click the message in the 7 | // Code Analysis results, point to "Suppress Message", and click 8 | // "In Suppression File". 9 | // You do not need to add suppressions to this file manually. 10 | 11 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security.Web.Configuration", "CA3119:SetHttpCookiesRequireSSLToTrue")] 12 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security.Web.Configuration", "CA3103:SetFormsRequireSSLToTrue")] 13 | -------------------------------------------------------------------------------- /mc/Models/EvaluationViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | 6 | namespace DecisionServicePrivateWeb.Models 7 | { 8 | public class EvaluationViewModel 9 | { 10 | public List WindowFilters { get; set; } 11 | public string SelectedFilter { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /mc/Models/IndexViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | 6 | namespace DecisionServicePrivateWeb.Models 7 | { 8 | public class IndexViewModel 9 | { 10 | public string Error { get; set; } 11 | public bool Authenticated { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /mc/Models/SettingsSaveModel.cs: -------------------------------------------------------------------------------- 1 | using DecisionServicePrivateWeb.Validations; 2 | using Microsoft.Research.MultiWorldTesting.Contract; 3 | 4 | namespace DecisionServicePrivateWeb.Models 5 | { 6 | public class SettingsSaveModel 7 | { 8 | public string TrainArguments { get; set; } 9 | 10 | public string SelectedModelId { get; set; } 11 | 12 | public bool IsExplorationEnabled { get; set; } 13 | 14 | [UnitInterval(ErrorMessage = "Initial Exploration Epsilon must be a value in the interval [0,1]")] 15 | public float InitialExplorationEpsilon { get; set; } 16 | } 17 | } -------------------------------------------------------------------------------- /mc/Models/SimulationViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | 6 | namespace DecisionServicePrivateWeb.Models 7 | { 8 | public class SimulationViewModel 9 | { 10 | public string Password { get; set; } 11 | 12 | public string WebServiceToken { get; set; } 13 | 14 | public string TrainerToken { get; set; } 15 | 16 | public EvaluationViewModel EvaluationView { get; set; } 17 | 18 | public string TrainerArguments { get; set; } 19 | } 20 | } -------------------------------------------------------------------------------- /mc/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("DecisionServicePrivateWeb")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("DecisionServicePrivateWeb")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("33901324-b99d-4ae4-99ac-e92cb1709c6c")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /mc/Properties/PublishProfiles/arm.pubxml: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | Package 9 | Debug 10 | x64 11 | 12 | True 13 | False 14 | DecisionServicePrivateWeb.zip 15 | true 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /mc/Properties/PublishProfiles/arm.pubxml.user: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /mc/Properties/PublishProfiles/mc-mcdel5spqfpsfzclank - Web Deploy.pubxml: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | MSDeploy 9 | AzureWebSite 10 | Release 11 | x64 12 | http://mc-mcdel5spqfpsfzclank.azurewebsites.net 13 | True 14 | False 15 | mc-mcdel5spqfpsfzclank.scm.azurewebsites.net:443 16 | mc-mcdel5spqfpsfzclank 17 | 18 | True 19 | WMSVC 20 | True 21 | $mc-mcdel5spqfpsfzclank 22 | <_SavePWD>True 23 | <_DestinationType>AzureWebSite 24 | 25 | -------------------------------------------------------------------------------- /mc/Scripts/site.js: -------------------------------------------------------------------------------- 1 | $(function () { 2 | AddAntiForgeryToken = function (data) { 3 | data.__RequestVerificationToken = $('input[name=__RequestVerificationToken]').val(); 4 | return data; 5 | }; 6 | 7 | $('.helptext-on-interaction').click(function () { 8 | $('div[id^="div-sv-"]').hide(); 9 | $('#div-sv-' + this.id).fadeIn(); 10 | }); 11 | 12 | $('.ds-form').on('click', '.resetter', function () { 13 | var reset = confirm("Are you sure you want to reset?"); 14 | if (reset == true) { 15 | $this = $(this); 16 | var relatedInputId = $this.attr("name"); 17 | var relatedInputValue = $("#" + relatedInputId).val(); 18 | $.ajax({ 19 | url: '/Home/Reset/', 20 | type: "POST", 21 | data: AddAntiForgeryToken({ 22 | inputId: relatedInputId, 23 | inputValue: relatedInputValue 24 | }), 25 | dataType: "html", 26 | cache: false, 27 | success: function (data) { 28 | alert("Reset completed successfully."); 29 | }, 30 | error: function (jqXHR, textStatus, errorThrown) { 31 | alert("Reset failed due to internal server error, check Application Insights for more details."); 32 | } 33 | }); 34 | }; 35 | }); 36 | }) -------------------------------------------------------------------------------- /mc/Validations/UnitIntervalAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Web; 6 | 7 | namespace DecisionServicePrivateWeb.Validations 8 | { 9 | public class UnitIntervalAttribute : ValidationAttribute 10 | { 11 | public override bool IsValid(object value) 12 | { 13 | if (value == null) 14 | { 15 | return false; 16 | } 17 | float floatValue = -1; 18 | bool isFloat = float.TryParse(value.ToString(), out floatValue); 19 | 20 | return isFloat && floatValue >= 0 && floatValue <= 1; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /mc/Views/Home/Evaluation.cshtml: -------------------------------------------------------------------------------- 1 | @using DecisionServicePrivateWeb.Models 2 | @using DecisionServicePrivateWeb.Controllers 3 | @model EvaluationViewModel 4 | @{ 5 | ViewBag.Title = "Evaluation Dashboard"; 6 | } 7 |

@ViewBag.Title

8 | 9 |
10 |
11 | 12 |
13 | @Html.DropDownList("eval-window-filter", 14 | Model.WindowFilters.Select(m => new SelectListItem 15 | { 16 | Value = m, 17 | Text = m, 18 | Selected = (m == Model.SelectedFilter) 19 | }), 20 | new { @id = "eval-window-filter", @class = "form-control", @style = "display:inline" }) 21 |
22 |
23 |
24 | 25 |
26 |
27 | 28 | @section styles { 29 | 30 | } 31 | 32 | @section scripts { 33 | 34 | 35 | 36 | 37 | } -------------------------------------------------------------------------------- /mc/Views/Shared/_LoginPartial.cshtml: -------------------------------------------------------------------------------- 1 | @using DecisionServicePrivateWeb.Controllers 2 | @if (HomeController.IsAuthenticated(Session)) 3 | { 4 | using (Html.BeginForm("LogOff", "Home", FormMethod.Post, new { id = "logoutForm", @class = "navbar-right" })) 5 | { 6 | @Html.AntiForgeryToken() 7 | 10 | } 11 | } 12 | else 13 | { 14 | 17 | } 18 | -------------------------------------------------------------------------------- /mc/Views/Shared/_OpenSvg.cshtml: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /mc/Views/Shared/_ResetSvg.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /mc/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "~/Views/Shared/_Layout.cshtml"; 3 | } -------------------------------------------------------------------------------- /mc/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /mc/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /mc/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/mwt-ds/86f552e7a592df6fb41e46e22f3473088660612e/mc/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /mc/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/mwt-ds/86f552e7a592df6fb41e46e22f3473088660612e/mc/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /mc/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/mwt-ds/86f552e7a592df6fb41e46e22f3473088660612e/mc/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /provisioning/WebLoadTesting/PolicyDecision.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace WebLoadTesting 8 | { 9 | public class PolicyDecision 10 | { 11 | public string EventId { get; set; } 12 | 13 | public int Action { get; set; } 14 | 15 | public string ModelTime { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /provisioning/WebLoadTesting/ProbabilisticConditional.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.WebTesting; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace WebLoadTesting 9 | { 10 | public class ProbabilisticConditional : ConditionalRule 11 | { 12 | public float SuccessProbability { get; set; } 13 | 14 | public override void CheckCondition(object sender, ConditionalEventArgs e) 15 | { 16 | e.IsMet = new Random().NextDouble() < SuccessProbability; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /provisioning/WebLoadTesting/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("WebLoadTesting")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("WebLoadTesting")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("45198b1a-bc39-4883-b828-289e935b70c1")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /provisioning/WebLoadTesting/ResponseConditional.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.WebTesting; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace WebLoadTesting 9 | { 10 | public class ResponseConditional : ConditionalRule 11 | { 12 | public float InconsistencyProbability { get; set; } 13 | 14 | public int ExpectedAction { get; set; } 15 | 16 | public override void CheckCondition(object sender, ConditionalEventArgs e) 17 | { 18 | if (e.WebTest.LastRequestOutcome != Outcome.Pass) 19 | { 20 | e.IsMet = false; 21 | return; 22 | } 23 | var action = (int)e.WebTest.Context["Action"]; 24 | var reportReward = action == this.ExpectedAction; 25 | 26 | if (new Random().NextDouble() < this.InconsistencyProbability) 27 | reportReward = !reportReward; 28 | 29 | e.IsMet = reportReward; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /provisioning/WebLoadTesting/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /provisioning/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "itemDisplayName": "Decision Service", 3 | "description": "This template creates a Multiworld-Testing Decision Service.", 4 | "summary": "Decision Service", 5 | "githubUsername": eisber 6 | "dateUpdated": "2016-06-27" 7 | } -------------------------------------------------------------------------------- /provisioning/templates/AppInsightsTemplate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "postfix": { "type": "string" } 6 | }, 7 | "variables": { 8 | "name": "[concat('appinsights-', parameters('postfix'))]" 9 | }, 10 | "resources": [ 11 | { 12 | "apiVersion": "2014-04-01", 13 | "type": "Microsoft.Insights/components", 14 | "name": "[variables('name')]", 15 | "location": "eastus", 16 | "properties": { 17 | "mode": "incremental", 18 | "ApplicationId": "[concat('appinsights-', parameters('postfix'))]" 19 | } 20 | } 21 | ], 22 | "outputs": { 23 | "InstrumentationKey": { 24 | "type": "string", 25 | "value": "[reference(concat('microsoft.insights/components/', variables('name')), '2014-04-01').InstrumentationKey]" 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /provisioning/templates/DeploymentFinished.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "data": { "type": "object" } 6 | }, 7 | "resources": [ 8 | { 9 | "apiVersion": "2015-01-01", 10 | "name": "DeploymentFinished_Deployment", 11 | "type": "Microsoft.Resources/deployments", 12 | "properties": { 13 | "mode": "incremental", 14 | "templateLink": { 15 | "uri": "[concat('http://mwtds.azurewebsites.net/DeploymentFinish/template?p=', base64(string(parameters('data'))))]", 16 | "contentVersion": "1.0.0.0" 17 | } 18 | } 19 | } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /provisioning/templates/EmptyTemplate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "resources": [ ] 5 | } -------------------------------------------------------------------------------- /provisioning/templates/EventHubNamespaceTemplate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "MB/s": { 6 | "type": "int", 7 | "minValue": 1, 8 | "maxValue": 20 9 | }, 10 | "postfix": { 11 | "type": "string", 12 | // maximum name length is 63 - len('sb-') = 60 13 | // name restrictions: https://msdn.microsoft.com/en-us/library/azure/jj856303.aspx 14 | "maxLength": 47 15 | }, 16 | "location": { "type": "string" } 17 | }, 18 | "variables": { 19 | "sbName": "[concat('sb-', parameters('postfix'))]", 20 | "sbKeyName": "OwnerKey" 21 | }, 22 | "resources": [ 23 | { 24 | "apiVersion": "2015-08-01", 25 | "name": "[variables('sbName')]", 26 | "type": "Microsoft.EventHub/namespaces", 27 | "location": "[parameters('location')]", 28 | "sku": { 29 | "name": "Standard", 30 | "tier": "Standard", 31 | "capacity": "[parameters('MB/s')]" 32 | } 33 | } 34 | ], 35 | "outputs": { 36 | "EventHubNamespaceName": { 37 | "value": "[variables('sbName')]", 38 | "type": "string" 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /provisioning/templates/OnlineTrainerEmptyTemplate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schema.management.azure.com/schemas/2015-01-01-preview/deploymentTemplate.json", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "postfix": { 6 | "type": "string", 7 | // maximum name length is 63 - len('trainer-') = 55 8 | "maxLength": 55 9 | }, 10 | "location": { "type": "string" } 11 | }, 12 | "variables": { 13 | "name": "[concat('trainer-', parameters('postfix'))]" 14 | }, 15 | "resources": [ 16 | { 17 | "apiVersion": "2014-06-01", 18 | "type": "Microsoft.ClassicCompute/domainNames", 19 | "name": "[variables('name')]", 20 | "location": "[parameters('location')]" 21 | } 22 | ], 23 | "outputs": { 24 | "name": { 25 | "type": "string", 26 | "value": "[variables('name')]" 27 | }, 28 | "url": { 29 | "type": "string", 30 | "value": "[concat('http://',variables('name'), '.cloudapp.net')]" 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /provisioning/templates/OnlineTrainerTemplate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schema.management.azure.com/schemas/2015-01-01-preview/deploymentTemplate.json", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "onlineTrainerCspkgToken": { "type": "string" }, 6 | "configLink": { "type": "string" }, 7 | "name": { "type": "string" }, 8 | "location": { "type": "string" } 9 | }, 10 | "resources": [ 11 | { 12 | // this API is not supported 13 | "apiVersion": "2014-06-01", 14 | "type": "Microsoft.ClassicCompute/domainNames", 15 | "name": "[parameters('name')]", 16 | "location": "[parameters('location')]", 17 | "resources": [ 18 | { 19 | "apiVersion": "2014-06-01", 20 | "name": "production", 21 | "type": "deploymentSlots", 22 | "dependsOn": [ 23 | "[resourceId('Microsoft.ClassicCompute/domainNames', parameters('name'))]" 24 | ], 25 | "properties": { 26 | "packageLink": { 27 | "uri": "[parameters('onlineTrainerCspkgToken')]" 28 | }, 29 | "deploymentLabel": "[parameters('name')]", 30 | "ConfigurationLink": { 31 | "uri": "[parameters('configLink')]" 32 | }, 33 | "deploymentOptions": "StartDeployment" 34 | } 35 | } 36 | ] 37 | } 38 | ] 39 | } -------------------------------------------------------------------------------- /provisioning/templates/SecureSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "webManageUri": { "type": "string" }, 6 | "json": { "type": "object" } 7 | }, 8 | "resources": [ 9 | { 10 | "apiVersion": "2015-01-01", 11 | "name": "SecureSettings", 12 | "type": "Microsoft.Resources/deployments", 13 | "dependsOn": [ 14 | "Microsoft.Resources/deployments/WebManage" 15 | ], 16 | "properties": { 17 | "mode": "incremental", 18 | "templateLink": { "uri": "[concat(parameters('webManageUri'), '/Deployment/GenerateSASToken?parameters=key=', )]" } 19 | } 20 | } 21 | ], 22 | "outputs": { 23 | "outputs": { 24 | "type": "object", 25 | "value": "[reference('Microsoft.Resources/deployments/SecureSettings').outputs]" 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /provisioning/templates/WebSourceControlTemplate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "postfix": { 6 | "type": "string", 7 | // maximum name length is 63 - len('mc-') = 60 8 | "maxLength": 60 9 | } 10 | }, 11 | "variables": { 12 | "siteName": "[concat('mc-', parameters('postfix'))]" 13 | }, 14 | "resources": [ 15 | { 16 | "apiVersion": "2015-08-01", 17 | "name": "[variables('siteName')]", 18 | "type": "Microsoft.Web/sites", 19 | "location": "[resourceGroup().location]", 20 | "properties": { 21 | "serverFarmId": "ManagementPlan" 22 | }, 23 | "resources": [ 24 | { 25 | "apiVersion": "2015-08-01", 26 | "name": "web", 27 | "type": "sourcecontrols", 28 | "dependsOn": [ 29 | "[resourceId('Microsoft.Web/Sites', variables('siteName'))]" 30 | ], 31 | "properties": { 32 | "RepoUrl": "https://github.com/Microsoft/mwt-ds-management-center.git", 33 | "branch": "master", 34 | "IsManualIntegration": true 35 | } 36 | } 37 | ] 38 | } 39 | ] 40 | } -------------------------------------------------------------------------------- /provisioning/test/Local.testsettings: -------------------------------------------------------------------------------- 1 |  2 | 3 | These are default test settings for a local test run. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 |
18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /provisioning/test/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ds-provisioning")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ds-provisioning")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("26167826-af8e-47d8-95bc-ca6b6ca9808f")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /provisioning/validate.ps1: -------------------------------------------------------------------------------- 1 | Import-AzureRM 2 | Import-Module Azure 3 | 4 | Add-AzureRmAccount 5 | --------------------------------------------------------------------------------