Example #1
0
        /// <summary>
        /// Creates the experiment.
        /// </summary>
        /// <param name="experiment">The experiment.</param>
        /// <param name="baseline">The baseline - if baseline is different than null it is going to be written into workspace before executing the experiment
        /// with the Unitname BASELINE.</param>
        /// <returns></returns>
        private IExperimentRunner CreateExperimentRunner(Workspace workspace, ComponentsLibrary library, TraceLabSDK.Types.Contests.TLExperimentResults baseline)
        {
            RunnableExperimentBase graph = null;

            var experimentWorkspaceWrapper = WorkspaceWrapperFactory.CreateExperimentWorkspaceWrapper(workspace, ExperimentInfo.Id);

            RunnableNodeFactory templateGraphNodesFactory = new RunnableNodeFactory(experimentWorkspaceWrapper);

            graph = GraphAdapter.Adapt(this, templateGraphNodesFactory, library, experimentWorkspaceWrapper.TypeDirectories);

            //clear Workspace
            experimentWorkspaceWrapper.DeleteExperimentUnits();

            //if baseline has been provided write it into the workspace before returning the dispatcher
            if (baseline != null)
            {
                experimentWorkspaceWrapper.Store("BASELINE", baseline);
            }

            IExperimentRunner dispatcher = ExperimentRunnerFactory.CreateExperimentRunner(graph);

            dispatcher.NodeExecuting      += dispatcher_NodeExecuting;
            dispatcher.NodeFinished       += dispatcher_NodeFinished;
            dispatcher.NodeHasError       += dispatcher_NodeHasError;
            dispatcher.ExperimentFinished += dispatcher_ExperimentFinished;
            dispatcher.ExperimentStarted  += dispatcher_ExperimentStarted;

            m_dispatcher = dispatcher;

            return(dispatcher);
        }
        /// <summary>
        /// Creates the Runnable node with a specific id based on the given metadata.
        /// Uses Composite Component Metadata config values to override Components config values in subgraph.
        /// </summary>
        /// <param name="id">The id of the node.</param>
        /// <param name="metadata">The component metadata.</param>
        /// <param name="loggerNameRoot">The logger name root - needed so that the logs are specific per experiment and experiment window.</param>
        /// <param name="library">The library of components.</param>
        /// <param name="componentsAppDomain">The components app domain is the app domain which components assemblies are going to be loaded into.</param>
        /// <param name="terminateExperimentExecutionResetEvent">The event that allows signalling termination of the experiment;
        /// Needed for the composite components sublevel experiments, so that they hold the referance to the same termination event as top level experiment</param>
        /// <returns>
        /// Created node
        /// </returns>
        public override RunnableNode CreateNode(String id, Metadata metadata, LoggerNameRoot loggerNameRoot, ComponentsLibrary library,
                                                AppDomain componentsAppDomain, System.Threading.ManualResetEvent terminateExperimentExecutionResetEvent)
        {
            RunnableNode retNode;

            ComponentMetadata originalComponentMetadata = metadata as ComponentMetadata;
            CompositeComponentMetadata compositeComponentMetadata = metadata as CompositeComponentMetadata;

            if (originalComponentMetadata != null)
            {
                ComponentMetadata overrideComponentMetadata = (ComponentMetadata)originalComponentMetadata.Clone();
                OverrideConfigValues(id, overrideComponentMetadata);
                retNode = base.CreateNode(id, overrideComponentMetadata, loggerNameRoot, library, componentsAppDomain, terminateExperimentExecutionResetEvent);
            }
            else if (compositeComponentMetadata != null)
            {
                OverrideConfigValues(id, compositeComponentMetadata);
                retNode = base.CreateCompositeComponentNode(id, compositeComponentMetadata, loggerNameRoot, library, componentsAppDomain, terminateExperimentExecutionResetEvent);
            }
            else
            {
                retNode = base.CreateNode(id, metadata, loggerNameRoot, library, componentsAppDomain, terminateExperimentExecutionResetEvent);
            }

            return retNode;
        }
Example #3
0
        /// <summary>
        /// Runs the experiement.
        /// </summary>
        /// <param name="progress">The progress.</param>
        /// <param name="experiment">The experiment.</param>
        /// <param name="baseline">(optional) The baseline data that is going to be preloaded into workspace before executing the experiment.</param>
        public void RunExperiment(IProgress progress, Workspace workspace, ComponentsLibrary library, TraceLabSDK.Types.Contests.TLExperimentResults baseline)
        {
            progress.CurrentStatus   = "Preparing experiment...";
            progress.IsIndeterminate = true;
            progress.SetError(false);
            ClearErrors();

            Action method = () =>
            {
                //prevent the component library from rescanning while running the experiment
                using (var rescanLibraryGuard = new RescanLibraryGuard(library))
                {
                    using (var dispatcher = CreateExperimentRunner(workspace, library, baseline))
                    {
                        dispatcher.ExecuteExperiment(progress);
                    }
                }
            };

            Thread dispatchThread = ThreadFactory.CreateThread(new System.Threading.ThreadStart(method));

            dispatchThread.IsBackground = true;
            dispatchThread.Name         = "ExperimentRunner";
            dispatchThread.SetApartmentState(System.Threading.ApartmentState.STA);
            dispatchThread.Start();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="RunnableDecisionNode"/> class.
 /// </summary>
 /// <param name="id">The id of this decision node.</param>
 /// <param name="label">The label - useful for debugging.</param>
 /// <param name="decisionModule">The decision module that is going to be invoked to select nodes to be executed after decision</param>
 /// <param name="library">The reference to the components library.</param>
 public RunnableDecisionNode(String id, String label, TraceLab.Core.Decisions.IDecisionModule decisionModule, ComponentsLibrary library, bool waitForAllPredecessors)
     : base(id, label, new RunnableNodeCollection(), new RunnableNodeCollection(), library, waitForAllPredecessors)
 {
     if (decisionModule == null)
         throw new ArgumentNullException("decisionModule");
     m_candidateNodes = new RunnableNodeCollection();
     m_decisionModule = decisionModule;
 }
Example #5
0
 public BenchmarkWizard(string benchmarkDirectory, ComponentsLibrary library, Workspace workspace,
                        List <string> workspaceTypeDirectories, string dataRoot, TraceLab.Core.Settings.Settings settings)
 {
     m_workspace         = workspace;
     m_componentsLibrary = library;
     m_dataRoot          = dataRoot;
     m_settings          = settings;
     BenchmarksDirectory = benchmarkDirectory;
 }
Example #6
0
        /// <summary>
        /// Creates the Runnable node with a specific id based on the given metadata.
        /// </summary>
        /// <param name="nodeId">The node id.</param>
        /// <param name="metadata">The component metadata.</param>
        /// <param name="loggerNameRoot">The logger name root - needed so that the logs are specific per experiment and experiment window.</param>
        /// <param name="library">The library of components.</param>
        /// <param name="componentsAppDomain">The components app domain is the app domain which components assemblies are going to be loaded into.</param>
        /// <param name="terminateExperimentExecutionResetEvent">The event that allows signalling termination of the experiment;
        /// Needed for the composite components sublevel experiments, so that they hold the referance to the same termination event as top level experiment.</param>
        /// <returns>
        /// Created node
        /// </returns>
        public virtual RunnableNode CreateNode(String nodeId, Metadata metadata, LoggerNameRoot loggerNameRoot,
                                               ComponentsLibrary library, AppDomain componentsAppDomain, System.Threading.ManualResetEvent terminateExperimentExecutionResetEvent)
        {
            RunnableNode retNode;

            ComponentMetadata          componentMetadata          = metadata as ComponentMetadata;
            DecisionMetadata           decisionMetadata           = metadata as DecisionMetadata;
            StartNodeMetadata          startNodeMetadata          = metadata as StartNodeMetadata;
            EndNodeMetadata            endNodeMetadata            = metadata as EndNodeMetadata;
            ScopeBaseMetadata          scopeMetadata              = metadata as ScopeBaseMetadata;
            LoopScopeMetadata          loopMetadata               = metadata as LoopScopeMetadata;
            CompositeComponentMetadata compositeComponentMetadata = metadata as CompositeComponentMetadata;
            ExitDecisionMetadata       exitDecisionMetadata       = metadata as ExitDecisionMetadata;

            if (componentMetadata != null)
            {
                TraceLabSDK.ComponentLogger logger = TraceLab.Core.Components.LoggerFactory.CreateLogger(loggerNameRoot, nodeId, componentMetadata);
                IComponent component = library.LoadComponent(componentMetadata, Workspace, logger, componentsAppDomain);
                retNode = new RunnableComponentNode(nodeId, componentMetadata.Label, component, logger, library, componentMetadata.WaitsForAllPredecessors);
            }
            else if (decisionMetadata != null)
            {
                IDecisionModule decisionModule = DecisionModuleFactory.LoadDecisionModule(decisionMetadata, Workspace, componentsAppDomain);
                retNode = new RunnableDecisionNode(nodeId, decisionMetadata.Label, decisionModule, library, decisionMetadata.WaitsForAllPredecessors);
            }
            else if (startNodeMetadata != null)
            {
                retNode = new RunnableStartNode(nodeId);
            }
            else if (endNodeMetadata != null)
            {
                retNode = new RunnableEndNode(nodeId, endNodeMetadata.WaitsForAllPredecessors);
            }
            else if (loopMetadata != null)
            {
                retNode = CreateLoopNode(nodeId, loopMetadata, loggerNameRoot, library, componentsAppDomain, terminateExperimentExecutionResetEvent);
            }
            else if (scopeMetadata != null)
            {
                retNode = CreateScopeCompositeComponentNode(nodeId, scopeMetadata, loggerNameRoot, library, componentsAppDomain, terminateExperimentExecutionResetEvent);
            }
            else if (compositeComponentMetadata != null)
            {
                retNode = CreateCompositeComponentNode(nodeId, compositeComponentMetadata, loggerNameRoot, library, componentsAppDomain, terminateExperimentExecutionResetEvent);
            }
            else if (exitDecisionMetadata != null)
            {
                retNode = new RunnablePrimitiveNode(nodeId, exitDecisionMetadata.WaitsForAllPredecessors);
            }
            else
            {
                throw new Exceptions.InconsistentTemplateException("Could not identify node type.");
            }

            return(retNode);
        }
        public BenchmarkWizard(string benchmarkDirectory, ComponentsLibrary library, Workspace workspace,
                               List<string> workspaceTypeDirectories, string dataRoot, TraceLab.Core.Settings.Settings settings)
        {
            m_workspace = workspace;
            m_componentsLibrary = library;
            m_dataRoot = dataRoot;
            m_settings = settings;
            BenchmarksDirectory = benchmarkDirectory;

        }
        /// <summary>
        /// Creates the Runnable node with a specific id based on the given metadata.
        /// </summary>
        /// <param name="nodeId">The node id.</param>
        /// <param name="metadata">The component metadata.</param>
        /// <param name="loggerNameRoot">The logger name root - needed so that the logs are specific per experiment and experiment window.</param>
        /// <param name="library">The library of components.</param>
        /// <param name="componentsAppDomain">The components app domain is the app domain which components assemblies are going to be loaded into.</param>
        /// <param name="terminateExperimentExecutionResetEvent">The event that allows signalling termination of the experiment; 
        /// Needed for the composite components sublevel experiments, so that they hold the referance to the same termination event as top level experiment.</param>
        /// <returns>
        /// Created node
        /// </returns>
        public virtual RunnableNode CreateNode(String nodeId, Metadata metadata, LoggerNameRoot loggerNameRoot, 
                                               ComponentsLibrary library, AppDomain componentsAppDomain, System.Threading.ManualResetEvent terminateExperimentExecutionResetEvent)
        {
            RunnableNode retNode;

            ComponentMetadata componentMetadata = metadata as ComponentMetadata;
            DecisionMetadata decisionMetadata = metadata as DecisionMetadata;
            StartNodeMetadata startNodeMetadata = metadata as StartNodeMetadata;
            EndNodeMetadata endNodeMetadata = metadata as EndNodeMetadata;
            ScopeBaseMetadata scopeMetadata = metadata as ScopeBaseMetadata;
            LoopScopeMetadata loopMetadata = metadata as LoopScopeMetadata;
            CompositeComponentMetadata compositeComponentMetadata = metadata as CompositeComponentMetadata;
            ExitDecisionMetadata exitDecisionMetadata = metadata as ExitDecisionMetadata;
            if (componentMetadata != null)
            {
                TraceLabSDK.ComponentLogger logger = TraceLab.Core.Components.LoggerFactory.CreateLogger(loggerNameRoot, nodeId, componentMetadata);
                IComponent component = library.LoadComponent(componentMetadata, Workspace, logger, componentsAppDomain);
                retNode = new RunnableComponentNode(nodeId, componentMetadata.Label, component, logger, library, componentMetadata.WaitsForAllPredecessors);
            }
            else if (decisionMetadata != null)
            {
                IDecisionModule decisionModule = DecisionModuleFactory.LoadDecisionModule(decisionMetadata, Workspace, componentsAppDomain);
                retNode = new RunnableDecisionNode(nodeId, decisionMetadata.Label, decisionModule, library, decisionMetadata.WaitsForAllPredecessors);
            }
            else if (startNodeMetadata != null)
            {
                retNode = new RunnableStartNode(nodeId);
            }
            else if (endNodeMetadata != null)
            {
                retNode = new RunnableEndNode(nodeId, endNodeMetadata.WaitsForAllPredecessors);
            }
            else if (loopMetadata != null)
            {
                retNode = CreateLoopNode(nodeId, loopMetadata, loggerNameRoot, library, componentsAppDomain, terminateExperimentExecutionResetEvent);
            }
            else if (scopeMetadata != null)
            {
                retNode = CreateScopeCompositeComponentNode(nodeId, scopeMetadata, loggerNameRoot, library, componentsAppDomain, terminateExperimentExecutionResetEvent);
            }
            else if (compositeComponentMetadata != null)
            {
                retNode = CreateCompositeComponentNode(nodeId, compositeComponentMetadata, loggerNameRoot, library, componentsAppDomain, terminateExperimentExecutionResetEvent);
            }
            else if (exitDecisionMetadata != null)
            {
                retNode = new RunnablePrimitiveNode(nodeId, exitDecisionMetadata.WaitsForAllPredecessors);
            }
            else
            {
                throw new Exceptions.InconsistentTemplateException("Could not identify node type.");
            }

            return retNode;
        }
Example #9
0
        /// <summary>
        /// Creates the composite component node.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="compositeComponentMetadata">The composite component metadata.</param>
        /// <param name="loggerNameRoot">The logger name root - needed so that the logs are specific per experiment and experiment window.</param>
        /// <param name="library">The library of components.</param>
        /// <param name="componentsAppDomain">The components app domain is the app domain which components assemblies are going to be loaded into.</param>
        /// <param name="terminateExperimentExecutionResetEvent">The event that allows signalling termination of the experiment; The sublevel experiments hold the referance to the same termination event as top level experiment.</param>
        /// <returns>
        /// Created composite component node
        /// </returns>
        protected RunnableNode CreateCompositeComponentNode(string id, CompositeComponentMetadata compositeComponentMetadata, LoggerNameRoot loggerNameRoot,
                                                            ComponentsLibrary library, AppDomain componentsAppDomain,
                                                            System.Threading.ManualResetEvent terminateExperimentExecutionResetEvent)
        {
            NestedWorkspaceWrapper workspaceWrapper       = WorkspaceWrapperFactory.CreateCompositeComponentWorkspaceWrapper(compositeComponentMetadata, Workspace, id, componentsAppDomain);
            NodesFactoryOfSubGraph nodesFactoryOfSubGraph = new NodesFactoryOfSubGraph(compositeComponentMetadata, workspaceWrapper);

            RunnableExperimentBase subExperiment = ConstructSubExperiment(compositeComponentMetadata, loggerNameRoot, library,
                                                                          componentsAppDomain, terminateExperimentExecutionResetEvent, nodesFactoryOfSubGraph);

            return(new RunnableCompositeComponentNode(id, compositeComponentMetadata, subExperiment, workspaceWrapper, library, compositeComponentMetadata.WaitsForAllPredecessors));
        }
Example #10
0
        static void Main(string[] args)
        {
            string outfile = Properties.Settings.Default.Outfile;
            List <SettingsPath> ComponentDirectories = CreateSettingsPath(Properties.Settings.Default.ComponentDirectoriesFile);
            string        decisionDirectory          = Properties.Settings.Default.DecisionDirectory;
            string        dataRoot = Properties.Settings.Default.DataRoot;
            List <string> typeDir  = CreateTypeDirectories(Properties.Settings.Default.TypeDirectoriesFile);

            Console.WriteLine("Scanning component directories...");

            ComponentsLibrary.Init(ComponentDirectories);
            ComponentsLibrary.Instance.DecisionsDirectoryPath = decisionDirectory;
            ComponentsLibrary.Instance.DataRoot = dataRoot;
            ComponentsLibrary.Instance.Rescan(PackageManager.Instance, typeDir, true);
            while (ComponentsLibrary.Instance.IsRescanning)
            {
            }                                                   // wait

            if (ComponentsLibrary.Instance.DefinitionErrors != null)
            {
                int errors = 0;
                foreach (string error in ComponentsLibrary.Instance.DefinitionErrors)
                {
                    errors++;
                    Console.WriteLine(error);
                }
                Console.WriteLine();
                Console.WriteLine("{0} errors found.", errors);
            }

            int count = 0;

            if (ComponentsLibrary.Instance.Components != null)
            {
                string     lineFormat = String.Format("{{0,-{0}}}\t{{1}}\t{{2}}\t{{3}}", Properties.Settings.Default.GUIDLength);
                TextWriter file       = new StreamWriter(outfile, false);
                foreach (MetadataDefinition metadata in ComponentsLibrary.Instance.Components)
                {
                    count++;
                    file.WriteLine(lineFormat,
                                   metadata.ID,
                                   PadName(metadata.Label, Properties.Settings.Default.NameLength),
                                   PadName(metadata.Version, Properties.Settings.Default.VersionLength),
                                   metadata.Assembly);
                }
                file.Flush();
                file.Close();
            }

            Console.WriteLine("{0} components found.", count);
            Console.WriteLine("Output written to {0}", Properties.Settings.Default.Outfile);
        }
Example #11
0
 public DefaultQuokkaAssemblyDeps(
     ILogStream logStream,
     RuntimeConfiguration runtimeConfiguration,
     RTLModulesDiscovery rtlModulesDiscovery,
     ComponentsLibrary componentsLibrary,
     ClassFactory classFactory)
 {
     _logStream            = logStream;
     _runtimeConfiguration = runtimeConfiguration;
     _rtlModulesDiscovery  = rtlModulesDiscovery;
     _componentsLibrary    = componentsLibrary;
     _classFactory         = classFactory;
 }
Example #12
0
        /// <summary>
        /// Creates the scope composite component node. It actually returns the composite component, but with different nested workspace wrapper.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="scopeMetadata">The scope metadata.</param>
        /// <param name="loggerNameRoot">The logger name root.</param>
        /// <param name="library">The library.</param>
        /// <param name="componentsAppDomain">The components app domain.</param>
        /// <param name="terminateExperimentExecutionResetEvent">The terminate experiment execution reset event.</param>
        /// <returns></returns>
        protected RunnableNode CreateScopeCompositeComponentNode(string id, ScopeBaseMetadata scopeMetadata, LoggerNameRoot loggerNameRoot,
                                                                 ComponentsLibrary library, AppDomain componentsAppDomain,
                                                                 System.Threading.ManualResetEvent terminateExperimentExecutionResetEvent)
        {
            ScopeNestedWorkspaceWrapper workspaceWrapper = WorkspaceWrapperFactory.CreateCompositeComponentWorkspaceWrapper(scopeMetadata, Workspace, id, componentsAppDomain);

            //scope can standard runnable factory, unlike the composite component
            IRunnableNodeFactory nodesFactory = new RunnableNodeFactory(workspaceWrapper);

            RunnableExperimentBase subExperiment = ConstructSubExperiment(scopeMetadata, loggerNameRoot, library, componentsAppDomain, terminateExperimentExecutionResetEvent, nodesFactory);

            return(new RunnableCompositeComponentNode(id, scopeMetadata, subExperiment, workspaceWrapper, library, scopeMetadata.WaitsForAllPredecessors));
        }
Example #13
0
        /// <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();
        }
Example #14
0
        /// <summary>
        /// Constructs the sub experiment.
        /// </summary>
        /// <param name="compositeComponentMetadata">The composite component metadata.</param>
        /// <param name="loggerNameRoot">The logger name root.</param>
        /// <param name="library">The library.</param>
        /// <param name="componentsAppDomain">The components app domain.</param>
        /// <param name="terminateExperimentExecutionResetEvent">The terminate experiment execution reset event - must be the same as top level experiment termination event.</param>
        /// <param name="nodesFactoryOfSubGraph">The nodes factory of sub graph.</param>
        /// <returns></returns>
        private RunnableExperimentBase ConstructSubExperiment(CompositeComponentBaseMetadata compositeComponentMetadata, LoggerNameRoot loggerNameRoot,
                                                              ComponentsLibrary library, AppDomain componentsAppDomain,
                                                              System.Threading.ManualResetEvent terminateExperimentExecutionResetEvent, IRunnableNodeFactory nodesFactoryOfSubGraph)
        {
            //add to experiment id the owner node id to make it unique
            LoggerNameRoot compositeComponentNodeLoggerNameRoot = loggerNameRoot.CreateLoggerNameRootForCompositeNode(compositeComponentMetadata);

            RunnableExperimentBase subExperiment = GraphAdapter.Adapt(compositeComponentMetadata.ComponentGraph, compositeComponentNodeLoggerNameRoot,
                                                                      nodesFactoryOfSubGraph, library, Workspace.TypeDirectories,
                                                                      componentsAppDomain, terminateExperimentExecutionResetEvent, false);

            if (subExperiment.IsEmpty)
            {
                throw new TraceLab.Core.Exceptions.IncorrectSubTemplateException("Unable to execute subexperiment due to errors.");
            }
            return(subExperiment);
        }
        public BenchmarkWizardViewModel(BenchmarkWizard benchmarkWizard, Workspace workspace, ComponentsLibrary library)
        {
            if (benchmarkWizard == null)
                throw new ArgumentNullException("benchmarkWizard", "Wrapped benchmark wizard cannot be null");
            if (workspace == null)
                throw new ArgumentNullException("workspace");
            if (library == null)
                throw new ArgumentNullException("library");

            AdvanceState = new DelegateCommand(DoAdvanceState, CanAdvanceState);
            BacktrackState = new DelegateCommand(DoBacktrackState, CanBacktrackState);
            Process = new DelegateCommand(DoProcess, DoCanProcess);
            DownloadContestPackage = new DelegateCommand(ExecuteDownloadContestPackage);
           
            m_benchmarkWizard = benchmarkWizard;
            m_workspace = workspace;
            m_library = library;

            m_benchmarkWizard.PropertyChanged += OnWrappedBenchmarkWizardPropertyChanged;
        }
Example #16
0
        private static TraceLab.Core.ViewModels.ComponentLibraryViewModel CreateComponentLibraryViewModel(PackageManager pkgManager, TraceLab.Core.Settings.Settings settings, string decisionDirectory, string dataRoot)
        {
            ComponentsLibrary.Init(settings.ComponentPaths);

            //Load stuff to components library
            TraceLab.Core.Decisions.DecisionCompilationRunner.DecisionDirectoryPath = decisionDirectory;
            ComponentsLibrary.Instance.DataRoot = dataRoot;

            var workspaceTypeDirectories = new List <string>(settings.TypePaths.Select(path => path.Path));

            ComponentsLibrary.Instance.Rescan(pkgManager, workspaceTypeDirectories, false);

            foreach (SettingsPath path in settings.ComponentPaths)
            {
                var logger = NLog.LogManager.GetCurrentClassLogger();
                logger.Info("Reading components from: {0}", path.Path);
            }

            var compvm = new ComponentLibraryViewModel(ComponentsLibrary.Instance, workspaceTypeDirectories);

            return(compvm);
        }
        /// <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();
        }
 public PackageAwareComponentLibrary(ComponentsLibrary wrappedLibrary, IEnumerable <IPackageReference> references)
 {
     m_wrappedLibrary = wrappedLibrary;
     m_references     = references;
 }
Example #19
0
        /// <summary>
        /// Creates the Runnable node with a specific id based on the given metadata.
        /// Uses Composite Component Metadata config values to override Components config values in subgraph.
        /// </summary>
        /// <param name="id">The id of the node.</param>
        /// <param name="metadata">The component metadata.</param>
        /// <param name="loggerNameRoot">The logger name root - needed so that the logs are specific per experiment and experiment window.</param>
        /// <param name="library">The library of components.</param>
        /// <param name="componentsAppDomain">The components app domain is the app domain which components assemblies are going to be loaded into.</param>
        /// <param name="terminateExperimentExecutionResetEvent">The event that allows signalling termination of the experiment;
        /// Needed for the composite components sublevel experiments, so that they hold the referance to the same termination event as top level experiment</param>
        /// <returns>
        /// Created node
        /// </returns>
        public override RunnableNode CreateNode(String id, Metadata metadata, LoggerNameRoot loggerNameRoot, ComponentsLibrary library,
                                                AppDomain componentsAppDomain, System.Threading.ManualResetEvent terminateExperimentExecutionResetEvent)
        {
            RunnableNode retNode;

            ComponentMetadata          originalComponentMetadata  = metadata as ComponentMetadata;
            CompositeComponentMetadata compositeComponentMetadata = metadata as CompositeComponentMetadata;

            if (originalComponentMetadata != null)
            {
                ComponentMetadata overrideComponentMetadata = (ComponentMetadata)originalComponentMetadata.Clone();
                OverrideConfigValues(id, overrideComponentMetadata);
                retNode = base.CreateNode(id, overrideComponentMetadata, loggerNameRoot, library, componentsAppDomain, terminateExperimentExecutionResetEvent);
            }
            else if (compositeComponentMetadata != null)
            {
                OverrideConfigValues(id, compositeComponentMetadata);
                retNode = base.CreateCompositeComponentNode(id, compositeComponentMetadata, loggerNameRoot, library, componentsAppDomain, terminateExperimentExecutionResetEvent);
            }
            else
            {
                retNode = base.CreateNode(id, metadata, loggerNameRoot, library, componentsAppDomain, terminateExperimentExecutionResetEvent);
            }

            return(retNode);
        }
Example #20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RunnableDecisionNode"/> class.
 /// </summary>
 /// <param name="id">The id of this decision node.</param>
 /// <param name="label">The label - useful for debugging.</param>
 /// <param name="decisionModule">The decision module that is going to be invoked to select nodes to be executed after decision</param>
 /// <param name="library">The reference to the components library.</param>
 public RunnableDecisionNode(String id, String label, TraceLab.Core.Decisions.IDecisionModule decisionModule, ComponentsLibrary library, bool waitForAllPredecessors)
     : base(id, label, new RunnableNodeCollection(), new RunnableNodeCollection(), library, waitForAllPredecessors)
 {
     if (decisionModule == null)
     {
         throw new ArgumentNullException("decisionModule");
     }
     m_candidateNodes = new RunnableNodeCollection();
     m_decisionModule = decisionModule;
 }
        /// <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;
        }
 public PackageAwareComponentLibrary(ComponentsLibrary wrappedLibrary, IEnumerable<IPackageReference> references)
 {
     m_wrappedLibrary = wrappedLibrary;
     m_references = references;
 }
Example #23
0
        /// <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();
            }
        }
        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 RunnableComponentNode(String id, String label, IComponent component, TraceLabSDK.ComponentLogger logger, ComponentsLibrary library, bool waitForAllPredecessors) 
     : base(id, label, new RunnableNodeCollection(), new RunnableNodeCollection(), library, waitForAllPredecessors)
 {
     m_component = component;
     Logger = logger;
 }
Example #26
0
        /// <summary>
        /// Creates the scope composite component node. It actually returns the composite component, but with different nested workspace wrapper.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="loopScopeMetadata">The scope metadata.</param>
        /// <param name="loggerNameRoot">The logger name root.</param>
        /// <param name="library">The library.</param>
        /// <param name="componentsAppDomain">The components app domain.</param>
        /// <param name="terminateExperimentExecutionResetEvent">The terminate experiment execution reset event.</param>
        /// <returns></returns>
        protected RunnableNode CreateLoopNode(string id, LoopScopeMetadata loopScopeMetadata, LoggerNameRoot loggerNameRoot,
                                                                 ComponentsLibrary library, AppDomain componentsAppDomain,
                                                                 System.Threading.ManualResetEvent terminateExperimentExecutionResetEvent)
        {
            ScopeNestedWorkspaceWrapper workspaceWrapper = WorkspaceWrapperFactory.CreateCompositeComponentWorkspaceWrapper(loopScopeMetadata, Workspace, id, componentsAppDomain);

            //scope can standard runnable factory, unlike the composite component
            IRunnableNodeFactory nodesFactory = new RunnableNodeFactory(workspaceWrapper);

            RunnableExperimentBase subExperiment = ConstructSubExperiment(loopScopeMetadata, loggerNameRoot, library, componentsAppDomain, terminateExperimentExecutionResetEvent, nodesFactory);

            ILoopDecisionModule decisionModule = DecisionModuleFactory.LoadDecisionModule(loopScopeMetadata, Workspace, componentsAppDomain);
            return new RunnableLoopNode(id, decisionModule, loopScopeMetadata, subExperiment, workspaceWrapper, library, loopScopeMetadata.WaitsForAllPredecessors);
        }
Example #27
0
 public void TestSetup()
 {
     AppContext   = new TraceLabTestApplication(TestContext);
     this.Library = AppContext.Components;
 }
Example #28
0
        /// <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>
        /// 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();
            }
        }
Example #30
0
 /// <summary>
 /// Runs the experiement.
 /// </summary>
 /// <param name="progress">The progress.</param>
 public void RunExperiment(IProgress progress, Workspace workspace, ComponentsLibrary library)
 {
     RunExperiment(progress, workspace, library, null);
 }
Example #31
0
 public RunnableComponentNode(String id, String label, IComponent component, TraceLabSDK.ComponentLogger logger, ComponentsLibrary library, bool waitForAllPredecessors)
     : base(id, label, new RunnableNodeCollection(), new RunnableNodeCollection(), library, waitForAllPredecessors)
 {
     m_component = component;
     Logger      = logger;
 }
 public void TestSetup()
 {
     AppContext = new TraceLabTestApplication(TestContext);
     this.Library = AppContext.Components;
 }
Example #33
0
 public RescanLibraryGuard(ComponentsLibrary library)
 {
     m_library = library;
     m_library.LockRescanning();
 }
Example #34
0
        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 void RunExperiment(TraceLabSDK.IProgress progress, TraceLab.Core.Workspaces.Workspace workspace, ComponentsLibrary library)
 {
     m_experiment.RunExperiment(progress, workspace, library);
 }
Example #36
0
 /// <summary>
 /// Creates the composite component node.
 /// </summary>
 /// <param name="id">The id.</param>
 /// <param name="compositeComponentMetadata">The composite component metadata.</param>
 /// <param name="loggerNameRoot">The logger name root - needed so that the logs are specific per experiment and experiment window.</param>
 /// <param name="library">The library of components.</param>
 /// <param name="componentsAppDomain">The components app domain is the app domain which components assemblies are going to be loaded into.</param>
 /// <param name="terminateExperimentExecutionResetEvent">The event that allows signalling termination of the experiment; The sublevel experiments hold the referance to the same termination event as top level experiment.</param>
 /// <returns>
 /// Created composite component node
 /// </returns>
 protected RunnableNode CreateCompositeComponentNode(string id, CompositeComponentMetadata compositeComponentMetadata, LoggerNameRoot loggerNameRoot,
                                                     ComponentsLibrary library, AppDomain componentsAppDomain, 
                                                     System.Threading.ManualResetEvent terminateExperimentExecutionResetEvent)
 {
     NestedWorkspaceWrapper workspaceWrapper = WorkspaceWrapperFactory.CreateCompositeComponentWorkspaceWrapper(compositeComponentMetadata, Workspace, id, componentsAppDomain);
     NodesFactoryOfSubGraph nodesFactoryOfSubGraph = new NodesFactoryOfSubGraph(compositeComponentMetadata, workspaceWrapper);
     
     RunnableExperimentBase subExperiment = ConstructSubExperiment(compositeComponentMetadata, loggerNameRoot, library, 
                                                     componentsAppDomain, terminateExperimentExecutionResetEvent, nodesFactoryOfSubGraph);
     
     return new RunnableCompositeComponentNode(id, compositeComponentMetadata, subExperiment, workspaceWrapper, library, compositeComponentMetadata.WaitsForAllPredecessors);
 }
 public void RunExperiment(TraceLabSDK.IProgress progress, TraceLab.Core.Workspaces.Workspace workspace, ComponentsLibrary library)
 {
     m_experiment.RunExperiment(progress, workspace, library);
 }
Example #38
0
        /// <summary>
        /// Constructs the sub experiment.
        /// </summary>
        /// <param name="compositeComponentMetadata">The composite component metadata.</param>
        /// <param name="loggerNameRoot">The logger name root.</param>
        /// <param name="library">The library.</param>
        /// <param name="componentsAppDomain">The components app domain.</param>
        /// <param name="terminateExperimentExecutionResetEvent">The terminate experiment execution reset event - must be the same as top level experiment termination event.</param>
        /// <param name="nodesFactoryOfSubGraph">The nodes factory of sub graph.</param>
        /// <returns></returns>
        private RunnableExperimentBase ConstructSubExperiment(CompositeComponentBaseMetadata compositeComponentMetadata, LoggerNameRoot loggerNameRoot, 
                                                ComponentsLibrary library, AppDomain componentsAppDomain, 
                                                System.Threading.ManualResetEvent terminateExperimentExecutionResetEvent, IRunnableNodeFactory nodesFactoryOfSubGraph)
        {
            //add to experiment id the owner node id to make it unique
            LoggerNameRoot compositeComponentNodeLoggerNameRoot = loggerNameRoot.CreateLoggerNameRootForCompositeNode(compositeComponentMetadata);

            RunnableExperimentBase subExperiment = GraphAdapter.Adapt(compositeComponentMetadata.ComponentGraph, compositeComponentNodeLoggerNameRoot,
                                                                        nodesFactoryOfSubGraph, library, Workspace.TypeDirectories,
                                                                        componentsAppDomain, terminateExperimentExecutionResetEvent, false);

            if (subExperiment.IsEmpty)
            {
                throw new TraceLab.Core.Exceptions.IncorrectSubTemplateException("Unable to execute subexperiment due to errors.");
            }
            return subExperiment;
        }
 public void LoadUserTags(string path)
 {
     ComponentsLibrary.ReadTags(path, (a) => { return(m_componentsLibraryInstance.GetComponentDefinition(a)); });
 }