cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Input not completely consumed

debra_paponette
New Contributor

I have a parent pipeline calling another. Which runs successfully when you validate but errors when you execute. Why is this? It seems that the issue is coming form a pyton script in the child pipeline. The purpose of the script is the call a bat.file on a server and wait for the .bat file to complete and return the error message if any before the pipleline completes. If i validate the parent pipeline it calls the child pipeline and execute this script without issues but this is not the case when i execute. I am either getting an error saying on the script snap โ€œInput not completely consumedโ€ or other times โ€œroot pipeline no longer runningโ€

the following is the script code

Import the interface required by the Script snap.

from com.snaplogic.scripting.language import ScriptHook
import java.util, os, subprocess

class TransformScript(ScriptHook):
def init(self, input, output, error, log):
self.input = input
self.output = output
self.error = error
self.log = log

# The "execute()" method is called once when the pipeline is started
# and allowed to process its inputs or just send data to its outputs.
def execute(self):
    filepath="C:\\Profisee\\ProfiseeMatch.bat & exit"
    p = subprocess.Popen(filepath, shell=True, stdout = subprocess.PIPE)
    p.communicate()
    p.wait()
    
    self.output.write (p.returncode)

The Script Snap will look for a ScriptHook object in the โ€œhookโ€

variable. The snap will then call the hookโ€™s โ€œexecuteโ€ method.

hook = TransformScript(input, output, error, log)

Any ideas what may be causing this and how this can be solved?

1 REPLY 1

akidave
Employee
Employee

See the example python script in the doc page https://docs-snaplogic.atlassian.net/wiki/spaces/SD/pages/1439321/Script

The script needs to consume all the input documents which are passed in its input view. If you do not need the input docs, you could add a loop to drop the docs

def execute(self):
    while self.input.hasNext():
        data = self.input.next()

    filepath="C:\\Profisee\\ProfiseeMatch.bat & exit"
    p = subprocess.Popen(filepath, shell=True, stdout = subprocess.PIPE)
    p.communicate()
    p.wait()
    self.output.write (p.returncode)