Пример #1
0
 public PrecisionRecallCurveMetricComputation(TraceLabSDK.ComponentLogger logger)
 {
     if (logger == null)
     {
         throw new ArgumentNullException("logger");
     }
     m_logger = logger;
 }
Пример #2
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);
        }
Пример #3
0
        private static string ReferenceTypesAssemblies(List <string> typeDirectories, TraceLabSDK.ComponentLogger logger, out HashSet <string> assembliesReferenceLocations)
        {
            string usingKeyword = "using ";
            string semicolon    = ";";

            Dictionary <string, System.Reflection.Assembly> assemblies = new Dictionary <string, System.Reflection.Assembly>();

            foreach (System.Reflection.Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                var name = assembly.GetName();
                assemblies[name.Name + System.Text.UTF8Encoding.UTF8.GetString(name.GetPublicKeyToken())] = assembly;
            }

            assembliesReferenceLocations = new HashSet <string>();
            HashSet <string> namespaces      = new HashSet <string>();
            StringBuilder    typesNamespaces = new StringBuilder();

            //preadd fixed namespaces
            namespaces.Add("System");
            namespaces.Add("System.Security.Permissions");
            namespaces.Add("TraceLab.Core.ExperimentExecution");
            namespaces.Add("TraceLab.Core.Experiments");
            namespaces.Add("TraceLab.Core.Decisions");
            namespaces.Add("TraceLabSDK");
            foreach (string fixedNamespace in namespaces)
            {
                typesNamespaces.AppendLine(usingKeyword + fixedNamespace + semicolon);
            }

            //iterate through all type directories, search for all dll, and collect the namespaces of all found types in those assemblies
            foreach (string dir in typeDirectories)
            {
                string typesDir = System.IO.Path.GetFullPath(dir);

                var files = System.IO.Directory.GetFiles(typesDir, "*.dll");
                foreach (string file in files)
                {
                    var name   = System.Reflection.AssemblyName.GetAssemblyName(file);
                    var lookup = name.Name + System.Text.UTF8Encoding.UTF8.GetString(name.GetPublicKeyToken());
                    if (assemblies.ContainsKey(lookup))
                    {
                        var assembly = assemblies[lookup];

                        try
                        {
                            Type[] typesInAssembly = assembly.GetTypes();

                            foreach (Type type in typesInAssembly)
                            {
                                if (namespaces.Contains(type.Namespace) == false && type.Namespace != String.Empty && type.Namespace != null)
                                {
                                    namespaces.Add(type.Namespace);
                                    typesNamespaces.AppendLine(usingKeyword + NamespaceFix(type.Namespace) + semicolon);
                                }
                            }

                            //collect also assemblies location - the assemblies must be added to the compiler parameters
                            assembliesReferenceLocations.Add(assembly.Location);
                        }
                        catch (ReflectionTypeLoadException ex)
                        {
                            if (logger != null)
                            {
                                //log warnings
                                logger.Warn(String.Format("Assembly {0} has been skipped in decision node compilation, because compiler was unable to load one or more of the requested types when compiling decision node. " +
                                                          "See the Loader Exceptions for more information.", name), ex);
                                int i = 1;
                                foreach (Exception loaderException in ex.LoaderExceptions)
                                {
                                    logger.Warn(String.Format("Loader exception {0}: {1}", i++, loaderException.Message));
                                }
                            }
                        }
                    }
                }
            }

            return(typesNamespaces.ToString());
        }
 protected override void CreateImporter(TraceLabSDK.ComponentLogger logger)
 {
     TestComponent = new PreprocessorStemmerComponent(logger);
 }
Пример #5
0
 protected override void CreateImporter(TraceLabSDK.ComponentLogger logger)
 {
     TestImporter = new PoirotXMLImporter(logger);
 }
Пример #6
0
 public RecallMetricComputation(double threshold, TraceLabSDK.ComponentLogger logger)
 {
     m_logger    = logger;
     m_threshold = threshold;
     s_rankTest  = new WilcoxonSignedRankTest(new Recall(threshold));
 }
Пример #7
0
 protected override void CreateImporter(TraceLabSDK.ComponentLogger logger)
 {
     TestComponent = new TracerComponent(logger);
 }
Пример #8
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 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;
 }