Skip to content

Commit

Permalink
Updated JS imports from cwltool (#121)
Browse files Browse the repository at this point in the history
JavaScript-related code has been migrated from `cwltool` to the `cwl-utils`
package. This commit backports these changes to StreamFlow 0.1.x.
  • Loading branch information
GlassOfWhiskey committed Apr 20, 2023
1 parent 81ed096 commit 45d2b92
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 15 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/cwl-conformance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ name: "CWL Conformance"
on:
push:
branches:
- master
- 0.1.x
pull_request:
branches:
- 0.1.x
jobs:
test:
runs-on: ubuntu-20.04
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflows:
- "CWL Conformance"
branches:
- master
- 0.1.x
types:
- completed
jobs:
Expand All @@ -21,7 +21,7 @@ jobs:
- name: "Get StreamFlow version"
run: echo "STREAMFLOW_VERSION=$(cat streamflow/version.py | grep -oP '(?<=VERSION = \")(.*)(?=\")')" >> $GITHUB_ENV
- name: "Check if Docker image already exists"
run : echo "NEW_IMAGE=$(DOCKER_CLI_EXPERIMENTAL=enabled docker manifest inspect alphaunito/streamflow:${STREAMFLOW_VERSION}-base > /dev/null 2>&1; echo $?)" >> $GITHUB_ENV
run : echo "NEW_IMAGE=$(docker buildx imagetools inspect alphaunito/streamflow:${STREAMFLOW_VERSION} > /dev/null 2>&1; echo $?)" >> $GITHUB_ENV
- name: "Build base image"
id: docker-base
if: ${{ env.NEW_IMAGE }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/github-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflows:
- "CWL Conformance"
branches:
- master
- 0.1.x
types:
- completed
jobs:
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/pypi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflows:
- "CWL Conformance"
branches:
- master
- 0.1.x
types:
- completed
jobs:
Expand All @@ -15,12 +15,10 @@ jobs:
- uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: "Install pypisearch package"
run: python -m pip install pypisearch --user
- name: "Get StreamFlow version"
run: echo "STREAMFLOW_VERSION=$(cat streamflow/version.py | grep -oP '(?<=VERSION = \")(.*)(?=\")')" >> $GITHUB_ENV
- name: "Get PyPI version"
run: echo "PYPI_VERSION=$(python -m pypisearch streamflow | grep -oP '(?<=^streamflow \()(.*)(?=\))')" >> $GITHUB_ENV
run: echo "PYPI_VERSION=$(pip index versions --pre streamflow | grep streamflow | sed 's/.*(\(.*\))/\1/')" >> $GITHUB_ENV
- name: "Build Python packages"
if: ${{ env.STREAMFLOW_VERSION != env.PYPI_VERSION }}
run: |
Expand Down
8 changes: 4 additions & 4 deletions streamflow/cwl/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from typing import Optional, MutableMapping, Any, Mapping, MutableSequence, Set

import antlr4
import cwltool.sandboxjs
from cwltool.sandboxjs import JavascriptException
import cwl_utils.sandboxjs
from cwl_utils.sandboxjs import JavascriptException
from schema_salad.utils import json_dumps

from streamflow.core.exception import WorkflowDefinitionException, WorkflowExecutionException
Expand Down Expand Up @@ -156,7 +156,7 @@ def evaluate(self, expr: str) -> Optional[Any]:
class DependencyResolver(Evaluator):

def _ecmascript_evaluate(self, expr: str) -> Optional[Any]:
code = cwltool.sandboxjs.code_fragment_to_js(expr, self.jslib)
code = cwl_utils.sandboxjs.code_fragment_to_js(expr, self.jslib)
lexer = ECMAScriptLexer(antlr4.InputStream(code))
parser = ECMAScriptParser(antlr4.CommonTokenStream(lexer))
listener = CWLDependencyListener()
Expand Down Expand Up @@ -184,7 +184,7 @@ def _regex_evaluate(self,
class RuntimeEvaluator(Evaluator):

def _ecmascript_evaluate(self, expr: str) -> Optional[Any]:
return cwltool.sandboxjs.execjs(expr, self.jslib, self.timeout)
return cwl_utils.sandboxjs.get_js_engine().eval(expr, self.jslib, timeout=self.timeout)

def _regex_evaluate(self,
parsed_string: str,
Expand Down
6 changes: 3 additions & 3 deletions streamflow/cwl/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import TYPE_CHECKING, MutableSequence, Set, MutableMapping

import cwltool.expression
import cwl_utils.expression

from streamflow.core.exception import WorkflowDefinitionException
from streamflow.core.utils import get_token_value
Expand Down Expand Up @@ -44,7 +44,7 @@ def eval_expression(expression: str,
expression,
context,
full_js=full_js,
jslib=cwltool.expression.jshead(expression_lib or [], context) if full_js else "",
jslib=cwl_utils.expression.jshead(expression_lib or [], context) if full_js else "",
strip_whitespace=strip_whitespace,
timeout=timeout)
else:
Expand Down Expand Up @@ -90,7 +90,7 @@ def resolve_dependencies(expression: str,
expression,
context,
full_js=full_js,
jslib=cwltool.expression.jshead(expression_lib or [], context) if full_js else "",
jslib=cwl_utils.expression.jshead(expression_lib or [], context) if full_js else "",
strip_whitespace=strip_whitespace,
timeout=timeout,
resolve_dependencies=True)
Expand Down

0 comments on commit 45d2b92

Please sign in to comment.