예제 #1
0
        static async void LogRun(int experimentId, ExperimentResult <MulticlassClassificationMetrics> experimentResults)
        {
            // Define run
            var runObject = new CreateRunRequest();

            runObject.ExperimentId = experimentId;
            runObject.StartTime    = ((DateTimeOffset)DateTime.UtcNow).ToUnixTimeMilliseconds();
            runObject.UserId       = Environment.UserName;
            runObject.SourceType   = SourceType.LOCAL;

            // Create new run in MLFlow
            var runRequest = await _mlFlowService.CreateRun(runObject);

            // Get information for best run
            var runDetails = experimentResults.BestRun;

            // Log trainer name
            await _mlFlowService.LogParameter(runRequest.Run.Info.RunUuid, nameof(runDetails.TrainerName), runDetails.TrainerName);

            // Log metrics
            await _mlFlowService.LogMetric(runRequest.Run.Info.RunUuid, nameof(runDetails.RuntimeInSeconds), (float)runDetails.RuntimeInSeconds);

            await _mlFlowService.LogMetric(runRequest.Run.Info.RunUuid, nameof(runDetails.ValidationMetrics.LogLoss), (float)runDetails.ValidationMetrics.LogLoss);

            await _mlFlowService.LogMetric(runRequest.Run.Info.RunUuid, nameof(runDetails.ValidationMetrics.MacroAccuracy), (float)runDetails.ValidationMetrics.MacroAccuracy);

            await _mlFlowService.LogMetric(runRequest.Run.Info.RunUuid, nameof(runDetails.ValidationMetrics.MicroAccuracy), (float)runDetails.ValidationMetrics.MicroAccuracy);
        }
예제 #2
0
        private async Task <RunResponse> CreateRun(int experimentId, string runName)
        {
            var userId         = "rian finnegan";
            var sourceType     = SourceType.LOCAL;
            var sourceName     = "My laptop";
            var entryPointName = "cli.Program.cs";
            var startTime      = ((DateTimeOffset)DateTime.UtcNow).ToUnixTimeSeconds(); //unix timestamp


            RunTag[] tags = { new RunTag()
                              {
                                  Key = "test_runner", Value = "No_Regressions"
                              } };

            var createRunRequest = new CreateRunRequest()
            {
                ExperimentId   = experimentId,
                UserId         = userId,
                Runname        = runName,
                SourceType     = sourceType,
                SourceName     = sourceName,
                EntryPointName = entryPointName,
                StartTime      = startTime,
                SourceVersion  = "d1f3ba3c",
                Tags           = tags
            };

            return(await mlflowService.CreateRun(createRunRequest));
        }
예제 #3
0
        public async Task <IActionResult> Index()
        {
            var newExperiment = await this.flowService.GetOrCreateExperiment("New_Experiement");

            var experimentId = newExperiment.ExperimentId;

            var userId         = "azadeh khojandi";
            var runName        = "this is a run name";
            var sourceType     = SourceType.NOTEBOOK;
            var sourceName     = "String descriptor for the run’s source";
            var entryPointName = "Name of the project entry point associated with the current run, if any.";
            var startTime      = ((DateTimeOffset)DateTime.UtcNow).ToUnixTimeMilliseconds(); //unix timestamp



            RunTag[] tags = { new RunTag()
                              {
                                  Key = "testkey", Value = "testvalue"
                              } };

            var createRunRequest = new CreateRunRequest()
            {
                ExperimentId   = experimentId,
                UserId         = userId,
                Runname        = runName,
                SourceType     = sourceType,
                SourceName     = sourceName,
                EntryPointName = entryPointName,
                StartTime      = startTime,
                Tags           = tags
            };

            var runResult = await flowService.CreateRun(createRunRequest);

            var logResultMetric = await flowService
                                  .LogMetric(
                runResult.Run.Info.RunUuid,
                "Somekey", 1234);

            var logResultParam = await flowService
                                 .LogParameter(
                runResult.Run.Info.RunUuid,
                "Somekey", "some parameter");

            ViewData["ExperimentId"] = experimentId;
            ViewData["RunId"]        = runResult.Run.Info.RunUuid;

            return(View());
        }
예제 #4
0
        public async Task <RunResponse> _createRun(int experiementId, IMLFlowService flowService)
        {
            var experimentId = experiementId;
            var userId       = "azadeh khojandi";
            var runName      = "this is a run name";
            var sourceType   = SourceType.NOTEBOOK;
            var sourceName   = "String descriptor for the run’s source";

            var entryPointName = "Name of the project entry point associated with the current run, if any.";
            var startTime      = ((DateTimeOffset)DateTime.UtcNow).ToUnixTimeSeconds(); //unix timestamp


            var path          = Directory.GetCurrentDirectory();
            var repopath      = path.Substring(0, path.IndexOf("src", StringComparison.Ordinal));
            var repo          = new Repository(repopath);
            var lastcommit    = repo.Commits.Last();
            var sourceVersion = lastcommit.Sha;


            RunTag[] tags = { new RunTag()
                              {
                                  Key = "testkey", Value = "testvalue"
                              } };

            //todo [az] run name is empty - check mlflow source code
            //todo [az] unix startTime not showing correct time on the UI

            var createRunRequest = new CreateRunRequest()
            {
                ExperimentId   = experimentId,
                UserId         = userId,
                Runname        = runName,
                SourceType     = sourceType,
                SourceName     = sourceName,
                EntryPointName = entryPointName,
                StartTime      = startTime,
                SourceVersion  = sourceVersion,
                Tags           = tags
            };

            var runResult = await flowService.CreateRun(
                createRunRequest);

            return(runResult);
        }