<gh_stars>10-100
"""An execution engine for Python processes."""
from pathlib import Path

from resolwe.flow.execution_engines.base import BaseExecutionEngine
from resolwe.flow.executors.constants import BOOTSTRAP_PYTHON_RUNTIME
from resolwe.process.parser import SafeParser


class ExecutionEngine(BaseExecutionEngine):
    """An execution engine that outputs bash programs."""

    name = "python"

    def discover_process(self, path):
        """Perform process discovery in given path.

        This method will be called during process registration and
        should return a list of dictionaries with discovered process
        schemas.
        """
        if not path.lower().endswith(".py"):
            return []
        parser = SafeParser(open(path).read())
        processes = parser.parse()
        return [process.to_schema() for process in processes]

    def evaluate(self, data):
        """Evaluate the code needed to compute a given Data object."""
        bootstrap_filename = Path("/") / BOOTSTRAP_PYTHON_RUNTIME
        return f"python3 {bootstrap_filename}"

"""An execution engine for Python processes."""
from pathlib import Path

from resolwe.flow.execution_engines.base import BaseExecutionEngine
from resolwe.flow.executors.constants import BOOTSTRAP_PYTHON_RUNTIME
from resolwe.process.parser import SafeParser


class ExecutionEngine(BaseExecutionEngine):
    """An execution engine that outputs bash programs."""

    name = "python"

    def discover_process(self, path):
        """Perform process discovery in given path.

        This method will be called during process registration and
        should return a list of dictionaries with discovered process
        schemas.
        """
        if not path.lower().endswith(".py"):
            return []
        parser = SafeParser(open(path).read())
        processes = parser.parse()
        return [process.to_schema() for process in processes]

    def evaluate(self, data):
        """Evaluate the code needed to compute a given Data object."""
        bootstrap_filename = Path("/") / BOOTSTRAP_PYTHON_RUNTIME
        return f"python3 {bootstrap_filename}"
An execution engine for Python processes. An execution engine that outputs bash programs. Perform process discovery in given path.          This method will be called during process registration and         should return a list of dictionaries with discovered process         schemas. Evaluate the code needed to compute a given Data object.