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

Main script class name collides with variable names in global scope #113

Closed
manuelesimi opened this issue Feb 26, 2016 · 10 comments
Closed
Milestone

Comments

@manuelesimi
Copy link
Collaborator

The onComplete event handler seems to fail when nextflow is running on an ubuntu machine.
The error reported is:

ERROR ~ No signature of method: static workflow.onComplete() is applicable for argument types: (workflow$_run_closure2) values: [workflow$_run_closure2@25e2ab5a]

Here's a simple workflow that I used to the error:

#!/usr/bin/env nextflow
_stringToEcho = ['Hello from $HOSTNAME'].channel()
process EchoStringToStandardOut {

input:
val stringToEcho from _stringToEcho

output:
stdout echo into _echo

shell:

    '''
echo  "!{stringToEcho}"
    '''
}
workflow.onComplete {
println "Workflow execution summary"
println "---------------------------"
println "Workflow completed at: $workflow.complete"
println "Duration: ${workflow.duration}"
println "Execution status: ${ workflow.success ? 'OK' : 'failed' }"
if (!  workflow.success) {
println "Error message: $workflow.errorMessage"
}
println "Files generated by the execution are available in $workflow.workDir"
println "---------------------------"

The same workflow executed on a Mac works well.
This is the configuration of the two machines as reported in the .nextflow.log:

Mac OS machine runtime:

  Version: 0.17.3 build 3495
  Modified: 18-02-2016 11:00 UTC (06:00 EDT)
  System: Mac OS X 10.10.2
  Runtime: Groovy 2.4.5 on Java HotSpot(TM) 64-Bit Server VM 1.8.0_51-b16

Ubuntu manchine runtime:

  Version: 0.17.3 build 3495
  Modified: 18-02-2016 11:00 UTC
  System: Linux 3.13.0-74-generic
  Runtime: Groovy 2.4.5 on Java HotSpot(TM) 64-Bit Server VM 1.8.0_72-b15
  Encoding: UTF-8 (UTF-8)

Attached is the full log reported by nextflow when running on ubuntu and failing.

nextflow.txt

@pditommaso
Copy link
Member

Hi Manuele,

What if you run this command:

echo "workflow.onComplete { println 'DONE' }" | nextflow run - 

@manuelesimi
Copy link
Collaborator Author

That works:


ubuntu@frontend001:~$ echo "workflow.onComplete { println 'DONE' }" | nextflow run - 
N E X T F L O W  ~  version 0.17.3
DONE
ubuntu@frontend001:~$

@pditommaso
Copy link
Member

I'm unable to replicate problem. What if you remove the process part in the script you have posted?

@manuelesimi
Copy link
Collaborator Author

Now it's very minimal but I still get the error:

ubuntu@frontend001:~$ cat workflow.nf

workflow.onComplete {
println "---------------------------"
}

ubuntu@frontend001:~$ nextflow workflow.nf

N E X T F L O W  ~  version 0.17.3
Launching workflow.nf
ERROR ~ No signature of method: static workflow.onComplete() is applicable for argument types: (workflow$_run_closure1) values: [workflow$_run_closure1@1359c03a]

-- Check script 'workflow.nf' at line: 1 or see '.nextflow.log' file for more details
ubuntu@frontend001:~$

@pditommaso
Copy link
Member

I'm starting to think there's a hidden special character in your script, otherwise it should fail also the one liner

@manuelesimi
Copy link
Collaborator Author

You might be right. But I'm unable to detect it.
I wrote from scratch another workflow script (named workflow2.nf) on the ubuntu machine, exactly the same than the one that I scp-ed from mac to ubuntu:

ubuntu@frontend001:~$ cat workflow.nf 
workflow.onComplete { println 'DONE' }
ubuntu@frontend001:~$ cat workflow2.nf 
workflow.onComplete { println 'DONE' }

If I look at their bytes, it's confirmed that they are exactly the same:

ubuntu@frontend001:~$ od -c workflow.nf 
0000000   w   o   r   k   f   l   o   w   .   o   n   C   o   m   p   l
0000020   e   t   e       {       p   r   i   n   t   l   n       '   D
0000040   O   N   E   '       }  \n
0000047
ubuntu@frontend001:~$ od -c workflow2.nf 
0000000   w   o   r   k   f   l   o   w   .   o   n   C   o   m   p   l
0000020   e   t   e       {       p   r   i   n   t   l   n       '   D
0000040   O   N   E   '       }  \n
0000047

But then, when I execute them, the results are completely different:

ubuntu@frontend001:~$ nextflow workflow.nf 
N E X T F L O W  ~  version 0.17.3
Launching workflow.nf
ERROR ~ No signature of method: static workflow.onComplete() is applicable for argument types: (workflow$_run_closure1) values: [workflow$_run_closure1@a93621]

 -- Check script 'workflow.nf' at line: 1 or see '.nextflow.log' file for more details

ubuntu@frontend001:~$ nextflow workflow2.nf 
N E X T F L O W  ~  version 0.17.3
Launching workflow2.nf
DONE


@pditommaso
Copy link
Member

Oh, I got it. You named that script workflow also before, isn't right? Nextflow scripts are compiled to a Java class having the same name as the file, thus in your case the class name overrides the implicit workflow variable raising that exception (!)

@pditommaso pditommaso changed the title onComplete event handler fails on ubuntu Main script class name collides with variable names in global scope Feb 26, 2016
@manuelesimi
Copy link
Collaborator Author

bingo!
You are right. I renamed the file and it works!
I guess you should have a runtime check in nextflow that validates the filename, if that's a constraint. And that should happen for all the implicit objects used inside a workflow script.
In the NextflowWorkbench we will add such checks too, so the user is informed as soon as it types the workflow name.

@pditommaso
Copy link
Member

I think I can manage to generate a class name with a random suffix that will prevent this problem.

@manuelesimi
Copy link
Collaborator Author

That should fix for good the issue.

pditommaso added a commit that referenced this issue Mar 25, 2016
pditommaso added a commit that referenced this issue Mar 25, 2016
@pditommaso pditommaso added this to the v0.18.0 milestone Mar 31, 2016
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

2 participants