private static AzureBenchmarkResult ToAzureResult(BenchmarkResult b, AzureBenchmarkResult externalOutput) { AzureBenchmarkResult azureResult = AzureExperimentStorage.ToAzureBenchmarkResult(b); if (externalOutput != null) { azureResult.StdOut = externalOutput.StdOut; azureResult.StdOutExtStorageIdx = externalOutput.StdOutExtStorageIdx; azureResult.StdErr = externalOutput.StdErr; azureResult.StdErrExtStorageIdx = externalOutput.StdErrExtStorageIdx; } else { b.StdOut.Position = 0; azureResult.StdOut = Utils.StreamToString(b.StdOut, true); azureResult.StdOutExtStorageIdx = string.Empty; b.StdErr.Position = 0; azureResult.StdErr = Utils.StreamToString(b.StdErr, true); azureResult.StdErrExtStorageIdx = string.Empty; } return(azureResult); }
public static AzureExperimentManager Open(string connectionString) { var cs = new BatchConnectionString(connectionString); string batchAccountName = cs.BatchAccountName; string batchUrl = cs.BatchURL; string batchAccessKey = cs.BatchAccessKey; cs.RemoveKeys(BatchConnectionString.KeyBatchAccount, BatchConnectionString.KeyBatchURL, BatchConnectionString.KeyBatchAccessKey); string storageConnectionString = cs.ToString(); AzureExperimentStorage storage = new AzureExperimentStorage(storageConnectionString); if (batchAccountName != null) { return(Open(storage, batchUrl, batchAccountName, batchAccessKey)); } return(OpenWithoutStart(storage)); }
public AzureExperimentResults(AzureExperimentStorage storage, int expId, AzureBenchmarkResult[] results, string etag) : base(expId, Parse(results, storage)) { this.expId = expId; this.storage = storage; this.etag = etag; var benchmarks = Benchmarks; externalOutputs = new Dictionary <BenchmarkResult, AzureBenchmarkResult>(); for (int i = 0; i < results.Length; i++) { var r = results[i]; if (!string.IsNullOrEmpty(r.StdOutExtStorageIdx) || !string.IsNullOrEmpty(r.StdErrExtStorageIdx)) { externalOutputs.Add(benchmarks[i], r); } } }
private static BenchmarkResult[] Parse(AzureBenchmarkResult[] results, AzureExperimentStorage storage) { if (storage == null) { throw new ArgumentNullException(nameof(storage)); } if (results == null) { throw new ArgumentNullException(nameof(results)); } int n = results.Length; BenchmarkResult[] benchmarks = new BenchmarkResult[n]; for (int i = 0; i < n; i++) { benchmarks[i] = storage.ParseAzureBenchmarkResult(results[i]); } return(benchmarks); }
public AzureSummaryManager(string storageConnectionString, IDomainResolver domainResolver) { if (domainResolver == null) { throw new ArgumentNullException(nameof(domainResolver)); } var cs = new StorageAccountConnectionString(storageConnectionString).ToString(); storage = new AzureExperimentStorage(cs); storageAccount = CloudStorageAccount.Parse(cs); blobClient = storageAccount.CreateCloudBlobClient(); summaryContainer = blobClient.GetContainerReference(summaryContainerName); var cloudEntityCreationTasks = new Task[] { summaryContainer.CreateIfNotExistsAsync() }; resolveDomain = domainResolver; Task.WaitAll(cloudEntityCreationTasks); }
/// <summary> /// Creates a manager in a mode when it can open data but not start new experiments. /// </summary> public static AzureExperimentManager OpenWithoutStart(AzureExperimentStorage storage) { return(new AzureExperimentManager(storage)); }
public static AzureExperimentManager Open(AzureExperimentStorage storage, string batchUrl, string batchAccName, string batchKey) { return(new AzureExperimentManager(storage, batchUrl, batchAccName, batchKey)); }
public static async Task <AzureExperimentManager> New(AzureExperimentStorage storage, ReferenceExperiment reference, string batchUrl, string batchAccName, string batchKey) { await storage.SaveReferenceExperiment(reference); return(new AzureExperimentManager(storage, batchUrl, batchAccName, batchKey)); }
protected AzureExperimentManager(AzureExperimentStorage storage) { this.storage = storage; this.batchCreds = null; this.BatchPoolID = DefaultPoolID; }
protected AzureExperimentManager(AzureExperimentStorage storage, string batchUrl, string batchAccName, string batchKey) { this.storage = storage; this.batchCreds = new BatchSharedKeyCredentials(batchUrl, batchAccName, batchKey); this.BatchPoolID = DefaultPoolID; }
public override async Task <bool> TryDelete(IEnumerable <BenchmarkResult> toRemove) { if (toRemove == null) { throw new ArgumentNullException(nameof(toRemove)); } var benchmarks = Benchmarks; var removeSet = new HashSet <BenchmarkResult>(toRemove); if (removeSet.Count == 0) { return(true); } int n = benchmarks.Length; List <AzureBenchmarkResult> newAzureResults = new List <AzureBenchmarkResult>(n); List <BenchmarkResult> newResults = new List <BenchmarkResult>(n); List <AzureBenchmarkResult> deleteOuts = new List <AzureBenchmarkResult>(); for (int i = 0; i < n; i++) { var b = benchmarks[i]; if (!removeSet.Contains(b)) // remains { var azureResult = AzureExperimentStorage.ToAzureBenchmarkResult(b); newAzureResults.Add(azureResult); newResults.Add(b); } else // to be removed { removeSet.Remove(b); AzureBenchmarkResult ar; if (externalOutputs.TryGetValue(b, out ar)) { deleteOuts.Add(ar); } } } if (removeSet.Count != 0) { throw new ArgumentException("Some of the given results to remove do not belong to the experiment results"); } // Updating blob with results table bool success = await Upload(newAzureResults.ToArray()); if (!success) { return(false); } // Update benchmarks array Replace(newResults.ToArray()); // Deleting blobs with output foreach (var ar in deleteOuts) { try { var _ = storage.DeleteOutputs(ar); } catch (Exception ex) { Trace.WriteLine(string.Format("Exception when deleting output: {0}", ex)); } } return(true); }
public override async Task <Dictionary <BenchmarkResult, BenchmarkResult> > TryUpdateStatus(IEnumerable <BenchmarkResult> toModify, ResultStatus status) { if (toModify == null) { throw new ArgumentNullException(nameof(toModify)); } var mod = new Dictionary <BenchmarkResult, BenchmarkResult>(); foreach (var oldRes in toModify) { mod.Add(oldRes, null); } if (mod.Count == 0) { return(mod); } int n = Benchmarks.Length; var newBenchmarks = (BenchmarkResult[])Benchmarks.Clone(); var newAzureBenchmarks = new AzureBenchmarkResult[n]; for (int i = 0; i < n; i++) { var b = newBenchmarks[i]; if (mod.ContainsKey(b)) { if (b.Status != status) // updating status of this result { newBenchmarks[i] = new BenchmarkResult(b.ExperimentID, b.BenchmarkFileName, b.AcquireTime, b.NormalizedRuntime, b.TotalProcessorTime, b.WallClockTime, b.PeakMemorySizeMB, status, // <-- new status b.ExitCode, b.StdOut, b.StdErr, b.Properties); newAzureBenchmarks[i] = AzureExperimentStorage.ToAzureBenchmarkResult(newBenchmarks[i]); mod[b] = newBenchmarks[i]; } else // status is as required already { newAzureBenchmarks[i] = AzureExperimentStorage.ToAzureBenchmarkResult(b); mod.Remove(b); } } else // result doesn't change { newAzureBenchmarks[i] = AzureExperimentStorage.ToAzureBenchmarkResult(b); } } if (mod.Count == 0) { return(new Dictionary <BenchmarkResult, BenchmarkResult>()); // no changes } foreach (var item in mod) { if (item.Value == null) { throw new ArgumentException("Some of the given results to update do not belong to the experiment results"); } } bool success = await Upload(newAzureBenchmarks); if (!success) { return(null); } // Update benchmarks array Replace(newBenchmarks.ToArray()); return(mod); }