openai/openai-python

Public

mirrored from https://github.com/openai/openai-pythonAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v2.31.0

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

scripts/mock

52lines · modeblame

d2738d42Stainless Bot2 years ago1#!/usr/bin/env bash
2
3set -e
4
5cd "$(dirname "$0")/.."
6
7if [[ -n "$1" && "$1" != '--'* ]]; then
8URL="$1"
9shift
10else
11URL="$(grep 'openapi_spec_url' .stats.yml | cut -d' ' -f2)"
12fi
13
14# Check if the URL is empty
15if [ -z "$URL" ]; then
16echo "Error: No OpenAPI spec path/url provided or found in .stats.yml"
17exit 1
18fi
19
20echo "==> Starting mock server with URL ${URL}"
21
85ac9313stainless-app[bot]3 months ago22# Run steady mock on the given spec
d2738d42Stainless Bot2 years ago23if [ "$1" == "--daemon" ]; then
9b1bb6eestainless-app[bot]3 months ago24# Pre-install the package so the download doesn't eat into the startup timeout
de2c7b1dstainless-app[bot]2 months ago25npm exec --package=@stdy/cli@0.20.2 -- steady --version
9b1bb6eestainless-app[bot]3 months ago26
de2c7b1dstainless-app[bot]2 months ago27npm exec --package=@stdy/cli@0.20.2 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log &
d2738d42Stainless Bot2 years ago28
85ac9313stainless-app[bot]3 months ago29# Wait for server to come online via health endpoint (max 30s)
d2738d42Stainless Bot2 years ago30echo -n "Waiting for server"
9b1bb6eestainless-app[bot]3 months ago31attempts=0
85ac9313stainless-app[bot]3 months ago32while ! curl --silent --fail "http://127.0.0.1:4010/_x-steady/health" >/dev/null 2>&1; do
33if ! kill -0 $! 2>/dev/null; then
34echo
35cat .stdy.log
36exit 1
37fi
9b1bb6eestainless-app[bot]3 months ago38attempts=$((attempts + 1))
39if [ "$attempts" -ge 300 ]; then
40echo
85ac9313stainless-app[bot]3 months ago41echo "Timed out waiting for Steady server to start"
42cat .stdy.log
9b1bb6eestainless-app[bot]3 months ago43exit 1
44fi
d2738d42Stainless Bot2 years ago45echo -n "."
46sleep 0.1
47done
48
49echo
50else
de2c7b1dstainless-app[bot]2 months ago51npm exec --package=@stdy/cli@0.20.2 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL"
d2738d42Stainless Bot2 years ago52fi