<commit_before>#This file contain example experiment and in the futur some generic experiment(for example for PLearn)
import sys

def example1(state, channel):

    print "example experiment"
    
    return channel.COMPLETE
    #return channel.INCOMPLETE #if the job is not finished, not tested

def theano_example(state, channel):
    import theano
    import theano.tensor as T
    a=T.scalar()
    b=T.scalar()
    c=a+b
    f=theano.function([a,b],c)
    print f(2,3)
    return channel.COMPLETE

def example2(state, channel):
    f=open("file","w")
    f.write("some results!")
    f.close()
    return channel.COMPLETE


def theano_test_return(state, channel):
    """
    This experiment allow to test different test case

    state param used wanted_return
    """
    state.will_return = state.wanted_return
    if state.wanted_return == 'raise':
        raise Exception("This jobs raise an error")    
    elif state.wanted_return == 'incomplete':
        return channel.INCOMPLETE
    elif state.wanted_return == 'complete':
        return channel.COMPLETE
    elif state.wanted_return == 'sysexit':
        sys.exit()


<commit_msg>added an example_sleep experiment to help test jobman.<commit_after>#This file contain example experiment and in the futur some generic experiment(for example for PLearn)
import sys, time

def example1(state, channel):

    print "example experiment"
    
    return channel.COMPLETE
    #return channel.INCOMPLETE #if the job is not finished, not tested

def theano_example(state, channel):
    import theano
    import theano.tensor as T
    a=T.scalar()
    b=T.scalar()
    c=a+b
    f=theano.function([a,b],c)
    print f(2,3)
    return channel.COMPLETE

def example2(state, channel):
    f=open("file","w")
    f.write("some results!")
    f.close()
    return channel.COMPLETE


def theano_test_return(state, channel):
    """
    This experiment allow to test different test case

    state param used wanted_return
    """
    state.will_return = state.wanted_return
    if state.wanted_return == 'raise':
        raise Exception("This jobs raise an error")    
    elif state.wanted_return == 'incomplete':
        return channel.INCOMPLETE
    elif state.wanted_return == 'complete':
        return channel.COMPLETE
    elif state.wanted_return == 'sysexit':
        sys.exit()



def example_sleep(state, channel):
    print "start of example_sleep for %ss"%str(state.sleep)
    time.sleep(state.sleep)
    print "end of example_sleep"
    return channel.COMPLETE
{'fraction_non_alphanumeric': 0.0967869892899643, 'fraction_numerical': 0.0031733439111463705, 'mean_word_length': 3.260135135135135, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6500075', 'n_tokens_mistral': 763, 'n_tokens_neox': 757, 'n_words': 226}