Пример #1
0
    async def run():
        # Read node input
        params = await pygada_runtime.read_json(sys.stdin)
        data = params.get("data", {})

        # Read from input file
        input = params.get("input", None)
        if input:
            with open(input, "r") as f:
                data = json.loads(f.read())

        # Write to output file
        output = params.get("output", None)
        if output:
            with open(output, "w+") as f:
                f.write(json.dumps(data))

        # Write node output
        pygada_runtime.write_json(sys.stdout, {"data": data})
Пример #2
0
    async def _run():
        with pygada_runtime.PipeStream() as stdin:
            with pygada_runtime.PipeStream() as stdout:
                with pygada_runtime.PipeStream(rmode="r") as stderr:
                    pygada_runtime.write_json(stdin, data)
                    stdin.eof()

                    proc = await pygada_runtime.run(
                        sanitize_node_name(node),
                        stdin=stdin.reader,
                        stdout=stdout,
                        stderr=stderr,
                    )

                    await proc.wait()

                    stdout.eof()
                    stderr.eof()

                    if proc.returncode != 0:
                        raise Exception(await stderr.read())

                    return await pygada_runtime.read_json(stdout)
Пример #3
0
    async def _run():
        with pygada_runtime.PipeStream() as stdin:
            with pygada_runtime.PipeStream() as stdout:
                with pygada_runtime.PipeStream(rmode="r") as stderr:
                    pygada_runtime.write_json(stdin, params)
                    stdin.eof()

                    proc = await pygada_runtime.run(
                        f"gadalang_lang.{node}",
                        stdin=stdin.reader,
                        stdout=stdout,
                        stderr=stderr,
                    )

                    await proc.wait()

                    stdout.eof()
                    stderr.eof()

                    if proc.returncode != 0:
                        raise Exception(await stderr.read())

                    return await pygada_runtime.read_json(stdout)
Пример #4
0
def hello(argv, *args, **kwargs):
    pygada_runtime.write_json(sys.stdout, {"data": "hello"})