From e81f9d92e3d77e889c580c28db767ed261bbd9e0 Mon Sep 17 00:00:00 2001 From: restitux Date: Sat, 25 Feb 2023 12:44:46 -0700 Subject: [PATCH] test --- .cursorius/Dockerfile | 7 ++++ .cursorius/build.py | 81 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 .cursorius/Dockerfile create mode 100644 .cursorius/build.py diff --git a/.cursorius/Dockerfile b/.cursorius/Dockerfile new file mode 100644 index 0000000..2aa1a6c --- /dev/null +++ b/.cursorius/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11 + +RUN pip install git+https://git.ohea.xyz/cursorius/pipeline-api#subdirectory=python + +COPY .cursorius/build.py / +CMD ["python3", "/build.py"] + diff --git a/.cursorius/build.py b/.cursorius/build.py new file mode 100644 index 0000000..a32d84b --- /dev/null +++ b/.cursorius/build.py @@ -0,0 +1,81 @@ +import os + +# import sys +# import grpc + +# HACK: need to fix how protobuf is generated to get imports working +# sys.path.append("/usr/local/lib/python3.11/site-packages/cursorius_pipeline_api_v2/") +# from cursorius_pipeline_api_v2 import get_runner_pb2, get_runner_pb2_grpc +# from cursorius_pipeline_api_v2 import run_command_pb2, run_command_pb2_grpc +# from cursorius_pipeline_api_v2 import release_runner_pb2, release_runner_pb2_grpc + + +print("Hello world!") +print("Hello world!") + +run_id = os.environ.get("CURSORIUS_RUN_ID") +src_dir = os.environ.get("CURSORIUS_SRC_DIR") +server_url = os.environ.get("CURSORIUS_SERVER_URL") + +print(f"{run_id=}") +print(f"{src_dir=}") +print(f"{server_url=}") + +## create GRPc connection +# channel = grpc.insecure_channel(server_url) +# +## GetRunner stub +# get_runner_stub = get_runner_pb2_grpc.GetRunnerServiceStub(channel) +# +## GetRunner Request +# request = get_runner_pb2.GetRunnerRequest() +# +## Call GetRunner +# get_runner_resp = None +# try: +# get_runner_resp = get_runner_stub.GetRunner(request) +# except grpc._channel._InactiveRpcError as e: +# print(f"Error: {e.details()}") +# sys.exit(-1) +# +## Print ID of allocated runner +# print(get_runner_resp.id) +# +## RunCommand stub +# run_command_stub = run_command_pb2_grpc.RunCommandServiceStub(channel) +# +## RunCommand request +# request = run_command_pb2.RunCommandRequest( +# id=get_runner_resp.id, +# command="ls", +# args=["-lah"], +# ) +# +## Call RunCommand +# run_command_resp = None +# try: +# run_command_resp = run_command_stub.RunCommand(request) +# except grpc._channel._InactiveRpcError as e: +# print(f"Error: {e.details()}") +# sys.exit(-1) +# +# print(f"return code: {run_command_resp.return_code}") +# print(f"stdout: {run_command_resp.stdout}") +# print(f"stderr: {run_command_resp.stderr}") +# +# +## ReleaseRunner stub +# release_runner_stub = release_runner_pb2_grpc.ReleaseRunnerServiceStub(channel) +# +## ReleaseRunner request +# request = release_runner_pb2.ReleaseRunnerRequest( +# id=get_runner_resp.id, +# ) +# +## Call ReleaseRunner +# release_runner_resp = None +# try: +# release_runner_resp = release_runner_stub.ReleaseRunner(request) +# except grpc._channel._InactiveRpcError as e: +# print(f"Error: {e.details()}") +# sys.exit(-1)