Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid parameter remapping in workflow.csv does not throw errors #282

Open
mmterpstra opened this issue Nov 6, 2019 · 1 comment
Open

Comments

@mmterpstra
Copy link
Contributor

mmterpstra commented Nov 6, 2019

Parameter remapping in workflow.csv does not throw errors when the target parameter does not exist.
https://rawgit.com/molgenis/molgenis-compute/master/molgenis-compute-core/README.html with workflow.csv:

step,protocol,parameterMapping
step1,protocols/step1.sh,in=input
step2,protocols/step2.sh,wf=workflowName;date=creationDate;strings=step1.out

you can do this and it happily runs (molgenis never complains about pinkunicornsdancingonrainbows while is is never set anywhere):

step,protocol,parameterMapping
step1,protocols/step1.sh,in=input;pinkunicornsdancingonrainbows=input
step2,protocols/step2.sh,wf=workflowName;date=creationDate;strings=step1.out

For archival reasons

@mmterpstra
Copy link
Contributor Author

mmterpstra commented Jan 9, 2020

workaround, partial should actually check the protocols for the parameters to remap instead of the parameterfiles:

...oldcode...

edit: now works on my pc:

#!/usr/bin/env python
import sys
import time

#use workflow
try:
    workflow = open(sys.argv[1])
except:
    print('Die cannot open file' + sys.argv[1])
    exit


def info(info):
  print >> sys.stderr, "## %s ## INFO ## %s"  % (time.asctime(),info)

def errornofail(error):
  print >> sys.stderr, "## %s ## ERROR ## %s"  % (time.asctime(),error)


def error(error):
  print >> sys.stderr, "## %s ## ERROR ## %s"  % (time.asctime(),error)
  exit(1)


info("Analysing " + sys.argv[1])

protocolfiles = []

try:
    steps = {}
    parameterseen = {}
    for i, line in enumerate(workflow):
        if i == 0: 
            continue
        line=line.rstrip()
        csv= line.split(",")
	if csv[0].startswith("#"):
       	    continue
        if csv[0] in steps:
            steps[csv[0]]=steps[csv[0]]+1
        else:
            steps[csv[0]]=1
	protocolfiles.append(csv[1])
        #print csv[0]
        #print("node "+ csv[0])
        remap=csv[2].split(";")
        #print edges
        for element in remap:
            element.rstrip()
            if("=" in element and  element != ""):
                parameterseen[element.split("=")[0]]=0
finally:
    workflow.close()
    
#for parameterfile in sys.argv[2::]:
#    info('processing ' + parameterfile)
#    try:
#        parameters = open(parameterfile)
#    except:
#        print('Die cannot open file ' + parameterfile)
#        exit
#    try:
#        for i, line in enumerate(parameters):
#            line = line.rstrip()
#            csv = line.split(",")
#            if(csv[0] in parameterseen):
#                parameterseen[csv[0]]=parameterseen[csv[0]]+1
#    finally:
#        parameters.close()

for protocolfile in protocolfiles:
    info('processing ' + protocolfile)
    try:
        protocol = open(protocolfile)
    except:
        print('Die cannot open file ' + protocolfile)
        exit
    try:
        for i, line in enumerate(protocol):
            line = line.rstrip()
            if not(line.startswith("#list") or line.startswith("#string")):
                continue
            ssv = line.split(" ")
            csv = ssv[1].split(",")
            for val in csv:
                if(val in parameterseen):
                    parameterseen[val]+=1
    finally:
	protocol.close()




fail=0
for key in parameterseen.keys():
    if(parameterseen[key] < 1):
        errornofail("Parameter '" + key + "' not in parameter files")
        fail=1
if(fail == 1):
    exit(1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant