From 697f660532ee1bb1e71f00a0e88a0811c2f8aed9 Mon Sep 17 00:00:00 2001 From: pyranota <92104930+pyranota@users.noreply.github.com> Date: Tue, 3 Jun 2025 00:05:12 +0200 Subject: [PATCH] chore: fix python client build (#5856) * chore: fix python client build * nit --- backend/windmill-api/openapi.yaml | 4 ++++ flake.nix | 3 +++ python-client/build.sh | 20 +++++++++++++++++--- python-client/publish.sh | 2 +- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/backend/windmill-api/openapi.yaml b/backend/windmill-api/openapi.yaml index e757d24432..d6284c53e4 100644 --- a/backend/windmill-api/openapi.yaml +++ b/backend/windmill-api/openapi.yaml @@ -13185,6 +13185,8 @@ components: # NOTE: Not so many generators and validators support this format: # $ref: "../../openflow.openapi.yaml#/components/schemas" # This is why it is better to inline each of schemas for better compat + # Do not change next line. It is used by python-client for pre-processing + # -- INLINE START -- OpenFlow: $ref: "../../openflow.openapi.yaml#/components/schemas/OpenFlow" FlowValue: @@ -13223,6 +13225,8 @@ components: $ref: "../../openflow.openapi.yaml#/components/schemas/FlowStatus" FlowStatusModule: $ref: "../../openflow.openapi.yaml#/components/schemas/FlowStatusModule" + # -- INLINE END -- + # Do not change line above AIProvider: type: string diff --git a/flake.nix b/flake.nix index 10a1e26c14..d11b967cc4 100644 --- a/flake.nix +++ b/flake.nix @@ -94,6 +94,9 @@ python3 python3Packages.pip uv + poetry + pyright + openapi-python-client # Other languages deno diff --git a/python-client/build.sh b/python-client/build.sh index 76bfa4e736..780806388e 100755 --- a/python-client/build.sh +++ b/python-client/build.sh @@ -1,8 +1,22 @@ -#!/bin/bash +#!/usr/bin/env bash set -e mkdir openapi || true -cp ../backend/windmill-api/openapi.yaml openapi/openapi.yaml +# cp ../backend/windmill-api/openapi.yaml openapi/openapi.yaml + +LEGACY_WILDCARD="\$ref: \"..\/..\/openflow.openapi.yaml#\/components\/schemas\"" +# We will need to use old syntax of openapi to maintain compatability with previous windmill-api versions. +# If we use new format, many models use another namespace, thus make it not fully compatible with old versions +if [[ "$OSTYPE" == "darwin"* ]]; then + # macOS version using perl + perl -0777 -pe "s/# -- INLINE START --\n.*?# -- INLINE END --\n/$LEGACY_WILDCARD\n/s" \ + ../backend/windmill-api/openapi.yaml > openapi/openapi.yaml +else + # Replace everything between markers with legacy wildcard + sed -z " + s/# -- INLINE START --\n.*# -- INLINE END --\n/$LEGACY_WILDCARD\n/g; + " ../backend/windmill-api/openapi.yaml > openapi/openapi.yaml +fi npx @redocly/openapi-cli@latest bundle openapi/openapi.yaml > openapi-bundled.yaml @@ -10,7 +24,7 @@ if [[ "$OSTYPE" == "darwin"* ]]; then # sed -z is not supported on macOS, use perl instead perl -0777 -pe 's/FlowModuleValue:/FlowModuleValue2:/g' openapi-bundled.yaml > openapi-decycled.yaml else - sed -z 's/FlowModuleValue:/FlowModuleValue2:/' openapi-bundled.yaml > openapi-decycled.yaml + sed -z 's/FlowModuleValue:/FlowModuleValue2:/' openapi-bundled.yaml > openapi-decycled.yaml fi echo " FlowModuleValue: {}" >> openapi-decycled.yaml diff --git a/python-client/publish.sh b/python-client/publish.sh index 54a18d9b0f..b6610ebf7f 100755 --- a/python-client/publish.sh +++ b/python-client/publish.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e ./build.sh