Giter Club home page Giter Club logo

cwl-ts's Introduction

cwl-ts

CircleCI npm version

CWL-ts is a data model library for the Common Workflow Language made for use in TypeScript and JavaScript (primarily client-side) applications.

It supports JSON schemas and mappings for draft-3, draft-4, and v1.0. Draft-2 support is SevenBridges flavored.

Installation

npm install cwlts

Build

The npm package can be built locally by running the following command. It will generate .d.ts and compiled .js files into the /lib directory.

./scripts/package.sh

Mappings

lib/mappings contains TypeScript interfaces that can be used for type hinting when working with CWL documents in TS/JS.

Schemas

lib/schemas contains JSON Schema definitions for CommandLineTool, Workflow and ExpressionTool for each draft/version. They can be used with a JSON Schema validator to ensure schema validity of a CWL document.

Models [WIP]

lib/models contains TypeScript classes representing CWL entities. Models are still in early development, so many intended features are not implemented yet or don't function properly. The purpose of these models is to provide a set of methods that will facilitate working with CWL in a client-side application--one that graphically displays CWL documents or creates them. They should abstract differences between drafts and versions, provide a consistent API, and always generate correct and valid CWL documents.

CommandLineToolModel should:

  • generate command line when supplied test data
  • evaluate and validate expressions
  • enable operations on complex child objects (inputs, outputs, arguments, etc)

WorkflowModel should:

  • generate DAG of workflow
  • enable adding and connecting steps
  • enable operations on complex child objects (inputs, outputs, steps, etc)

cwl-ts's People

Contributors

bogdang989 avatar ivanbatic avatar marijanlekic avatar matebordas avatar mayacoda avatar michael-kotliar avatar milosdanilov avatar mr-c avatar starvingmarvin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cwl-ts's Issues

Generate command line for v1.0 tools

sbg:draft-2 tools can generate their own command line by passing baseCommand, inputs, arguments and stdin/stdout through a series of parsers which resolve each chunk recursively and return a CommandLinePart

How this works can be found in SBDraft2CommandLineToolModel.ts:185:

private generateCommandLineParts(): Promise<CommandLinePart[]> {
    // creates a flat list of inputs and arguments, sorting them accordingly in the process

    // creates a flat list of job values (flattens record fields, for example)
   
    // runs baseCommands through the parser, returns array of Promises

    // runs flattened inputs and arguments through the parser

    // runs streams through the parser

    // joins and returns all Promise arrays, filtering null promises (if job value was null)
}

The same needs to be done with v1.0 tools, keeping in mind any differences in command lines between draft-2 and v1.0.

Also, I'm sure there are bugs in the current command line, for example I don't think some cases where valueFrom is defined are covered properly.

Missing dependency in npm package

I get the following message when running ng serve on a project which uses cwl-ts:

ERROR in ./node_modules/cwlts/models/helpers/JSExecutor.js
Module not found: Error: Can't resolve 'vm' in './node_modules\cwlts\models\helpers'

Running npm install vm solves this error.
I think that the vm module needs to be added to package.json

Problem with valueFrom field

rabix/composer#472

Constructs like

    valueFrom: O=$(runtime.outdir)/rna_metrics.txt

result in instability - the command line preview will show errors, which disappear and then reappear with edits in the code pane.

@gungorbudak has tracked these to the latest cwl-ts release

Add timeout on js execution

Expression execution is susceptible to infinite loops. The JSExecutor used by default doesn't timeout, even though there is a timeout set in the options. This might be a bug caused by the nested Promises used to make execution asynchronous.

JSExecutor.ts

 static evaluate(version: CWLVersion, expr: string, job?: any, self?: any): Promise<any> {
        const options = {
            displayErrors: true,
            timeout: 1000
        };
       ...
}

build package leads to typescript compiler error

Hi all!

I try to compile my own version of CWL-TS.

I followed readme instructions by running scripts/package.sh.
However it raises many typescript compiler errors.

Has someone been able to build CWL-TS locally ?

Thanks!

Y.

CWL v1.0

CWL v1.0 has now been released! ๐ŸŽ‰

  • Draft-4 should be renamed to v1
  • Mappings should reflect new features

Error: Can't resolve 'vm'

I created a simple Angular application and imported cwlts/models. When the application is compiled it complains about 'vm' module not present.

It is fixed if I install 'vm' (npm install vm).

Maybe you should add the 'vm' module to the list of dependencies in your package.json.

ERROR in ./node_modules/cwlts/models/helpers/JSExecutor.js
Module not found: Error: Can't resolve 'vm' in '/Users/eduardo/Development/glue/cwlts-angular/node_modules/cwlts/models/helpers'
resolve 'vm' in '/Users/eduardo/Development/glue/cwlts-angular/node_modules/cwlts/models/helpers'
  Parsed request is a module
  using description file: /Users/eduardo/Development/glue/cwlts-angular/node_modules/cwlts/package.json (relative path: ./models/helpers)
    Field 'browser' doesn't contain a valid alias configuration
    resolve as module
      looking for modules in /Users/eduardo/Development/glue/cwlts-angular/
        using description file: /Users/eduardo/Development/glue/cwlts-angular/package.json (relative path: .)
          Field 'browser' doesn't contain a valid alias configuration
          using description file: /Users/eduardo/Development/glue/cwlts-angular/package.json (relative path: ./vm)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Users/eduardo/Development/glue/cwlts-angular/vm doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Users/eduardo/Development/glue/cwlts-angular/vm.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Users/eduardo/Development/glue/cwlts-angular/vm.js doesn't exist
            as directory
              /Users/eduardo/Development/glue/cwlts-angular/vm doesn't exist
      /Users/eduardo/Development/glue/cwlts-angular/node_modules/cwlts/models/helpers/node_modules doesn't exist or is not a directory
      /Users/eduardo/Development/glue/cwlts-angular/node_modules/cwlts/models/node_modules doesn't exist or is not a directory
      /Users/eduardo/Development/glue/cwlts-angular/node_modules/node_modules doesn't exist or is not a directory
      /Users/eduardo/Development/glue/node_modules doesn't exist or is not a directory
      /Users/eduardo/Development/node_modules doesn't exist or is not a directory
      /Users/eduardo/node_modules doesn't exist or is not a directory
      /Users/node_modules doesn't exist or is not a directory
      /node_modules doesn't exist or is not a directory
      looking for modules in /Users/eduardo/Development/glue/cwlts-angular/node_modules/cwlts/node_modules
        using description file: /Users/eduardo/Development/glue/cwlts-angular/node_modules/cwlts/package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
      looking for modules in /Users/eduardo/Development/glue/cwlts-angular/node_modules
        using description file: /Users/eduardo/Development/glue/cwlts-angular/package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
          using description file: /Users/eduardo/Development/glue/cwlts-angular/node_modules/cwlts/package.json (relative path: ./node_modules/vm)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
          using description file: /Users/eduardo/Development/glue/cwlts-angular/package.json (relative path: ./node_modules/vm)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Users/eduardo/Development/glue/cwlts-angular/node_modules/cwlts/node_modules/vm doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Users/eduardo/Development/glue/cwlts-angular/node_modules/vm doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Users/eduardo/Development/glue/cwlts-angular/node_modules/cwlts/node_modules/vm.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Users/eduardo/Development/glue/cwlts-angular/node_modules/vm.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Users/eduardo/Development/glue/cwlts-angular/node_modules/cwlts/node_modules/vm.js doesn't exist
              /Users/eduardo/Development/glue/cwlts-angular/node_modules/vm.js doesn't exist
            as directory
              /Users/eduardo/Development/glue/cwlts-angular/node_modules/cwlts/node_modules/vm doesn't exist
            as directory
              /Users/eduardo/Development/glue/cwlts-angular/node_modules/vm doesn't exist
[/Users/eduardo/Development/glue/cwlts-angular/vm]
[/Users/eduardo/Development/glue/cwlts-angular/vm.ts]
[/Users/eduardo/Development/glue/cwlts-angular/vm.js]
[/Users/eduardo/Development/glue/cwlts-angular/node_modules/cwlts/models/helpers/node_modules]
[/Users/eduardo/Development/glue/cwlts-angular/node_modules/cwlts/models/node_modules]
[/Users/eduardo/Development/glue/cwlts-angular/node_modules/node_modules]
[/Users/eduardo/Development/glue/node_modules]
[/Users/eduardo/Development/node_modules]
[/Users/eduardo/node_modules]
[/Users/node_modules]
[/node_modules]
[/Users/eduardo/Development/glue/cwlts-angular/node_modules/cwlts/node_modules/vm]
[/Users/eduardo/Development/glue/cwlts-angular/node_modules/vm]
[/Users/eduardo/Development/glue/cwlts-angular/node_modules/cwlts/node_modules/vm.ts]
[/Users/eduardo/Development/glue/cwlts-angular/node_modules/vm.ts]
[/Users/eduardo/Development/glue/cwlts-angular/node_modules/cwlts/node_modules/vm.js]
[/Users/eduardo/Development/glue/cwlts-angular/node_modules/vm.js]
 @ ./node_modules/cwlts/models/helpers/JSExecutor.js 3:9-22
 @ ./node_modules/cwlts/models/helpers/index.js
 @ ./node_modules/cwlts/models/index.js
 @ ./src/app/app.component.ts
 @ ./src/app/app.module.ts
 @ ./src/main.ts
 @ multi ./src/main.ts

Command line generation

Either as a separate parser or as part of the model, sample command lines should be generated from CLT descriptions.

SecondaryFiles, streamable and format should not be assignable to type record and enum (CWL issue)

This is an issue with the CWL (common-workflow-language/common-workflow-language#215) but we can fix it in the typings.

The draft-3 specification states that CommandInputRecordSchema, CommandInputEnumSchema, InputRecordSchema and InputEnumSchema have the fields secondaryFiles, streamable and format. These fields are only possible for type: File or items: File which types record and enum are not. They should be removed from the specification.

Example creating workflow programmatically

Please, could you provide an example of how to create a workflow from scratch?

It would be nice if it contained some of these:

  • Add workflow's input and output
  • Add a couple of steps with its inputs and outputs
  • Edit label and doc
  • Serialize

Thanks!

Construct a graph from a document containing an array of workflows

I would appreciate advice on how to create a workflow model from a document that contains an array of workflows.

There is an example below of this type of document.

When I create the model I can see the customProps.$graph populated. I would like to construct a graph using #main as the entry point.

Thanks for your help!

{
    "cwlVersion": "v1.0", 
    "$graph": [
        {
            "class": "CommandLineTool", 
            "baseCommand": "dbfetch_lwp.pl", 
            "hints": [
                {
                    "dockerPull": "psafont/ebitools:20170602", 
                    "class": "DockerRequirement"
                }
            ], 
            "inputs": [
                {
                    "type": "File", 
                    "doc": "List of accessions to be retrieved as sequences.", 
                    "inputBinding": {
                        "loadContents": true, 
                        "valueFrom": "$(self.contents)", 
                        "position": 3
                    }, 
                    "id": "#dbfetch.cwl/accessions"
                }, 
                {
                    "type": "string", 
                    "doc": "Database to be searched.", 
                    "inputBinding": {
                        "position": 2
                    }, 
                    "default": "uniprot", 
                    "id": "#dbfetch.cwl/database"
                }, 
                {
                    "type": "string", 
                    "doc": "Type of command-line interface.", 
                    "inputBinding": {
                        "position": 1
                    }, 
                    "default": "fetchBatch", 
                    "id": "#dbfetch.cwl/method"
                }, 
                {
                    "type": "string", 
                    "doc": "Format of the output", 
                    "inputBinding": {
                        "position": 4
                    }, 
                    "default": "fasta", 
                    "id": "#dbfetch.cwl/outformat"
                }, 
                {
                    "type": "string", 
                    "doc": "Style of the output", 
                    "inputBinding": {
                        "position": 5
                    }, 
                    "default": "raw", 
                    "id": "#dbfetch.cwl/outstyle"
                }
            ], 
            "outputs": [
                {
                    "type": "stdout", 
                    "id": "#dbfetch.cwl/sequences"
                }
            ], 
            "id": "#dbfetch.cwl"
        }, 
        {
            "class": "CommandLineTool", 
            "baseCommand": "sh", 
            "hints": [
                {
                    "dockerPull": "psafont/ebitools:20170602", 
                    "class": "DockerRequirement"
                }
            ], 
            "inputs": [
                {
                    "type": "File", 
                    "doc": "File with proteins accessions whose sequences are to be retrieved.", 
                    "inputBinding": {
                        "position": 1
                    }, 
                    "id": "#idsFordbfetch.cwl/accessions_file"
                }, 
                {
                    "type": "string", 
                    "inputBinding": {
                        "position": 0
                    }, 
                    "default": "/usr/src/ebitools/idsFordbfetch.sh", 
                    "id": "#idsFordbfetch.cwl/command"
                }, 
                {
                    "type": "string", 
                    "doc": "Maximum number of records to fetch", 
                    "inputBinding": {
                        "position": 2
                    }, 
                    "default": "20", 
                    "id": "#idsFordbfetch.cwl/numberAccessions"
                }
            ], 
            "outputs": [
                {
                    "type": "stdout", 
                    "id": "#idsFordbfetch.cwl/accessions"
                }
            ], 
            "id": "#idsFordbfetch.cwl"
        }, 
        {
            "label": "Retrieve biological records", 
            "doc": "Retrieve biological records by accession identifier", 
            "class": "Workflow", 
            "inputs": [
                {
                    "label": "File with identifiers", 
                    "doc": "File with identifiers", 
                    "type": "File", 
                    "id": "#main/accessions"
                }, 
                {
                    "label": "Number of records to retrieve", 
                    "doc": "Number of records to retrieve starting from the top.", 
                    "type": [
                        "null", 
                        "string"
                    ], 
                    "id": "#main/numberAccessions"
                }
            ], 
            "outputs": [
                {
                    "label": "Biological records", 
                    "doc": "Output file with retrieved biological records", 
                    "type": "File", 
                    "outputSource": "#main/fetch/sequences", 
                    "id": "#main/sequences"
                }
            ], 
            "steps": [
                {
                    "label": "Dbfetch", 
                    "doc": "Retrieve biological records from identifiers", 
                    "run": "#dbfetch.cwl", 
                    "in": [
                        {
                            "source": "#main/format/accessions", 
                            "id": "#main/fetch/accessions"
                        }
                    ], 
                    "out": [
                        "#main/fetch/sequences"
                    ], 
                    "id": "#main/fetch"
                }, 
                {
                    "label": "Get X top identifiers", 
                    "doc": "Filter the X top identiers", 
                    "run": "#idsFordbfetch.cwl", 
                    "in": [
                        {
                            "source": "#main/accessions", 
                            "id": "#main/format/accessions_file"
                        }
                    ], 
                    "out": [
                        "#main/format/accessions"
                    ], 
                    "id": "#main/format"
                }
            ], 
            "id": "#main"
        }
    ]
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.