openai/openai-python

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v2.27.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
22# Run prism mock on the given spec
23if [ "$1" == "--daemon" ]; then
9b1bb6eestainless-app[bot]3 months ago24# Pre-install the package so the download doesn't eat into the startup timeout
25npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism --version
26
5dc34767stainless-app[bot]10 months ago27npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log &
d2738d42Stainless Bot2 years ago28
9b1bb6eestainless-app[bot]3 months ago29# Wait for server to come online (max 30s)
d2738d42Stainless Bot2 years ago30echo -n "Waiting for server"
9b1bb6eestainless-app[bot]3 months ago31attempts=0
d2738d42Stainless Bot2 years ago32while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do
9b1bb6eestainless-app[bot]3 months ago33attempts=$((attempts + 1))
34if [ "$attempts" -ge 300 ]; then
35echo
36echo "Timed out waiting for Prism server to start"
37cat .prism.log
38exit 1
39fi
d2738d42Stainless Bot2 years ago40echo -n "."
41sleep 0.1
42done
43
44if grep -q "✖ fatal" ".prism.log"; then
45cat .prism.log
46exit 1
47fi
48
49echo
50else
5dc34767stainless-app[bot]10 months ago51npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL"
d2738d42Stainless Bot2 years ago52fi