<commit_before>from datapipe import *

def test_example():

    # Create test file
    open('input.txt', 'w').close()

    from datapipe import Task, Input, LocalFile, require

    # New tasks are defined by inheriting from an existing Task
    class AddLines(Task):

        # The inputs can be anything the task depends on:
        # Local and remote files, python objects, numpy arrays, ...
        infile = Input()
        count = Input(default=1)
        text = Input(default='This is some text')

        # The outputs are defined dynamically (with access to the inputs)
        def outputs(self):
            return LocalFile(self.infile.get().replace('.txt', '.AddLines.txt'))

        # The actual task is defined as a function with access to inputs and outputs
        def run(self):
            with open(self.infile.get()) as f:
                with open(self.outputs().get(), 'w') as g:
                    g.write(f.read())
                    for i in range(self.count):
                        g.write(self.text + '\n')

    # Create initial Targets
    infile = LocalFile('input.txt')

    # Define the pipeline
    task1 = AddLines(infile, count=2)
    task2 = AddLines(task1.outputs(), count=3, text='This is some more text')

    # Require a target to execute all tasks needed to produce it
    require(task2.outputs())

<commit_msg>Modify test case<commit_after>from datapipe import *

def test_example():

    # Create test file
    open('/tmp/input.txt', 'w').close()

    from datapipe import Task, Input, LocalFile, require

    # New tasks are defined by inheriting from an existing Task
    class AddLines(Task):

        # The inputs can be anything the task depends on:
        # Local and remote files, python objects, numpy arrays, ...
        infile = Input()
        count = Input(default=1)
        text = Input(default='This is some text')

        # The outputs are defined dynamically (with access to the inputs)
        def outputs(self):
            return LocalFile(self.infile.path().replace('.txt', '.AddLines.txt'))

        # The actual task is defined as a function with access to inputs and outputs
        def run(self):
            with self.infile.open() as f:
                with self.outputs().open('w') as g:
                    g.write(f.read())
                    for i in range(self.count):
                        g.write(self.text + '\n')

    # Create initial Targets
    infile = LocalFile('/tmp/input.txt')

    # Define the pipeline
    task1 = AddLines(infile, count=2)
    task2 = AddLines(task1.outputs(), count=3, text='This is some more text')

    # Require a target to execute all tasks needed to produce it
    require(task2.outputs())


{'fraction_non_alphanumeric': 0.10524372230428361, 'fraction_numerical': 0.0051698670605613, 'mean_word_length': 2.2796610169491527, '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': '3170600', 'n_tokens_mistral': 753, 'n_tokens_neox': 721, 'n_words': 267}