You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@airavata.apache.org by "Marcus Christie (JIRA)" <ji...@apache.org> on 2017/07/28 13:33:02 UTC

[jira] [Created] (AIRAVATA-2494) Groovy templates throw MissingPropertyException when it doesn't recognize a variable

Marcus Christie created AIRAVATA-2494:
-----------------------------------------

             Summary: Groovy templates throw MissingPropertyException when it doesn't recognize a variable
                 Key: AIRAVATA-2494
                 URL: https://issues.apache.org/jira/browse/AIRAVATA-2494
             Project: Airavata
          Issue Type: Bug
          Components: GFac
            Reporter: Marcus Christie
            Assignee: Shameera Rathnayaka
             Fix For: 0.19



h3. Steps to reproduce
# Add post job command to deployment
# For example, for gaussian 09 on comet in seagrid.org we had (approximately)
{noformat}
mkdir -p "$PWD"_restart; if (ls ./*.chk 1> /dev/null 2>&1); then cp *.chk ${PWD}_restart; fi; if (ls ./*.rwf* 1> /dev/null 2>&1); then mv *.rwf* ${PWD}_restart; fi;
{noformat}

h3. Expected results

Since there are no predefined [script variables|https://github.com/apache/airavata/blob/8bc2dcc4eb3a45c09fa32903c38bd97e349b4599/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/Script.java#L43-L43] in this post job command, it should just pass through. I would expect that once the Groovy templating is applied that the post job command is unchanged.

h3. Actual results

GFac throws an exception. See the stack trace below.


h3. Workaround

For now the workaround is to escape the dollar sign in variables that aren't predefined script variables:

{noformat}
mkdir -p "\$PWD"_restart; if (ls ./*.chk 1> /dev/null 2>&1); then cp *.chk \${PWD}_restart; fi; if (ls ./*.rwf* 1> /dev/null 2>&1); then mv *.rwf* \${PWD}_restart; fi;
{noformat}

h3. Implementation ideas

* Change our implementation of GroovyMap so that if a variable is requested that doesn't exist in the map it will just return that variable back, with a dollar sign in front.  For example, the following would be true
{code}
groovyMap.get("PWD").equals("${PWD}")
{code}
The downside to this approach is that it may make typos harder to find.  But in any case a typo will cause an error so this approach seems preferable because other environment variables like {{$PWD}} won't cause errors and will just pass through.

h3. More information

Stack trace:
{noformat}
2017-07-27 15:36:44,501 [pool-7-thread-24] INFO  o.a.a.gfac.core.GFacUtils process_id=PROCESS_64a60cad-fe27-4f92-a5c5-7
7358d4ae93d, token_id=3d65bf6d-2c9f-4166-a51b-e76e0022bd3b, experiment_id=Clone_of_Clone_of_Testmvrwf_93b1e30c-c79a-4ff
6-8fb6-d76eae96fd16, gateway_id=seagrid - Email list: gw77jobs@scigap.org
2017-07-27 15:36:44,515 [pool-7-thread-24] ERROR o.a.a.g.i.t.DefaultJobSubmissionTask process_id=PROCESS_64a60cad-fe27-
4f92-a5c5-77358d4ae93d, token_id=3d65bf6d-2c9f-4166-a51b-e76e0022bd3b, experiment_id=Clone_of_Clone_of_Testmvrwf_93b1e3
0c-c79a-4ff6-8fb6-d76eae96fd16, gateway_id=seagrid - JobSubmission failed
groovy.lang.MissingPropertyException: No such property: PWD for class: groovy.lang.Binding
        at groovy.lang.Binding.getVariable(Binding.java:63)
        at groovy.lang.Binding.getProperty(Binding.java:105)
        at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:172)
        at groovy.lang.Closure.getPropertyTryThese(Closure.java:312)
        at groovy.lang.Closure.getPropertyDelegateFirst(Closure.java:302)
        at groovy.lang.Closure.getProperty(Closure.java:287)
        at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:50)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:307)
        at groovy.tmp.templates.GStringTemplateScript424$_getTemplate_closure1.doCall(GStringTemplateScript424.groovy:2
)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024)
        at groovy.lang.Closure.call(Closure.java:414)
        at groovy.lang.Closure$WritableClosure.writeTo(Closure.java:844)
        at groovy.lang.Closure$WritableClosure.toString(Closure.java:970)
        at org.apache.airavata.gfac.core.GFacUtils.parseCommands(GFacUtils.java:715)
        at org.apache.airavata.gfac.core.GFacUtils.lambda$createGroovyMap$5(GFacUtils.java:555)
        at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
        at java.util.stream.SortedOps$SizedRefSortingSink.end(SortedOps.java:352)
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
        at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
        at org.apache.airavata.gfac.core.GFacUtils.createGroovyMap(GFacUtils.java:556)
        at org.apache.airavata.gfac.impl.task.DefaultJobSubmissionTask.execute(DefaultJobSubmissionTask.java:72)
        at org.apache.airavata.gfac.impl.GFacEngineImpl.executeTask(GFacEngineImpl.java:814)
        at org.apache.airavata.gfac.impl.GFacEngineImpl.executeJobSubmission(GFacEngineImpl.java:510)
        at org.apache.airavata.gfac.impl.GFacEngineImpl.executeTaskListFrom(GFacEngineImpl.java:386)
        at org.apache.airavata.gfac.impl.GFacEngineImpl.executeProcess(GFacEngineImpl.java:286)
        at org.apache.airavata.gfac.impl.GFacWorker.executeProcess(GFacWorker.java:227)
        at org.apache.airavata.gfac.impl.GFacWorker.run(GFacWorker.java:86)
        at org.apache.airavata.common.logging.MDCUtil.lambda$wrapWithMDC$0(MDCUtil.java:40)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:748)
{noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)