Create simplified do_eval wrapper

This commit is contained in:
mvdbeek
2024-02-12 15:48:00 +01:00
parent 6fc51bd897
commit 1b7fc8ab8b
4 changed files with 22 additions and 13 deletions
+5 -1
View File
@@ -1,4 +1,7 @@
from .evaluation import evaluate
from .evaluation import (
do_eval,
evaluate,
)
from .script import (
EXPRESSION_SCRIPT_CALL,
EXPRESSION_SCRIPT_NAME,
@@ -7,6 +10,7 @@ from .script import (
from .util import find_engine
__all__ = (
"do_eval",
"evaluate",
"EXPRESSION_SCRIPT_CALL",
"EXPRESSION_SCRIPT_NAME",
@@ -1,6 +1,9 @@
import json
import os
import subprocess
from typing import MutableMapping
from cwl_utils.expression import do_eval as _do_eval
from .util import find_engine
@@ -8,6 +11,18 @@ FILE_DIRECTORY = os.path.normpath(os.path.dirname(os.path.join(__file__)))
NODE_ENGINE = os.path.join(FILE_DIRECTORY, "cwlNodeEngine.js")
def do_eval(expression: str, context: MutableMapping):
return _do_eval(
expression,
context,
[{"class": "InlineJavascriptRequirement"}],
None,
None,
{},
cwlVersion="v1.2.1",
)
def evaluate(config, input):
application = find_engine(config)
@@ -9,8 +9,6 @@ import os
import re
from io import StringIO
from cwl_utils.expression import do_eval
from galaxy.model import (
DatasetCollectionElement,
HistoryDatasetAssociation,
@@ -18,6 +16,7 @@ from galaxy.model import (
MetadataFile,
User,
)
from galaxy.tools.expressions import do_eval
from galaxy.util import string_as_bool
from galaxy.util.template import fill_template
from . import validation
@@ -792,11 +791,6 @@ class DynamicOptions:
data = do_eval(
self.from_url_postprocess,
data,
[{"class": "InlineJavascriptRequirement"}],
None,
None,
{},
cwlVersion="v1.2.1",
)
# We only support the very specific ["name", "value", "selected"] format for now.
+1 -5
View File
@@ -18,7 +18,6 @@ from typing import (
Union,
)
from cwl_utils.expression import do_eval
from typing_extensions import TypedDict
from galaxy import (
@@ -59,6 +58,7 @@ from galaxy.tools.execute import (
MappingParameters,
PartialJobExecution,
)
from galaxy.tools.expressions import do_eval
from galaxy.tools.parameters import (
check_param,
params_to_incoming,
@@ -226,10 +226,6 @@ def evaluate_value_from_expressions(progress, step, execution_state, extra_step_
as_cwl_value = do_eval(
when_expression,
step_state,
[{"class": "InlineJavascriptRequirement"}],
None,
None,
{},
)
except Exception:
# Exception contains script and traceback, which could be helpful for debugging workflows,