Skip to content

Wrong assumption on conformance test 309 (secontaryfiles/rename-inputs.cwl) #127

@GlassOfWhiskey

Description

@GlassOfWhiskey

This is a portion of the content of the rename-inputs.cwl file for conformance test 309:

inputs:
- id: inputWithSecondary
  type: File
  doc: |
    This input will with a secondary file `.accessory`. You could create these files (and its accessory) with:
    ```bash
    touch secondary_file_test.txt
    touch secondary_file_test.txt.accessory
    ```
  secondaryFiles:
    - .accessory
    - |
      ${
        function resolveSecondary(base, secPattern) {
          if (secPattern[0] == '^') {
            var spl = base.split('.');
            var endIndex = spl.length > 1 ? spl.length - 1 : 1;
            return resolveSecondary(spl.slice(undefined, endIndex).join("."), secPattern.slice(1));
          }
          return base + secPattern;
        }
        return [{
            "class": "File",
            "location": self.secondaryFiles[0].location,
            "basename": resolveSecondary(self.basename, '^.accessory')
        }];
      }

The JavaScript expression of the second entry in the secondaryFiles list explicitly refers to self.secondaryFiles[0], which must have been evaluated BEFORE starting to evaluate the expression.

In cwltool (and I assume also in other CWL-compliant tools) this works correctly because the secondaryFiles list is evaluated sequentially and in order. This is not a requirement for the CWL standard, but an out-of-order evaluation makes the test fail.

However, relying on a particular evaluation order can lead to an undesired behaviour also in sequential evaluations. For example, the following expression, which should apparently be as fine as the previous one. fails also within cwltool:

inputs:
- id: inputWithSecondary
  type: File
  doc: |
    This input will with a secondary file `.accessory`. You could create these files (and its accessory) with:
    ```bash
    touch secondary_file_test.txt
    touch secondary_file_test.txt.accessory
    ```
  secondaryFiles:
    - |
      ${
        function resolveSecondary(base, secPattern) {
          if (secPattern[0] == '^') {
            var spl = base.split('.');
            var endIndex = spl.length > 1 ? spl.length - 1 : 1;
            return resolveSecondary(spl.slice(undefined, endIndex).join("."), secPattern.slice(1));
          }
          return base + secPattern;
        }
        return [{
            "class": "File",
            "location": self.secondaryFiles[1].location,
            "basename": resolveSecondary(self.basename, '^.accessory')
        }];
      }
    - .accessory

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