예제 #1
0
    def test_logger(self):
        """The WF logger should not affect other loggers."""
        from workflow import engine

        logging.root.handlers = []
        engine.LOG.handlers = []

        other_logger = logging.getLogger('other')
        wf_logger = engine.get_logger('workflow.test')

        test_io = StringIO()
        root_io = StringIO()
        other_io = StringIO()

        logging.root.addHandler(logging.StreamHandler(root_io))
        other_logger.addHandler(logging.StreamHandler(other_io))
        wf_logger.addHandler(logging.StreamHandler(test_io))

        # set the root level to WARNING; wf should honour parent level
        logging.root.setLevel(logging.WARNING)

        logging.warn('root warn')
        other_logger.warn('other warn')
        wf_logger.warn('wf warn')

        logging.info('root info')
        other_logger.info('other info')
        wf_logger.info('wf info')

        self.assertEqual(root_io.getvalue(), "root warn\nother warn\n",
                         "Root logger should have two msgs")
        self.assertEqual(other_io.getvalue(), "other warn\n",
                         "Other logger should have one msg")
        self.assertEqual(test_io.getvalue(), "wf warn\n",
                         "Wf logger should have one msg")

        root_io.seek(0)
        other_io.seek(0)
        test_io.seek(0)

        # now set too to DEBUG and wf to INFO
        logging.root.setLevel(logging.DEBUG)
        engine.reset_all_loggers(logging.WARNING)

        logging.warn('root warn')
        other_logger.warn('other warn')
        wf_logger.warn('wf warn')

        logging.info('root info')
        other_logger.info('other info')
        wf_logger.info('wf info')

        self.assertEqual(root_io.getvalue(), "root warn\nother warn\n"
                         "root info\nother info\n",
                         "Root logger should have four msgs")
        self.assertEqual(other_io.getvalue(), "other warn\nother info\n",
                         "Other logger should have two msg")
        self.assertEqual(test_io.getvalue(), "wf warn\n",
                         "Wf logger should have one msg")
예제 #2
0
    def test_logger(self):
        """The WF logger should not affect other loggers."""
        from workflow import engine

        logging.root.handlers = []
        engine.LOG.handlers = []

        other_logger = logging.getLogger('other')
        wf_logger = engine.get_logger('workflow.test')

        test_io = StringIO()
        root_io = StringIO()
        other_io = StringIO()

        logging.root.addHandler(logging.StreamHandler(root_io))
        other_logger.addHandler(logging.StreamHandler(other_io))
        wf_logger.addHandler(logging.StreamHandler(test_io))

        # set the root level to WARNING; wf should honour parent level
        logging.root.setLevel(logging.WARNING)

        logging.warn('root warn')
        other_logger.warn('other warn')
        wf_logger.warn('wf warn')

        logging.info('root info')
        other_logger.info('other info')
        wf_logger.info('wf info')

        self.assertEqual(root_io.getvalue(), "root warn\nother warn\n",
                         "Root logger should have two msgs")
        self.assertEqual(other_io.getvalue(), "other warn\n",
                         "Other logger should have one msg")
        self.assertEqual(test_io.getvalue(), "wf warn\n",
                         "Wf logger should have one msg")

        root_io.seek(0)
        other_io.seek(0)
        test_io.seek(0)

        # now set too to DEBUG and wf to INFO
        logging.root.setLevel(logging.DEBUG)
        engine.reset_all_loggers(logging.WARNING)

        logging.warn('root warn')
        other_logger.warn('other warn')
        wf_logger.warn('wf warn')

        logging.info('root info')
        other_logger.info('other info')
        wf_logger.info('wf info')

        self.assertEqual(root_io.getvalue(), "root warn\nother warn\n"
                         "root info\nother info\n",
                         "Root logger should have four msgs")
        self.assertEqual(other_io.getvalue(), "other warn\nother info\n",
                         "Other logger should have two msg")
        self.assertEqual(test_io.getvalue(), "wf warn\n",
                         "Wf logger should have one msg")
예제 #3
0
from workflow.engine import get_logger
import os


log = get_logger('workflow.svm_classifier')

# requires lucene to be installed
try:
    from lucene import DefaultSimilarity, TermPositionVector, \
                       Term, IndexSearcher,Field
except:
    log.warning('lucene is not installed, please do not use the lucene specific tasks')

from libs import svm_classifier


def init(svm_model,
         svm_train,
         svm_predict,
         indexer='#indexer',
         train_dir=None,
         test_dir=None,
         output_dir=None):

    def _x(obj, eng):
        eng.setVar('#svm_train', svm_train)
        eng.setVar('#svm_predict', svm_predict)
        eng.setVar('#svm_model', svm_model)
        eng.setVar('#train_dir', train_dir)
        eng.setVar('#test_dir', test_dir)
예제 #4
0
 def __init__(self, *args, **kwargs):
     main_engine.GenericWorkflowEngine.__init__(self, *args, **kwargs)
     self.log = main_engine.get_logger('TalkativeWFE<%d>' %
                                       TalkativeWorkflowEngine.counter)
     TalkativeWorkflowEngine.counter += 1
예제 #5
0
# under the terms of the Revised BSD License; see LICENSE file for
# more details.

import glob
import six
import sys
import os
import imp
import logging
import traceback
import getopt

from workflow import engine as main_engine
from workflow.patterns import PROFILE

log = main_engine.get_logger('workflow.run-worklfow')


def run(selection,
        listwf=None,
        places=None,
        verbose=False,
        profile=None,
        **kwargs):
    """
Example usage: %prog -l
               %prog 1 [to select first workflow to run]

usage: %prog glob_pattern(s) [options]
-l, --listwf: list available workflows
-i, --places = places: list of glob patterns to search for workflows
예제 #6
0
 def __init__(self, *args, **kwargs):
     main_engine.GenericWorkflowEngine.__init__(self, *args, **kwargs)
     self.log = main_engine.get_logger(
         'TalkativeWFE<%d>' % TalkativeWorkflowEngine.counter)
     TalkativeWorkflowEngine.counter += 1
예제 #7
0
# more details.

import glob
import six
import sys
import os
import imp
import logging
import traceback
import getopt

from workflow import engine as main_engine
from workflow.patterns import PROFILE


log = main_engine.get_logger('workflow.run-worklfow')


def run(selection,
        listwf=None,
        places=None,
        verbose=False,
        profile=None,
        **kwargs):
    """
Example usage: %prog -l
               %prog 1 [to select first workflow to run]

usage: %prog glob_pattern(s) [options]
-l, --listwf: list available workflows
-i, --places = places: list of glob patterns to search for workflows