Skip to content

chore: fix python client build #5856

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions backend/windmill-api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@
python3
python3Packages.pip
uv
poetry
pyright
openapi-python-client

# Other languages
deno
Expand Down
20 changes: 17 additions & 3 deletions python-client/build.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
#!/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

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
Expand Down
2 changes: 1 addition & 1 deletion python-client/publish.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -e

./build.sh
Expand Down