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

terminate called after throwing an instance of 'YAML::BadSubscript' #12

Open
mr-c opened this issue Dec 10, 2024 · 3 comments
Open

terminate called after throwing an instance of 'YAML::BadSubscript' #12

mr-c opened this issue Dec 10, 2024 · 3 comments

Comments

@mr-c
Copy link
Member

mr-c commented Dec 10, 2024

error message:

terminate called after throwing an instance of 'YAML::BadSubscript'
  what():  yaml-cpp: error at line 4, column 17: operator[] call on a scalar (key: "id")
Aborted

test program:

#include "cwl_v1_2.h"

#include <iostream>

/**
 * This test program creates loads and prints a CWL description.
 *
 * It assumes that printing to stdout works (see cwl_output_example).
 * It loads a CWL description from a file and populates C++ classes.
 */


// using shortened cwl:: namespace instead of https___w3id_org_cwl_cwl
namespace cwl = https___w3id_org_cwl_cwl;

int main(int argc, char** argv) {
    if (argc != 2) return 1;

    auto yaml = YAML::LoadFile(argv[1]);
    auto tool = cwl::Workflow{};
    fromYaml(yaml, tool);

    auto y = toYaml(tool);

    YAML::Emitter out;
    out << y;
    std::cout << out.c_str() << "\n";

    return 0;
}

CWL test file

cwlVersion: v1.2
class: Workflow
inputs:
 09first_input: string
 05second_input: int
 01third_input: File
steps:
 zz_step_one:
   run:
     class: ExpressionTool
     inputs: []
     outputs: []
     expression: ${return {}; }
     requirements:
       InlineJavascriptRequirement: {}
   in: []
   out: []
 00_step_two:
   out: []
   run:
     inputs: []
     requirements:
       InlineJavascriptRequirement: {}
     outputs: []
     expression: ${return {}; }
     class: ExpressionTool
   in: []
outputs:
  zz_first_output:
    type: File
    outputSource: 01third_input
  ll_second_output:
    type: string
    outputSource: 09first_input
  aa_third_output:
    type: int
    outputSource: 05second_input
@SGSSGene
Copy link
Collaborator

So, the parser is tripping over at least two things:

  1. The inputs are not given in an expected way. We expect it to be:
inputs:
  - id: 09first_input
    type: string
  - id: 05second_input
    type: int

or in the more compact version:

inputs:
  09first_input:
    type: string
  05second_input
    type: int

This is according to https://www.commonwl.org/v1.2/SchemaSalad.html#Identifier_map_example

collapsing it down to, seems to be valid by

inputs:
  09first_input: string
  05second_input: int

This seems valid according to https://www.commonwl.org/v1.2/SchemaSalad.html#Domain_Specific_Language_for_types but is currently not supported by the schema_salad cpp generator.

  1. There is some trouble with the expression field. It is defined in Workflow.yml as:
    - name: expression
      type: Expression
      doc: |
        The expression to execute.  The expression must return a plain
        Javascript object which matches the output parameters of the
        ExpressionTool.

As far as I can see, the type Expression is no where defined. It is neither a primitive type nor a record. I go for primitives by this list https://www.commonwl.org/v1.2/CommandLineTool.html#CWLType

@mr-c
Copy link
Member Author

mr-c commented Dec 11, 2024

For Expression https://github.com/common-workflow-language/cwl-v1.2/blob/707ebcd2173889604459c5f4ffb55173c508abb3/Process.yml#L626-L634

It will need special handling, see

@SGSSGene
Copy link
Collaborator

Thank you! That was what I needed.

So there are two issues, that need separate fixing:

  1. typeDSL is not handled in scheme_salad, but TDL can partially handle this. The code must move from TDL to schema_salad cpp-generator. (https://github.com/deNBI-cibi/tool_description_lib/blob/1f06b09ad61b3845495ce2acfa783af693c2c112/src/tdl/convertToCWL.cpp#L32-L58)

  2. Handling of Expression needs a specialize std::string like type. and detect similar to how Any is detected.

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