Skip to content

variable isolation issue #4872

@eldadkd

Description

@eldadkd

Bug report

Expected behavior and actual behavior

Expected behavior:
println("calculateCPUs overrideValue = $overrideValue") should print:
alculateCPUs overrideValue = null

Actual behavior:
what prints out is:
calculateCPUs overrideValue = 1 GB

Steps to reproduce the problem

running this nf script:

include {calculateMem; calculateCPUs} from "./func.nf"

workflow {
    p1()
}


process p1 {
    debug true
    memory {calculateMem(overrideValue: "1 GB", task:task)}
    cpus {calculateCPUs(task: task)}

    exec:
    println("Hi")

}

and this script:

def calculateMem(Map args) {
    overrideValue = args.get('overrideValue', null)
    task = args.get('task')
    return 1.GB
}


def calculateCPUs(Map args) {
    overrideValue = args.get('overrideValue')
    task = args.get('task')

    taskMemory = task.memory.toGiga()
    println("taskMemory from inside the calculateCPUs: $taskMemory")
    println("calculateCPUs args['overrideValue']: ${args.get('overrideValue')}")
    println("calculateCPUs overrideValue = $overrideValue")
    return 1
}

after calling this line taskMemory = task.memory.toGiga() on calculateCPUs method
overrideValue value is changed from null to the value given to calculateMem

Program output

Launching `/Users/eldadkd/Library/Application Support/JetBrains/IdeaIC2023.3/scratches/scratch_4.txt` [high_poisson] DSL2 - revision: 47ee90e704
executor >  local (1)
[77/7b381c] process > p1 [100%] 1 of 1 ✔
taskMemory from inside the calculateCPUs: 1
calculateCPUs args['overrideValue']: null
calculateCPUs overrideValue = 1 GB
Hi

Environment

  • Nextflow version: [22.10.7]
  • Java version: [java version "17.0.6" 2023-01-17 LTS]
  • Operating system: [macOS]
  • Bash version: [zsh 5.9 (x86_64-apple-darwin23.0)]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions