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

JS expression bug #44

Closed
inutano opened this issue Apr 13, 2022 · 7 comments
Closed

JS expression bug #44

inutano opened this issue Apr 13, 2022 · 7 comments

Comments

@inutano
Copy link
Collaborator

inutano commented Apr 13, 2022

In short: CWL Expression が JS Expression と解釈されて参照できずに死ぬエラーっぽい。

何が問題か: Workflow の inputs で指定された fastq のファイル名を改変してツールの出力名に指定しようとして valueFrom: $(inputs.fastq.nameroot) をしたら JS が走って TypeError: Cannot read properties of undefined (reading 'nameroot') というエラーを吐いて死ぬ。

問題の箇所:

valueFrom: $(inputs.fastq.nameroot).trim.uniq.bam

        valueFrom: $(inputs.fastq.nameroot).trim.uniq.bam

実行時のエラー:

ERROR Expecting value: line 1 column 1 (char 0)
script was:
01 "use strict";
02 var inputs = {
03     "filter_alignments": "0x4",
04     "ignore_previous_version": true,
05     "include_header": true,
06     "input_file": {
07         "location": "file:///Users/inutano/work/machima/cache/fb8c843f8643626cef3a7377e298f7ad/SRR2078969_1.trim.sam",
08         "basename": "SRR2078969_1.trim.sam",
09         "nameroot": "SRR2078969_1.trim",
10         "nameext": ".sam",
11         "class": "File",
12         "checksum": "sha1$f9900f5d66035755bdd245c20d7cb148ff3cddaf",
13         "size": 1317267819,
14         "http://commonwl.org/cwltool#generation": 0
15     },
16     "output_bam": true,
17     "output_filename": "aln.bam",
18     "skip_alignments": 42,
19     "threads": 4
20 };
21 var self = "aln.bam";
22 var runtime = {
23     "tmpdir": null,
24     "outdir": null
25 };
26 (function(){return ((inputs.fastq.nameroot));})()
stdout was: ''
stderr was: 'evalmachine.<anonymous>:26
(function(){return ((inputs.fastq.nameroot));})()
                                  ^

TypeError: Cannot read properties of undefined (reading 'nameroot')
    at evalmachine.<anonymous>:26:35
    at evalmachine.<anonymous>:26:48
    at Script.runInContext (node:vm:139:12)
    at Script.runInNewContext (node:vm:144:17)
    at Object.runInNewContext (node:vm:298:38)
    at Socket.<anonymous> ([eval]:11:57)
    at Socket.emit (node:events:527:28)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:293:11)
    at Socket.Readable.push (node:internal/streams/readable:234:10)'

環境:

cwltool --version 
/Users/inutano/.venv/bin/cwltool 3.1.20220224085855

cc. @suecharo @tom-tan @manabuishii

@inutano
Copy link
Collaborator Author

inutano commented Apr 13, 2022

ちなみに、これしか使わんのなら標準のExpressionでいけるから InlineJSExpression の requirements いらんのではと思って外すとこんなメッセージが出てくる。

ERROR [step samtools-view] Cannot make job: Expression evaluation error:
Syntax error in parameter reference 'inputs.fastq.nameroot': inputs does not contain key 'fastq'. This could be due to using Javascript code without specifying InlineJavascriptRequirement.

以前は動いていたが cwltool のバージョンを上げたので、Workflow の inputs を step の invalueFrom して参照できないように cwltool の仕様が変更した、あるいは以前通っていたのはバグだった、、、?

@inutano
Copy link
Collaborator Author

inutano commented Apr 13, 2022

The value of inputs in the parameter reference or expression must be the input object to the workflow step after assigning the source values, applying default, and then scattering. The order of evaluating valueFrom among step input parameters is undefined and the result of evaluating valueFrom on a parameter must not be visible to evaluation of valueFrom on other parameters.
https://www.commonwl.org/v1.2/Workflow.html#WorkflowStepInput

なので Workflow の inputs が取れないのが仕様っぽい。じゃあ Workflow.inputs を取るにはどうすれば?

@tom-tan
Copy link
Member

tom-tan commented Apr 13, 2022

WorkflowStepInput.valueFrom の記述を確認すると

The value of inputs in the parameter reference or expression must be the input object to the workflow step after assigning the source values, applying default, and then scattering.

かぶった!

@tom-tan
Copy link
Member

tom-tan commented Apr 13, 2022

対象のステップの引数の sourcefastq を渡せばいけると思います。

      output_filename:
        source: fastq
        valueFrom: $(self.nameroot).trim.uniq.bam

@inutano
Copy link
Collaborator Author

inutano commented Apr 13, 2022

in:
  fastq: fastq
  output_filename:
    valueFrom: $(inputs.fastq.nameroot).trim.uniq.bam

かなと思ったらそっちの方がいいですね!ありがとうございます!

@inutano
Copy link
Collaborator Author

inutano commented Apr 13, 2022

しかし何故前は動いていたのか、、

@inutano inutano closed this as completed Apr 13, 2022
@tom-tan
Copy link
Member

tom-tan commented Apr 13, 2022

common-workflow-language/cwltool#1330 もそうですが、ネストされた expression 中の inputs の伝播周りの挙動はちょっと怪しい…

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