public void StartWizard(Experiment experimentToBeBenchmarked) { if (experimentToBeBenchmarked == null) throw new InvalidOperationException("Benchmark cannot be run with null experiment."); //if webservice is set access webservice, and load benchmarks from there... on OnRetrieveListOfBenchmarksCallCompleted will load load also local benchmarks //and discover those that are online contests if (m_settings.WebserviceAddress != null) { m_webService = new WebserviceAccessor(m_settings.WebserviceAddress, true); if (m_webService != null) { var listOfContestsCallback = new Callback<ListOfContestsResponse>(); listOfContestsCallback.CallCompleted += OnRetrieveListOfBenchmarksCallCompleted; m_webService.RetrieveListOfContests(listOfContestsCallback); } else { //load only local benchmarks Benchmarks = BenchmarkLoader.LoadBenchmarksInfo(BenchmarksDirectory); } } else { //load only local benchmarks Benchmarks = BenchmarkLoader.LoadBenchmarksInfo(BenchmarksDirectory); } ExperimentToBeBenchmarked = experimentToBeBenchmarked; }
/// <summary> /// Clones this experiment. /// </summary> /// <returns></returns> public override BaseExperiment Clone() { Experiment clone = new Experiment(); clone.CopyFrom(this); clone.ResetModifiedFlag(); return clone; }
internal static bool NewExperimantDialog (Window parentWindow, ref Experiment experiment) { var newExperimentDialog = new NewExperimentDialog(ref experiment); newExperimentDialog.Run(); return newExperimentDialog.Results; }
public PackageBuilderViewModel(Experiment originalExperiment, Dictionary<string, Type> supportedTypes) { //clone current experiment m_experiment = originalExperiment.Clone() as Experiment; m_supportedTypes = supportedTypes; this.ExperimentPackageConfig = new ExperimentPackageConfig(); CurrentState = PackageBuilderWizardPage.Config; }
/// <summary> /// Initializes a new instance of the <see cref="DefiningCompositeComponentSetup"/> class. /// </summary> /// <param name="experiment">The experiment.</param> public DefiningCompositeComponentSetup(Experiment experiment) { CompositeComponentGraph = CompositeComponentGraph.ConstructGraphFromSelectedNodes(experiment); InputSettings = new SortedDictionary<string, ItemSetting>(); OutputSettings = new SortedDictionary<string, ItemSetting>(); ConfigSettings = new SortedDictionary<string, ConfigItemSetting>(); TraceLab.Core.Utilities.ExperimentHelper.BFSTraverseExperiment(CompositeComponentGraph, CompositeComponentGraph.StartNode, RetrieveIOSpecAndConfig); }
public static ApplicationViewModel CreateNewApplicationViewModel(ApplicationViewModel context, Experiment experiment) { ApplicationViewModel newApplicationViewModel = new ApplicationViewModel(context.Workspace); newApplicationViewModel.ComponentLibraryViewModel = context.ComponentLibraryViewModel.Clone(); newApplicationViewModel.Settings = context.Settings.Clone(); newApplicationViewModel.BenchmarkWizard = context.BenchmarkWizard; newApplicationViewModel.Experiment = experiment; newApplicationViewModel.WorkspaceViewModel = new WorkspaceViewModel(newApplicationViewModel.Workspace, experiment.ExperimentInfo.Id); newApplicationViewModel.LogViewModel = new LogViewModel(newApplicationViewModel.Experiment.ExperimentInfo.Id, context.LogViewModel); return newApplicationViewModel; }
/// <summary> /// Creates new m_experiment. /// </summary> /// <returns>Returns newly created m_experiment.</returns> public static Experiment New() { Experiment newExperiment = new Experiment(NewExperimentName, string.Empty); ExperimentStartNode start = new ExperimentStartNode(); start.Data.X = 200; start.Data.Y = 100; newExperiment.AddVertex(start); ExperimentEndNode end = new ExperimentEndNode(); end.Data.X = 200; end.Data.Y = 200; newExperiment.AddVertex(end); newExperiment.ReloadStartAndEndNode(); newExperiment.ResetModifiedFlag(); return newExperiment; }
// END HERZUM SPRINT 3.1 TLAB-180 /// <summary> /// Initializes a new instance of the <see cref="DefiningCompositeComponentSetup"/> class. /// </summary> /// <param name="experiment">The experiment.</param> public DefiningCompositeComponentSetup(Experiment experiment) { // HERZUM SPRINT 2.4 TLAB-157 // CompositeComponentGraph = CompositeComponentGraph.ConstructGraphFromSelectedNodes(experiment); CompositeComponentGraph = CompositeComponentGraph.ConstructEmptyGraph(); // HERZUM SPRINT 3.1 TLAB-180 // CompositeComponentGraph.CopyAndAdd (CompositeComponentGraph.ConstructGraphFromSelectedNodes (experiment), 200.0, 200.0); ConstructGraphFromSelectedScopeNodes (experiment); // END HERZUM SPRINT 3.1 TLAB-180 CompositeComponentGraph.ConnectNodesToStartAndEndNode(CompositeComponentGraph); // END HERZUM SPRINT 2.4 TLAB-157 InputSettings = new SortedDictionary<string, ItemSetting>(); OutputSettings = new SortedDictionary<string, ItemSetting>(); ConfigSettings = new SortedDictionary<string, ConfigItemSetting>(); TraceLab.Core.Utilities.ExperimentHelper.BFSTraverseExperiment(CompositeComponentGraph, CompositeComponentGraph.StartNode, RetrieveIOSpecAndConfig); }
/// <summary> /// Initializes a new instance of the <see cref="DefiningBenchmark"/> class. /// </summary> /// <param name="baseExperiment">The base experiment represents experiment based on which the benchmark is being defined.</param> public DefiningBenchmark(Experiment baseExperiment, ComponentsLibrary library, Workspace workspace, PackageSystem.PackageManager manager, IEnumerable<string> workspaceTypeDirectories, string webserviceAddress) { if (baseExperiment == null) throw new ArgumentNullException("baseExperiment"); if (library == null) throw new ArgumentNullException("library"); if (workspace == null) throw new ArgumentNullException("workspace"); if (workspaceTypeDirectories == null) throw new ArgumentNullException("workspaceTypeDirectories"); // these are needed to create experiment serializing in Define method m_packageManager = manager; m_library = library; WebserviceAddress = webserviceAddress; if (webserviceAddress != null) { m_webService = new WebserviceAccessor(webserviceAddress, true); } m_baseExperiment = baseExperiment; m_workspace = workspace; //wrap the workspace into experiment workspace wrapper, so that we can load units only from experiment namespace m_experimentWorkspaceWrapper = new ExperimentWorkspaceWrapper(workspace, m_baseExperiment.ExperimentInfo.Id); //prefil benchmark info PrefillBenchmarkInfo(); //get nodes that can be selected as template GetTemplatizableComponents(); //get the ExperimentResults variables that can be selected as publishable results //from the ExperimentResults all metric names, their descriptions and dataset names are going to be extracted //when contest is going to be published GetPublishableExperimentResults(); }
/// <summary> /// Construct the experiment from given xml path navigator to root experiment graph element. /// It also reads in Experiment Info. /// </summary> /// <param name="reader">The reader.</param> /// <returns></returns> public virtual Experiment GraphFactory(XPathNavigator reader) { Experiment flow = new Experiment(); XPathNavigator experimentInfo = reader.SelectSingleNode("ExperimentInfo"); if (experimentInfo != null) { var experimentInfoSerializer = TraceLab.Core.Serialization.XmlSerializerFactory.GetSerializer(typeof(ExperimentInfo), null); flow.ExperimentInfo = (ExperimentInfo)experimentInfoSerializer.Deserialize(experimentInfo.ReadSubtree()); } else { flow.ExperimentInfo = new ExperimentInfo(); flow.ExperimentInfo.Author = "<Author>"; flow.ExperimentInfo.Name = "<Experiment name>"; flow.ExperimentInfo.Contributors = "<Contributors>"; flow.ExperimentInfo.Description = "<Description>"; experimentGuid = flow.ExperimentInfo.Id; } return flow; }
public NewExperimentDialog (ref Experiment experiment) { _experiment = experiment; this.Build (); }
/// <summary> /// Prepares the benchmark experiment. /// </summary> /// <param name="experimentToBeBenchmarked">The experiment to be benchmarked.</param> /// <exception cref="TraceLab.Core.Exceptions.ExperimentLoadException">throws if experiment load fails</exception> /// <param name="library">The library.</param> public void PrepareBenchmarkExperiment(Experiment experimentToBeBenchmarked, ComponentsLibrary library) { //load benchmark experiment Experiment benchmarkExperiment = ExperimentManager.Load(BenchmarkInfo.FilePath, library); //update benchmark experiment info, so that it refers to the same benchmark info (LoadExperiment would not read BenchmarkInfo, as it only reads ExperimentInfo) benchmarkExperiment.ExperimentInfo = BenchmarkInfo; //2. find template node to be replaced ExperimentNode templateNode = null; foreach (ExperimentNode node in benchmarkExperiment.Vertices) { if (node.Data.Metadata is ComponentTemplateMetadata) { templateNode = node; break; } } if (templateNode == null) throw new TraceLab.Core.Exceptions.BenchmarkException("Template node has not been found in the benchmark experiment. The benchmark experiment is corrupted."); //3. export current experiment into composite component foreach (BenchmarkItemSetting<IOItem> item in BenchmarkInputSetting) { item.SelectedSetting.Include = true; } foreach (BenchmarkItemSetting<IOItem> item in BenchmarkOutputsSetting) { item.SelectedSetting.Include = true; } //create temporary component source - note it is just a assembly source name file to satisfy Metadata Assembly requirement //the file is not going to be created (this is UGLY - do refactoring) string tempSource = System.IO.Path.Combine(BenchmarkInfo.FilePath, "temporary"); m_setup.CompositeComponentLocationFilePath = tempSource; CompositeComponentMetadataDefinition definition = m_setup.GenerateCompositeComponentDefinition(); //4. Replace template node by removing it from graph, adding the new node, and reconnecting new not //Add composite component node ExperimentNode replacementNode = benchmarkExperiment.AddComponentFromDefinition(definition, templateNode.Data.X, templateNode.Data.Y); //connect replacement node to the same outgoing nodes as template node foreach (ExperimentNodeConnection nodeConnection in benchmarkExperiment.OutEdges(templateNode)) { benchmarkExperiment.AddConnection(replacementNode, nodeConnection.Target); } //connect replacement node to the same incoming nodes as template node foreach (ExperimentNodeConnection nodeConnection in benchmarkExperiment.InEdges(templateNode)) { benchmarkExperiment.AddConnection(nodeConnection.Source, replacementNode); //if the predecessor is a decision node update its decision code so that it matches new label FixDecisionCode(templateNode.Data.Metadata.Label, replacementNode.Data.Metadata.Label, nodeConnection.Source as ExperimentDecisionNode); } //finally remove the template node benchmarkExperiment.RemoveVertex(templateNode); //now remap io according to settings CompositeComponentMetadata compositeComponentDefinition = (CompositeComponentMetadata)replacementNode.Data.Metadata; foreach (BenchmarkItemSetting<IOItem> item in BenchmarkInputSetting) { item.SelectedSetting.Include = true; compositeComponentDefinition.IOSpec.Input[item.SelectedSetting.ItemSettingName].MappedTo = item.Item.MappedTo; } foreach (BenchmarkItemSetting<IOItem> item in BenchmarkOutputsSetting) { item.SelectedSetting.Include = true; compositeComponentDefinition.IOSpec.Output[item.SelectedSetting.ItemSettingName].MappedTo = item.Item.MappedTo; } BenchmarkExperiment = benchmarkExperiment; }
/// <summary> /// Save as allows saving experiment in different location with referenced files copied. /// </summary> /// <param name="experiment">The experiment.</param> /// <param name="fileName">Name of the file.</param> /// <param name="referencedFilesProcessing">The referenced files processing.</param> /// <returns></returns> public static bool SaveAs(Experiment experiment, string fileName, ReferencedFiles referencedFilesProcessing) { if (fileName == null) { throw new ArgumentNullException("fileName"); } string oldExperimentFilePath = experiment.ExperimentInfo.FilePath; bool success = false; try { //update its FilePath info to the new file location experiment.ExperimentInfo.FilePath = fileName; if (referencedFilesProcessing == ReferencedFiles.KEEPREFERENCE) { //Filepath of experiment has changed so update all referenced files before saving the file //only this changes the Relative properties of FilePaths and DirectoryPaths //the Relative property is the only one that is serialized SetNewRootLocationToReferencedFiles(experiment, true); } //we check if the experiment is a challenge and if there is a password: in ths case we must encrypt the file if ((!string.IsNullOrEmpty(experiment.ExperimentInfo.ChallengePassword) || !string.IsNullOrEmpty(experiment.ExperimentInfo.ExperimentPassword)) && (!string.IsNullOrEmpty(experiment.ExperimentInfo.IsChallenge) && experiment.ExperimentInfo.IsChallenge.Equals("True"))) { success = SaveToCrypt(experiment); } else { success = Save(experiment); } if (success == true) { // process the components Path config values in the experiment - to update their Absolute and DataRoot properties to new location // if copy has been selected copy files accordingly // note KeepReference is not processed, as it was already processed before (because Relative property is being serialized. switch (referencedFilesProcessing) { case ReferencedFiles.COPY: CopyReferencedFiles(experiment, oldExperimentFilePath, false); break; case ReferencedFiles.COPYOVERWRITE: CopyReferencedFiles(experiment, oldExperimentFilePath, true); break; case ReferencedFiles.IGNORE: SetNewRootLocationToReferencedFiles(experiment, false); break; } } } finally { if (success == false) { experiment.ExperimentInfo.FilePath = oldExperimentFilePath; //go back to old filepath //Roll back the changes to Relative properties of FilePaths and DirectoriesPaths. SetNewRootLocationToReferencedFiles(experiment, true); } } return(success); }
private void SetExperimentViewModel(Experiment experiment) { var experimentViewModel = new ExperimentViewModel(experiment); ExperimentDocumentWrapper = new object[] { experimentViewModel }; }
/// <summary> /// Builds the list of candidate inputs and outputs used by the experiment that is being benchmarked /// </summary> /// <param name="experimentToBeBenchmarked">The experiment to be benchmarked.</param> public void PrepareMatchingIOByType(Experiment experimentToBeBenchmarked) { // Make sure to reset and previous state. ClearIO(); m_setup = new DefiningCompositeComponentSetup(experimentToBeBenchmarked); //PROCESS INPUTS ProcessIO(ComponentTemplate.IOSpec.Input, m_setup.InputSettings, BenchmarkInputSetting); //PROCESS OUTPUTS ProcessIO(ComponentTemplate.IOSpec.Output, m_setup.OutputSettings, BenchmarkOutputsSetting); ProcessConfig(m_setup.ConfigSettings); }
public void StartWizard(Experiment experimentToBeBenchmarked) { CurrentState = BenchmarkWizardState.SelectBenchmark; try { m_benchmarkWizard.StartWizard(experimentToBeBenchmarked); } catch (ArgumentException e) { NLog.LogManager.GetCurrentClassLogger().ErrorException("Failed to open wizard because ", e); System.Windows.MessageBox.Show(e.Message, "Failed to open wizard.", MessageBoxButton.OK); } }
public DefiningCompositeComponentSetup(Experiment experiment, Action <TraceLab.Core.Components.CompositeComponentMetadataDefinition> howToAddToComponentsLibrary) : this(experiment) { addToComponentLibrary = howToAddToComponentsLibrary; }
/// <summary> /// Goes through all the vertices in the experiment graph and extracts the components/types assemblies /// and other files/directories used. /// </summary> /// <param name="pVertices">Collection of vertices in the experiment graph.</param> public ExperimentPackagingResults PackExperiment(Experiment experiment) { foreach (ExperimentNode vertex in experiment.Vertices) { ExtractFilesFromNode(vertex); } ExperimentPackagingResults results = new ExperimentPackagingResults(experiment); results.TypeAssemblies = new List<string>(this.m_typeAssemblies); results.ComponentAssemblies = new List<string>(this.m_componentAssemblies); results.Files = new List<PackageFileInfo>(this.m_files); results.Directories = new List<PackageFileInfo>(this.m_directories); string tempPath = Path.Combine(Path.GetTempPath(), Path.GetFileName(experiment.ExperimentInfo.FilePath)); ExperimentManager.SaveAs(experiment, tempPath, ReferencedFiles.IGNORE); return results; }
/// <summary> /// Runs the experiment asynchronously... it will wait till the experiment runner thread completes before returning. /// </summary> /// <param name="experiment">The experiment.</param> /// <param name="progress">The progress.</param> private void RunExperimentAsync(Experiment experiment, IProgress progress, Workspace workspace, ComponentsLibrary library) { using (var waiter = new System.Threading.ManualResetEventSlim()) { experiment.RunExperiment(progress, workspace, library); experiment.ExperimentCompleted += (sender, args) => { waiter.Set(); }; waiter.Wait(); } }
/// <summary> /// Adds a new decision node at the specified coordinates /// </summary> public ExperimentDecisionNode AddDecisionToExperiment(Experiment experiment, double positionX, double positionY) { ExperimentDecisionNode newNode = null; SerializedVertexData data = new SerializedVertexData(); data.X = positionX; data.Y = positionY; data.Metadata = new DecisionMetadata("Decision"); newNode = new ExperimentDecisionNode(Guid.NewGuid().ToString(), data); experiment.AddVertex(newNode); return newNode; }
/// <summary> /// Save as allows saving experiment in different location with referenced files copied. /// </summary> /// <param name="experiment">The experiment.</param> /// <param name="fileName">Name of the file.</param> /// <param name="referencedFilesProcessing">The referenced files processing.</param> /// <returns></returns> public static bool SaveAs(Experiment experiment, string fileName, ReferencedFiles referencedFilesProcessing) { if (fileName == null) throw new ArgumentNullException("fileName"); string oldExperimentFilePath = experiment.ExperimentInfo.FilePath; bool success = false; try { //update its FilePath info to the new file location experiment.ExperimentInfo.FilePath = fileName; if (referencedFilesProcessing == ReferencedFiles.KEEPREFERENCE) { //Filepath of experiment has changed so update all referenced files before saving the file //only this changes the Relative properties of FilePaths and DirectoryPaths //the Relative property is the only one that is serialized SetNewRootLocationToReferencedFiles(experiment, true); } success = Save(experiment); if (success == true) { // process the components Path config values in the experiment - to update their Absolute and DataRoot properties to new location // if copy has been selected copy files accordingly // note KeepReference is not processed, as it was already processed before (because Relative property is being serialized. switch (referencedFilesProcessing) { case ReferencedFiles.COPY: CopyReferencedFiles(experiment, oldExperimentFilePath, false); break; case ReferencedFiles.COPYOVERWRITE: CopyReferencedFiles(experiment, oldExperimentFilePath, true); break; case ReferencedFiles.IGNORE: SetNewRootLocationToReferencedFiles(experiment, false); break; } } } finally { if (success == false) { experiment.ExperimentInfo.FilePath = oldExperimentFilePath; //go back to old filepath //Roll back the changes to Relative properties of FilePaths and DirectoriesPaths. SetNewRootLocationToReferencedFiles(experiment, true); } } return success; }
/// <summary> /// Method updates config relative path, so that they are relative to new location /// </summary> public static void SetNewRootLocationToReferencedFiles(Experiment experiment, bool transformRelative) { if (String.IsNullOrEmpty(experiment.ExperimentInfo.FilePath) == false) { string experimentLocation = System.IO.Path.GetDirectoryName(experiment.ExperimentInfo.FilePath); foreach (ExperimentNode node in experiment.Vertices) { var metadata = node.Data.Metadata as TraceLab.Core.Components.IConfigurableAndIOSpecifiable; if (metadata != null && ((metadata is TraceLab.Core.Components.ComponentTemplateMetadata) == false)) { metadata.ConfigWrapper.SetExperimentLocationRoot(experimentLocation, transformRelative); } } } }
/// <summary> /// Refreshes all experiments... needed when Components Library has been rescanned. /// </summary> /// <param name="experiment">The experiment.</param> /// <param name="library">The library.</param> /// <returns>experiment</returns> public static Experiment ReloadExperiment(Experiment experiment, TraceLab.Core.Components.ComponentsLibrary library) { //cache current experiment file path string currentPath = experiment.ExperimentInfo.FilePath; string tempFile = System.IO.Path.GetTempFileName(); //reload experiment by saving and loading it SerializeExperimentToXml(experiment, tempFile); Experiment refreshedExperiment = ExperimentManager.Load(tempFile, library); //set m_experiment path to the actual path - from temporary path refreshedExperiment.ExperimentInfo.FilePath = currentPath; SetNewRootLocationToReferencedFiles(refreshedExperiment, false); return refreshedExperiment; }
/// <summary> /// Copies the referenced files by experiment. Overwrite files if they already exists at new location. /// Errors contain the list of files that could not have been overwritten. /// </summary> /// <param name="experiment">The experiment.</param> public static void CopyReferencedFiles(Experiment experiment, string oldExperimentFilePath, bool overwrite) { if (String.IsNullOrEmpty(experiment.ExperimentInfo.FilePath) == false) { string experimentLocation = System.IO.Path.GetDirectoryName(experiment.ExperimentInfo.FilePath); string oldExperimentLocation = System.IO.Path.GetDirectoryName(oldExperimentFilePath); foreach (ExperimentNode node in experiment.Vertices) { var metadata = node.Data.Metadata as TraceLab.Core.Components.IConfigurableAndIOSpecifiable; if (metadata != null && ((metadata is TraceLab.Core.Components.ComponentTemplateMetadata) == false)) { metadata.ConfigWrapper.CopyReferencedFiles(experimentLocation, oldExperimentLocation, overwrite); } } } }
/// <summary> /// Initializes a new instance of the <see cref="TraceLab.UI.GTK.NodeConnection"/> class. /// </summary> public NodeConnectionControl(Experiment experimentOwner): base() { m_experimentOwner = experimentOwner; InitRemoveHandle(); }
private static IExperimentRunner CreateExperiment(Experiment experiment, Workspace workspace, ComponentsLibrary library) { RunnableExperimentBase graph = null; ExperimentWorkspaceWrapper experimentWorkspaceWrapper = WorkspaceWrapperFactory.CreateExperimentWorkspaceWrapper(workspace, experiment.ExperimentInfo.Id); RunnableNodeFactory templateGraphNodesFactory = new RunnableNodeFactory(experimentWorkspaceWrapper); graph = GraphAdapter.Adapt(experiment, templateGraphNodesFactory, library, workspace.TypeDirectories); //clear Workspace workspace.DeleteUnits(experiment.ExperimentInfo.Id); IExperimentRunner dispatcher = ExperimentRunnerFactory.CreateExperimentRunner(graph); return dispatcher; }
public DefiningCompositeComponentSetup(Experiment experiment, Action<TraceLab.Core.Components.CompositeComponentMetadataDefinition> howToAddToComponentsLibrary) : this(experiment) { addToComponentLibrary = howToAddToComponentsLibrary; }
/// <summary> /// Initializes a new instance of the <see cref="TraceLab.UI.GTK.NodeConnection"/> class. /// </summary> /// <param name='source'> /// Source. /// </param> /// <param name='target'> /// Target. /// </param> public NodeConnectionControl(Experiment experimentOwner, IFigure source, IFigure target): base(source, target) { m_experimentOwner = experimentOwner; InitRemoveHandle(); }