scramjetorg / scramjet

Public tracker for Scramjet Cloud Platform, a platform that bring data from many environments together.
https://www.scramjet.org
MIT License
253 stars 20 forks source link

Runner failed error #123

Closed tomkeee closed 2 years ago

tomkeee commented 2 years ago

Running a sequence, which main file is written in python causes an error {"message":"Runner failed","exitcode":1} ( on console.beta.scramjet.cloud platform)

structure

.
├── __pypackages__
├── index.py
└── package.json

index.py

from scramjet.streams import Stream
import asyncio

grey="\033[37m"
strong="\033[97;1m"
reset="\033[0m"

async def simple_stream_example():
    data = ['$8', '$25', '$3', '$14', '$20', '$9', '$13', '$16']
    result = await (
        Stream
            .read_from(data)
            .each(lambda x: print("Echo (in):", repr(x)))
            .map(lambda s: int(s[1:]))
            .filter(lambda x: x % 2 == 0)
            .map(lambda x: x/2)
            .map(lambda x: "$" + str(x))
            .each(lambda x: print("Echo (out):", repr(x)))
            .to_list()
    )
    print("\nOutput:", result)
print(f"\n{strong}Running simple_stream_example:{reset}")
asyncio.run(simple_stream_example())

package.json

{
  "name": "@scramjet/sirocco-python",
  "version": "0.0.1",
  "description": "",
  "main": "./index.py",
  "author": "XYZ",
  "engines": {
    "python3": "3.9.0"
  }
}

__pypackages__ includes scramjet - link

Tatarinho commented 2 years ago

@tomkeee When you wants to run Sequence you need to be sure that you defined run function, cause our runner is looking for specific named function. So to run this sample, remove unecessary asyncio.run and printf (which will normally run in python shell) and rename simple_stream_example function to run async def run(context, input, *args): ...

Tatarinho commented 2 years ago

@tomkeee you can check a lot of simple python samples here

tomkeee commented 2 years ago

@Tatarinho Thanks a lot!