Rewrote pipeline to use grpc flow
This commit is contained in:
@@ -0,0 +1,9 @@
|
|||||||
|
.DS_Store
|
||||||
|
.idea
|
||||||
|
*.log
|
||||||
|
tmp/
|
||||||
|
|
||||||
|
*.py[cod]
|
||||||
|
*.egg
|
||||||
|
build
|
||||||
|
htmlcov
|
||||||
+10
-3
@@ -1,7 +1,14 @@
|
|||||||
FROM python:3.11
|
FROM python:3.11
|
||||||
|
|
||||||
RUN pip install git+https://git.ohea.xyz/cursorius/pipeline-api#subdirectory=python
|
# Install poetry
|
||||||
|
ENV POETRY_VERSION=1.4.2
|
||||||
|
ENV POETRY_HOME=/opt/poetry
|
||||||
|
RUN curl https://install.python-poetry.org --output install-poetry.py
|
||||||
|
RUN python3 install-poetry.py
|
||||||
|
|
||||||
COPY .cursorius/build.py /
|
COPY .cursorius/pipeline /pipeline
|
||||||
CMD ["python3", "/build.py"]
|
WORKDIR /pipeline
|
||||||
|
RUN $POETRY_HOME/bin/poetry config virtualenvs.in-project true
|
||||||
|
RUN $POETRY_HOME/bin/poetry install
|
||||||
|
|
||||||
|
CMD ["/opt/poetry/bin/poetry", "run", "pipeline"]
|
||||||
|
|||||||
Generated
+108
@@ -0,0 +1,108 @@
|
|||||||
|
# This file is automatically @generated by Poetry 1.4.2 and should not be changed by hand.
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cursorius-pipeline-api-v2"
|
||||||
|
version = "0.2.0"
|
||||||
|
description = "Python client for the cursorius pipeline api (v2)"
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = "^3.10"
|
||||||
|
files = []
|
||||||
|
develop = false
|
||||||
|
|
||||||
|
[package.dependencies]
|
||||||
|
grpcio = "^1.51.1"
|
||||||
|
protobuf = "^4.21.12"
|
||||||
|
|
||||||
|
[package.source]
|
||||||
|
type = "git"
|
||||||
|
url = "https://git.ohea.xyz/cursorius/pipeline-api"
|
||||||
|
reference = "HEAD"
|
||||||
|
resolved_reference = "34d8875b72f46cecd6bb2522d73fd93c79594439"
|
||||||
|
subdirectory = "python"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "grpcio"
|
||||||
|
version = "1.53.0"
|
||||||
|
description = "HTTP/2-based RPC framework"
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.7"
|
||||||
|
files = [
|
||||||
|
{file = "grpcio-1.53.0-cp310-cp310-linux_armv7l.whl", hash = "sha256:752d2949b40e12e6ad3ed8cc552a65b54d226504f6b1fb67cab2ccee502cc06f"},
|
||||||
|
{file = "grpcio-1.53.0-cp310-cp310-macosx_12_0_universal2.whl", hash = "sha256:8a48fd3a7222be226bb86b7b413ad248f17f3101a524018cdc4562eeae1eb2a3"},
|
||||||
|
{file = "grpcio-1.53.0-cp310-cp310-manylinux_2_17_aarch64.whl", hash = "sha256:f3e837d29f0e1b9d6e7b29d569e2e9b0da61889e41879832ea15569c251c303a"},
|
||||||
|
{file = "grpcio-1.53.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:aef7d30242409c3aa5839b501e877e453a2c8d3759ca8230dd5a21cda029f046"},
|
||||||
|
{file = "grpcio-1.53.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e6f90698b5d1c5dd7b3236cd1fa959d7b80e17923f918d5be020b65f1c78b173"},
|
||||||
|
{file = "grpcio-1.53.0-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:a96c3c7f564b263c5d7c0e49a337166c8611e89c4c919f66dba7b9a84abad137"},
|
||||||
|
{file = "grpcio-1.53.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:ee81349411648d1abc94095c68cd25e3c2812e4e0367f9a9355be1e804a5135c"},
|
||||||
|
{file = "grpcio-1.53.0-cp310-cp310-win32.whl", hash = "sha256:fdc6191587de410a184550d4143e2b24a14df495c86ca15e59508710681690ac"},
|
||||||
|
{file = "grpcio-1.53.0-cp310-cp310-win_amd64.whl", hash = "sha256:658ffe1e39171be00490db5bd3b966f79634ac4215a1eb9a85c6cd6783bf7f6e"},
|
||||||
|
{file = "grpcio-1.53.0-cp311-cp311-linux_armv7l.whl", hash = "sha256:1b172e6d497191940c4b8d75b53de82dc252e15b61de2951d577ec5b43316b29"},
|
||||||
|
{file = "grpcio-1.53.0-cp311-cp311-macosx_10_10_universal2.whl", hash = "sha256:82434ba3a5935e47908bc861ce1ebc43c2edfc1001d235d6e31e5d3ed55815f7"},
|
||||||
|
{file = "grpcio-1.53.0-cp311-cp311-manylinux_2_17_aarch64.whl", hash = "sha256:1c734a2d4843e4e14ececf5600c3c4750990ec319e1299db7e4f0d02c25c1467"},
|
||||||
|
{file = "grpcio-1.53.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b6a2ead3de3b2d53119d473aa2f224030257ef33af1e4ddabd4afee1dea5f04c"},
|
||||||
|
{file = "grpcio-1.53.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a34d6e905f071f9b945cabbcc776e2055de1fdb59cd13683d9aa0a8f265b5bf9"},
|
||||||
|
{file = "grpcio-1.53.0-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:eaf8e3b97caaf9415227a3c6ca5aa8d800fecadd526538d2bf8f11af783f1550"},
|
||||||
|
{file = "grpcio-1.53.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:da95778d37be8e4e9afca771a83424f892296f5dfb2a100eda2571a1d8bbc0dc"},
|
||||||
|
{file = "grpcio-1.53.0-cp311-cp311-win32.whl", hash = "sha256:e4f513d63df6336fd84b74b701f17d1bb3b64e9d78a6ed5b5e8a198bbbe8bbfa"},
|
||||||
|
{file = "grpcio-1.53.0-cp311-cp311-win_amd64.whl", hash = "sha256:ddb2511fbbb440ed9e5c9a4b9b870f2ed649b7715859fd6f2ebc585ee85c0364"},
|
||||||
|
{file = "grpcio-1.53.0-cp37-cp37m-linux_armv7l.whl", hash = "sha256:2a912397eb8d23c177d6d64e3c8bc46b8a1c7680b090d9f13a640b104aaec77c"},
|
||||||
|
{file = "grpcio-1.53.0-cp37-cp37m-macosx_10_10_universal2.whl", hash = "sha256:55930c56b8f5b347d6c8c609cc341949a97e176c90f5cbb01d148d778f3bbd23"},
|
||||||
|
{file = "grpcio-1.53.0-cp37-cp37m-manylinux_2_17_aarch64.whl", hash = "sha256:6601d812105583948ab9c6e403a7e2dba6e387cc678c010e74f2d6d589d1d1b3"},
|
||||||
|
{file = "grpcio-1.53.0-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c705e0c21acb0e8478a00e7e773ad0ecdb34bd0e4adc282d3d2f51ba3961aac7"},
|
||||||
|
{file = "grpcio-1.53.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ba074af9ca268ad7b05d3fc2b920b5fb3c083da94ab63637aaf67f4f71ecb755"},
|
||||||
|
{file = "grpcio-1.53.0-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:14817de09317dd7d3fbc8272864288320739973ef0f4b56bf2c0032349da8cdf"},
|
||||||
|
{file = "grpcio-1.53.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:c7ad9fbedb93f331c2e9054e202e95cf825b885811f1bcbbdfdc301e451442db"},
|
||||||
|
{file = "grpcio-1.53.0-cp37-cp37m-win_amd64.whl", hash = "sha256:dad5b302a4c21c604d88a5d441973f320134e6ff6a84ecef9c1139e5ffd466f6"},
|
||||||
|
{file = "grpcio-1.53.0-cp38-cp38-linux_armv7l.whl", hash = "sha256:fa8eaac75d3107e3f5465f2c9e3bbd13db21790c6e45b7de1756eba16b050aca"},
|
||||||
|
{file = "grpcio-1.53.0-cp38-cp38-macosx_10_10_universal2.whl", hash = "sha256:104a2210edd3776c38448b4f76c2f16e527adafbde171fc72a8a32976c20abc7"},
|
||||||
|
{file = "grpcio-1.53.0-cp38-cp38-manylinux_2_17_aarch64.whl", hash = "sha256:dbc1ba968639c1d23476f75c356e549e7bbf2d8d6688717dcab5290e88e8482b"},
|
||||||
|
{file = "grpcio-1.53.0-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:95952d3fe795b06af29bb8ec7bbf3342cdd867fc17b77cc25e6733d23fa6c519"},
|
||||||
|
{file = "grpcio-1.53.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f144a790f14c51b8a8e591eb5af40507ffee45ea6b818c2482f0457fec2e1a2e"},
|
||||||
|
{file = "grpcio-1.53.0-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:0698c094688a2dd4c7c2f2c0e3e142cac439a64d1cef6904c97f6cde38ba422f"},
|
||||||
|
{file = "grpcio-1.53.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:6b6d60b0958be711bab047e9f4df5dbbc40367955f8651232bfdcdd21450b9ab"},
|
||||||
|
{file = "grpcio-1.53.0-cp38-cp38-win32.whl", hash = "sha256:1948539ce78805d4e6256ab0e048ec793956d54787dc9d6777df71c1d19c7f81"},
|
||||||
|
{file = "grpcio-1.53.0-cp38-cp38-win_amd64.whl", hash = "sha256:df9ba1183b3f649210788cf80c239041dddcb375d6142d8bccafcfdf549522cd"},
|
||||||
|
{file = "grpcio-1.53.0-cp39-cp39-linux_armv7l.whl", hash = "sha256:19caa5b7282a89b799e63776ff602bb39604f7ca98db6df27e2de06756ae86c3"},
|
||||||
|
{file = "grpcio-1.53.0-cp39-cp39-macosx_10_10_universal2.whl", hash = "sha256:b5bd026ac928c96cc23149e6ef79183125542062eb6d1ccec34c0a37e02255e7"},
|
||||||
|
{file = "grpcio-1.53.0-cp39-cp39-manylinux_2_17_aarch64.whl", hash = "sha256:7dc8584ca6c015ad82e186e82f4c0fe977394588f66b8ecfc4ec873285314619"},
|
||||||
|
{file = "grpcio-1.53.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2eddaae8af625e45b5c8500dcca1043264d751a6872cde2eda5022df8a336959"},
|
||||||
|
{file = "grpcio-1.53.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c5fb6f3d7824696c1c9f2ad36ddb080ba5a86f2d929ef712d511b4d9972d3d27"},
|
||||||
|
{file = "grpcio-1.53.0-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:8270d1dc2c98ab57e6dbf36fa187db8df4c036f04a398e5d5e25b4e01a766d70"},
|
||||||
|
{file = "grpcio-1.53.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:976a7f24eb213e8429cab78d5e120500dfcdeb01041f1f5a77b17b9101902615"},
|
||||||
|
{file = "grpcio-1.53.0-cp39-cp39-win32.whl", hash = "sha256:9c84a481451e7174f3a764a44150f93b041ab51045aa33d7b5b68b6979114e48"},
|
||||||
|
{file = "grpcio-1.53.0-cp39-cp39-win_amd64.whl", hash = "sha256:6beb84f83360ff29a3654f43f251ec11b809dcb5524b698d711550243debd289"},
|
||||||
|
{file = "grpcio-1.53.0.tar.gz", hash = "sha256:a4952899b4931a6ba12951f9a141ef3e74ff8a6ec9aa2dc602afa40f63595e33"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[package.extras]
|
||||||
|
protobuf = ["grpcio-tools (>=1.53.0)"]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "protobuf"
|
||||||
|
version = "4.22.1"
|
||||||
|
description = ""
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.7"
|
||||||
|
files = [
|
||||||
|
{file = "protobuf-4.22.1-cp310-abi3-win32.whl", hash = "sha256:85aa9acc5a777adc0c21b449dafbc40d9a0b6413ff3a4f77ef9df194be7f975b"},
|
||||||
|
{file = "protobuf-4.22.1-cp310-abi3-win_amd64.whl", hash = "sha256:8bc971d76c03f1dd49f18115b002254f2ddb2d4b143c583bb860b796bb0d399e"},
|
||||||
|
{file = "protobuf-4.22.1-cp37-abi3-macosx_10_9_universal2.whl", hash = "sha256:5917412347e1da08ce2939eb5cd60650dfb1a9ab4606a415b9278a1041fb4d19"},
|
||||||
|
{file = "protobuf-4.22.1-cp37-abi3-manylinux2014_aarch64.whl", hash = "sha256:9e12e2810e7d297dbce3c129ae5e912ffd94240b050d33f9ecf023f35563b14f"},
|
||||||
|
{file = "protobuf-4.22.1-cp37-abi3-manylinux2014_x86_64.whl", hash = "sha256:953fc7904ef46900262a26374b28c2864610b60cdc8b272f864e22143f8373c4"},
|
||||||
|
{file = "protobuf-4.22.1-cp37-cp37m-win32.whl", hash = "sha256:6e100f7bc787cd0a0ae58dbf0ab8bbf1ee7953f862b89148b6cf5436d5e9eaa1"},
|
||||||
|
{file = "protobuf-4.22.1-cp37-cp37m-win_amd64.whl", hash = "sha256:87a6393fa634f294bf24d1cfe9fdd6bb605cbc247af81b9b10c4c0f12dfce4b3"},
|
||||||
|
{file = "protobuf-4.22.1-cp38-cp38-win32.whl", hash = "sha256:e3fb58076bdb550e75db06ace2a8b3879d4c4f7ec9dd86e4254656118f4a78d7"},
|
||||||
|
{file = "protobuf-4.22.1-cp38-cp38-win_amd64.whl", hash = "sha256:651113695bc2e5678b799ee5d906b5d3613f4ccfa61b12252cfceb6404558af0"},
|
||||||
|
{file = "protobuf-4.22.1-cp39-cp39-win32.whl", hash = "sha256:67b7d19da0fda2733702c2299fd1ef6cb4b3d99f09263eacaf1aa151d9d05f02"},
|
||||||
|
{file = "protobuf-4.22.1-cp39-cp39-win_amd64.whl", hash = "sha256:b8700792f88e59ccecfa246fa48f689d6eee6900eddd486cdae908ff706c482b"},
|
||||||
|
{file = "protobuf-4.22.1-py3-none-any.whl", hash = "sha256:3e19dcf4adbf608924d3486ece469dd4f4f2cf7d2649900f0efcd1a84e8fd3ba"},
|
||||||
|
{file = "protobuf-4.22.1.tar.gz", hash = "sha256:dce7a55d501c31ecf688adb2f6c3f763cf11bc0be815d1946a84d74772ab07a7"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[metadata]
|
||||||
|
lock-version = "2.0"
|
||||||
|
python-versions = "^3.10"
|
||||||
|
content-hash = "db1351b75ece40f207aa5956fb2b87f4624e058b6eaf60c1c69dc12a6d729061"
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
[tool.poetry]
|
||||||
|
name = "test-pipeline"
|
||||||
|
version = "0.1.0"
|
||||||
|
description = "test pipeline"
|
||||||
|
authors = ["restitux <restitux@ohea.xyz>"]
|
||||||
|
license = "GPLv3"
|
||||||
|
packages = [{include = "test_pipeline"}]
|
||||||
|
|
||||||
|
[tool.poetry.dependencies]
|
||||||
|
python = "^3.10"
|
||||||
|
cursorius-pipeline-api-v2 = {git = "https://git.ohea.xyz/cursorius/pipeline-api", subdirectory = "python"}
|
||||||
|
|
||||||
|
[tool.poetry.scripts]
|
||||||
|
pipeline = 'test_pipeline.__main__:main'
|
||||||
|
|
||||||
|
[build-system]
|
||||||
|
requires = ["poetry-core"]
|
||||||
|
build-backend = "poetry.core.masonry.api"
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import grpc
|
||||||
|
|
||||||
|
# HACK: need to fix how protobuf is generated to get imports working
|
||||||
|
sys.path.append(
|
||||||
|
"/pipeline/.venv/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
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
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)
|
||||||
Reference in New Issue
Block a user