コード例 #1
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));
        }
コード例 #2
0
        internal static IExperimentRunner CreateExperimentRunner(IExperiment currentExperiment,
                TraceLab.Core.Workspaces.Workspace workspace,
                TraceLab.Core.Components.ComponentsLibrary library)
        {
            // Allow all nodes to send info to logs - if any targets exist.
            foreach (TraceLab.Core.Experiments.ExperimentNode node in currentExperiment.Vertices)
            {
                var componentNode = node as TraceLab.Core.Experiments.ComponentNode;
                if (componentNode != null)
                {
                    foreach (TraceLab.Core.Settings.LogLevelItem item in componentNode.Data.Metadata.LogLevels)
                    {
                        item.IsEnabled = true;
                    }
                }
            }

            RunnableNodeFactory templateGraphNodesFactory = new RunnableNodeFactory(workspace);
            TraceLab.Core.ExperimentExecution.RunnableExperimentBase template = GraphAdapter.Adapt(currentExperiment, templateGraphNodesFactory, library, workspace.TypeDirectories);

            var dispatcher = ExperimentRunnerFactory.CreateExperimentRunner(template);
            return dispatcher;
        }
コード例 #3
0
ファイル: RunnableNodeFactory.cs プロジェクト: CoEST/TraceLab
        /// <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);
        }
コード例 #4
0
        public void ValidateInputMapping_Decision_CorrectMapping()
        {
            Experiment experiment = ExperimentManager.New();
            experiment.ExperimentInfo.FilePath = "C:\\somefakelocation\\mockExperiment.teml";
            ExperimentNode writerNode = experiment.AddComponentFromDefinition(m_componentWriterMetaDefinition, 15, 15);
            (writerNode.Data.Metadata as ComponentMetadata).IOSpec.Output["testoutput"].MappedTo = "test";

            ExperimentNode readerNode = experiment.AddComponentFromDefinition(m_componentReaderMetaDefinition, 25, 25);
            (readerNode.Data.Metadata as ComponentMetadata).IOSpec.Input["testinput"].MappedTo = "test";

            ExperimentNode incrementerNode = experiment.AddComponentFromDefinition(m_incrementerComponentMetaDefinition, 35, 35);
            (incrementerNode.Data.Metadata as ComponentMetadata).IOSpec.Input["testinput"].MappedTo = "test";
            (incrementerNode.Data.Metadata as ComponentMetadata).IOSpec.Output["testoutput"].MappedTo = "test";

            var decisionNode = AddDecisionToExperiment(experiment, 10, 10);
            //code doesn't really matter in this case, because we don't execute dispatcher 
            string decisionCode = "";

            decisionNode.Data.Metadata = CompileMockDecision(decisionCode);

            experiment.AddConnection(experiment.StartNode, writerNode);
            experiment.AddConnection(writerNode, readerNode);
            experiment.AddConnection(readerNode, decisionNode);
            experiment.AddConnection(decisionNode, incrementerNode);
            experiment.AddConnection(incrementerNode, readerNode);
            experiment.AddConnection(decisionNode, experiment.EndNode);

            Assert.IsFalse(writerNode.HasError);
            Assert.IsFalse(readerNode.HasError);
            Assert.IsFalse(incrementerNode.HasError);
            Assert.IsFalse(decisionNode.HasError);

            RunnableNodeFactory templateGraphNodesFactory = new RunnableNodeFactory(AppContext.WorkspaceInstance);
            RunnableExperimentBase template = GraphAdapter.Adapt(experiment, templateGraphNodesFactory, AppContext.Components, AppContext.WorkspaceInstance.TypeDirectories);

            Assert.IsFalse(writerNode.HasError);
            Assert.IsFalse(readerNode.HasError);
            Assert.IsFalse(incrementerNode.HasError);
            Assert.IsFalse(decisionNode.HasError);

            Assert.IsFalse(template.IsEmpty);
            Assert.AreEqual(6, template.Nodes.Count);

            //check all  edges
            foreach (RunnableNode node in template.Nodes)
            {
                if (node is RunnableDecisionNode)
                {
                    //in this graph decision node has only two outcoming edges
                    Assert.AreEqual(2, node.NextNodes.Count);
                }
                else if (node is RunnableEndNode)
                {
                    //end node has none outcoming edges
                    Assert.AreEqual(0, node.NextNodes.Count);
                }
                else
                {
                    //all other nodes in this graph has only one outcoming edge
                    Assert.AreEqual(1, node.NextNodes.Count);
                }
            }
        }
コード例 #5
0
        public void ValidateInputMapping_CorrectFlow_OutputFound3()
        {
            IEditableExperiment experiment = ((IEditableExperiment)ExperimentManager.New());
            experiment.ExperimentInfo.FilePath = "C:\\somefakelocation\\mockExperiment.teml";
            ExperimentNode writerNode1 = experiment.AddComponentFromDefinition(m_componentWriterMetaDefinition, 15, 15);
            ExperimentNode writerNode2 = experiment.AddComponentFromDefinition(m_componentWriterMetaDefinition, 35, 35);

            ExperimentNode readerNode1 = experiment.AddComponentFromDefinition(m_componentReaderMetaDefinition, 5, 5);
            ExperimentNode readerNode2 = experiment.AddComponentFromDefinition(m_componentReaderMetaDefinition, 25, 25);


            experiment.AddConnection(experiment.StartNode, writerNode1);
            experiment.AddConnection(experiment.StartNode, writerNode2);

            experiment.AddConnection(writerNode1, readerNode2);

            experiment.AddConnection(writerNode2, readerNode1);
            experiment.AddConnection(readerNode1, readerNode2);

            experiment.AddConnection(readerNode2, experiment.EndNode);

            (writerNode1.Data.Metadata as ComponentMetadata).IOSpec.Output["testoutput"].MappedTo = "test1";
            (writerNode2.Data.Metadata as ComponentMetadata).IOSpec.Output["testoutput"].MappedTo = "test2";

            (readerNode1.Data.Metadata as ComponentMetadata).IOSpec.Input["testinput"].MappedTo = "test2";
            (readerNode2.Data.Metadata as ComponentMetadata).IOSpec.Input["testinput"].MappedTo = "test2";

            RunnableNodeFactory templateGraphNodesFactory = new RunnableNodeFactory(AppContext.WorkspaceInstance);
            RunnableExperimentBase template = GraphAdapter.Adapt(experiment, templateGraphNodesFactory, AppContext.Components, AppContext.WorkspaceInstance.TypeDirectories);

            Assert.IsFalse(readerNode1.HasError);
            Assert.IsFalse(readerNode2.HasError);
            Assert.IsFalse(writerNode1.HasError);
            Assert.IsFalse(writerNode2.HasError);

            Assert.IsFalse(template.IsEmpty);

            Assert.AreEqual(6, template.Nodes.Count);
        }
コード例 #6
0
        public void ValidateInputMapping_NoOutputFound2()
        {
            Assert.Fail("Test temporarily broken. The input mapping validator temporarily validates across all components, " +
                        "not only predecessors nodes. Test ignored till the validator feature is going to be revisited.");

            IEditableExperiment experiment = ((IEditableExperiment)ExperimentManager.New());
            experiment.ExperimentInfo.FilePath = "C:\\somefakelocation\\mockExperiment.teml";
            ExperimentNode readerNode1 = experiment.AddComponentFromDefinition(m_componentReaderMetaDefinition, 5, 5);
            ExperimentNode readerNode2 = experiment.AddComponentFromDefinition(m_componentReaderMetaDefinition, 15, 15);
            ExperimentNode writerNode = experiment.AddComponentFromDefinition(m_componentWriterMetaDefinition, 25, 25);

            experiment.AddConnection(experiment.StartNode, writerNode);
            experiment.AddConnection(experiment.StartNode, readerNode1);
            experiment.AddConnection(writerNode, readerNode2);
            experiment.AddConnection(readerNode1, experiment.EndNode);
            experiment.AddConnection(readerNode2, experiment.EndNode);

            (writerNode.Data.Metadata as ComponentMetadata).IOSpec.Output["testoutput"].MappedTo = "fakemapping";
            (readerNode1.Data.Metadata as ComponentMetadata).IOSpec.Input["testinput"].MappedTo = "fakemapping";
            (readerNode2.Data.Metadata as ComponentMetadata).IOSpec.Input["testinput"].MappedTo = "fakemapping";

            Assert.IsFalse(readerNode1.HasError);
            Assert.IsFalse(readerNode2.HasError);
            Assert.IsFalse(writerNode.HasError);

            RunnableNodeFactory templateGraphNodesFactory = new RunnableNodeFactory(AppContext.WorkspaceInstance);
            RunnableExperimentBase template = GraphAdapter.Adapt(experiment, templateGraphNodesFactory, AppContext.Components, AppContext.WorkspaceInstance.TypeDirectories);
            Assert.IsTrue(template.IsEmpty);

            Assert.IsFalse(readerNode2.HasError);
            Assert.IsFalse(writerNode.HasError);

            Assert.IsTrue(readerNode1.HasError);
            Assert.AreEqual(readerNode1.ErrorMessage, "The component attempts to load 'fakemapping' from the Workspace. However, none of the previous components outputs 'fakemapping' to the Workspace.");
        }
コード例 #7
0
        public void ValidateInputMapping_NoOutputFound()
        {
            IEditableExperiment experiment = ((IEditableExperiment)ExperimentManager.New());
            experiment.ExperimentInfo.FilePath = "C:\\somefakelocation\\mockExperiment.teml";
            ExperimentNode readerNode = experiment.AddComponentFromDefinition(m_componentReaderMetaDefinition, 5, 5);
            ExperimentNode writerNode = experiment.AddComponentFromDefinition(m_componentWriterMetaDefinition, 5, 5);

            experiment.AddConnection(experiment.StartNode, writerNode);
            experiment.AddConnection(writerNode, readerNode);
            experiment.AddConnection(readerNode, experiment.EndNode);

            (readerNode.Data.Metadata as ComponentMetadata).IOSpec.Input["testinput"].MappedTo = "fakemapping";

            Assert.IsFalse(readerNode.HasError);

            RunnableNodeFactory templateGraphNodesFactory = new RunnableNodeFactory(AppContext.WorkspaceInstance);
            RunnableExperimentBase template = GraphAdapter.Adapt(experiment, templateGraphNodesFactory, AppContext.Components, AppContext.WorkspaceInstance.TypeDirectories);
            Assert.IsTrue(template.IsEmpty);

            Assert.IsTrue(readerNode.HasError);
            Assert.AreEqual(readerNode.ErrorMessage, "The component attempts to load 'fakemapping' from the Workspace. However, none of the previous components outputs 'fakemapping' to the Workspace.");
        }
コード例 #8
0
        public void GraphStructureValidator_NoCircularLinkIfDecision()
        {
            Experiment experiment = ExperimentManager.New();
            experiment.ExperimentInfo.FilePath = "C:\\somefakelocation\\mockExperiment.teml";
            ExperimentNode node1 = experiment.AddComponentFromDefinition(m_emptyComponentMetaDefinition, 5, 5);
            ExperimentNode node2 = experiment.AddComponentFromDefinition(m_emptyComponentMetaDefinition, 15, 15);
            var decisionNode = AddDecisionToExperiment(experiment, 10, 10);
            decisionNode.Data.Metadata = CompileMockDecision("");

            experiment.AddConnection(experiment.StartNode, node1);
            experiment.AddConnection(node1, node2);
            experiment.AddConnection(node2, decisionNode);
            experiment.AddConnection(decisionNode, node1);
            experiment.AddConnection(decisionNode, experiment.EndNode);

            Assert.IsFalse(node1.HasError);
            Assert.IsFalse(node2.HasError);
            Assert.IsFalse(decisionNode.HasError);

            RunnableNodeFactory templateGraphNodesFactory = new RunnableNodeFactory(AppContext.WorkspaceInstance);
            RunnableExperimentBase template = GraphAdapter.Adapt(experiment, templateGraphNodesFactory, AppContext.Components, AppContext.WorkspaceInstance.TypeDirectories);

            Assert.IsFalse(node1.HasError);
            Assert.IsFalse(node2.HasError);
            Assert.IsFalse(decisionNode.HasError);

            Assert.IsFalse(template.IsEmpty);
            Assert.AreEqual(5, template.Nodes.Count);

            //check all  edges
            foreach (RunnableNode node in template.Nodes)
            {
                if (node is RunnableDecisionNode)
                {
                    //in this graph decision node has only two outcoming edges
                    Assert.AreEqual(2, node.NextNodes.Count);
                }
                else if (node is RunnableEndNode)
                {
                    //end node has none outcoming edges
                    Assert.AreEqual(0, node.NextNodes.Count);
                }
                else
                {
                    //all other nodes in this graph has only one outcoming edge
                    Assert.AreEqual(1, node.NextNodes.Count);
                }
            }
        }
コード例 #9
0
        public void GraphStructureValidator_CircularLink()
        {
            IEditableExperiment experiment = ((IEditableExperiment)ExperimentManager.New());
            experiment.ExperimentInfo.FilePath = "C:\\somefakelocation\\mockExperiment.teml";
            ExperimentNode node1 = experiment.AddComponentFromDefinition(m_emptyComponentMetaDefinition, 5, 5);
            ExperimentNode node2 = experiment.AddComponentFromDefinition(m_emptyComponentMetaDefinition, 5, 5);
            ExperimentNode node3 = experiment.AddComponentFromDefinition(m_emptyComponentMetaDefinition, 5, 5);

            experiment.AddConnection(experiment.StartNode, node1);
            experiment.AddConnection(node1, node2);
            experiment.AddConnection(node2, node3);
            experiment.AddConnection(node3, node1);

            Assert.IsFalse(node3.HasError);

            RunnableNodeFactory templateGraphNodesFactory = new RunnableNodeFactory(AppContext.WorkspaceInstance);
            RunnableExperimentBase template = GraphAdapter.Adapt(experiment, templateGraphNodesFactory, AppContext.Components, AppContext.WorkspaceInstance.TypeDirectories);
            Assert.IsTrue(template.IsEmpty);

            Assert.IsTrue(node3.HasError);
            Assert.AreEqual(node3.ErrorMessage, "Circular link detected.");
        }
コード例 #10
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;
        }