-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #487 from inkz:inkz/fingreprint_gradio
PiperOrigin-RevId: 654004034 Change-Id: I8c23798f232816e3324408c42df96c0ca5151a4b
- Loading branch information
Showing
6 changed files
with
2,910 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
google/fingerprinters/web/scripts/updater/community/gradio/app/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM python:3.9-slim | ||
|
||
ARG version | ||
|
||
RUN python -m pip install gradio==$version | ||
|
||
ADD test_app.py /workspace/ | ||
|
||
EXPOSE 8000 | ||
|
||
CMD [ "python3" , "/workspace/test_app.py" ] |
8 changes: 8 additions & 0 deletions
8
google/fingerprinters/web/scripts/updater/community/gradio/app/docker-compose.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
services: | ||
gradio: | ||
build: | ||
context: . | ||
args: | ||
version: ${GRADIO_VERSION} | ||
ports: | ||
- "8000:8000" |
13 changes: 13 additions & 0 deletions
13
google/fingerprinters/web/scripts/updater/community/gradio/app/test_app.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import gradio as gr | ||
|
||
def greet(name, intensity): | ||
return "Hello, " + name + "!" * int(intensity) | ||
|
||
demo = gr.Interface( | ||
fn=greet, | ||
inputs=["text", "slider"], | ||
outputs=["text"], | ||
) | ||
|
||
if __name__ == "__main__": | ||
demo.launch(server_name="0.0.0.0", server_port=8000) |
90 changes: 90 additions & 0 deletions
90
google/fingerprinters/web/scripts/updater/community/gradio/update.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copyright 2022 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -e | ||
|
||
source ../../common.sh | ||
|
||
SCRIPT_PATH="$(cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P)" | ||
# Root path to the web fingerprinter plugin. | ||
PROJECT_ROOT="$(cd -- "${SCRIPT_PATH}/../../../.." >/dev/null 2>&1 ; pwd -P)" | ||
# Path to the configurations for starting a live instance of Gradio. | ||
GRADIO_APP_PATH="${SCRIPT_PATH}/app" | ||
# Path to the temporary data holder. | ||
TMP_DATA="/tmp/gradio_fingerprints" | ||
# Path to the local git repository for Gradio codebase. | ||
GIT_REPO="${TMP_DATA}/repo" | ||
# Path to the directory of all the updated fingerprints data. | ||
FINGERPRINTS_PATH="${TMP_DATA}/fingerprints" | ||
# Json data of the final result. | ||
JSON_DATA="${FINGERPRINTS_PATH}/fingerprint.json" | ||
# Binary proto data of the final result. | ||
BIN_DATA="${FINGERPRINTS_PATH}/fingerprint.binproto" | ||
# Read all the versions to be fingerprinted. | ||
readarray -t ALL_VERSIONS < "${SCRIPT_PATH}/versions.txt" | ||
mkdir -p "${FINGERPRINTS_PATH}" | ||
|
||
startGradio() { | ||
local version="$1" | ||
pushd "${GRADIO_APP_PATH}" >/dev/null | ||
GRADIO_VERSION="${version}" docker-compose up --build -d | ||
popd >/dev/null | ||
} | ||
|
||
stopGradio() { | ||
local version="$1" | ||
pushd "${GRADIO_APP_PATH}" >/dev/null | ||
GRADIO_VERSION="${version}" docker-compose down --volumes --remove-orphans | ||
popd >/dev/null | ||
} | ||
|
||
# Convert the existing data file to a human-readable json file. | ||
convertFingerprint \ | ||
"${PROJECT_ROOT}/src/main/resources/fingerprinters/web/data/community/gradio.binproto" \ | ||
"${JSON_DATA}" | ||
|
||
# Fetch Gradio codebase. | ||
if [[ ! -d "${GIT_REPO}" ]] ; then | ||
git clone https://github.com/gradio-app/gradio.git "${GIT_REPO}" | ||
fi | ||
|
||
# Update for all the versions listed in versions.txt file. | ||
for gradio_version in "${ALL_VERSIONS[@]}"; do | ||
echo "Fingerprinting Gradio version ${gradio_version} ..." | ||
# Start a live instance of Gradio. | ||
startGradio "${gradio_version}" | ||
# Arbitrarily chosen so that Gradio is up and running. | ||
echo "Waiting for Gradio ${gradio_version} to be ready ..." | ||
sleep 30 | ||
|
||
# Checkout the repository to the correct tag. | ||
checkOutRepo "${GIT_REPO}" "gradio@${gradio_version}" | ||
|
||
updateFingerprint \ | ||
"gradio" \ | ||
"${gradio_version}" \ | ||
"${FINGERPRINTS_PATH}" \ | ||
"${GIT_REPO}/js/app/public/" \ | ||
"http://localhost:8000" | ||
|
||
# Stop the live instance of Gradio. | ||
stopGradio "${gradio_version}" | ||
done | ||
|
||
convertFingerprint "${JSON_DATA}" "${BIN_DATA}" | ||
|
||
echo "Fingerprint updated for Gradio. Please commit the following file:" | ||
echo " ${BIN_DATA}" |
79 changes: 79 additions & 0 deletions
79
google/fingerprinters/web/scripts/updater/community/gradio/versions.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
4.36.1 | ||
4.36.0 | ||
4.35.0 | ||
4.33.0 | ||
4.32.2 | ||
4.32.1 | ||
4.32.0 | ||
4.31.5 | ||
4.31.4 | ||
4.31.3 | ||
4.31.2 | ||
4.31.1 | ||
4.31.0 | ||
4.29.0 | ||
4.28.3 | ||
4.28.2 | ||
4.28.1 | ||
4.28.0 | ||
4.27.0 | ||
4.26.0 | ||
4.25.0 | ||
4.24.0 | ||
4.23.0 | ||
4.22.0 | ||
4.21.0 | ||
4.20.1 | ||
4.20.0 | ||
4.19.2 | ||
4.19.1 | ||
4.19.0 | ||
4.18.0 | ||
4.17.0 | ||
4.16.0 | ||
4.15.0 | ||
4.14.0 | ||
4.13.0 | ||
4.12.0 | ||
4.11.0 | ||
4.10.0 | ||
4.9.1 | ||
4.9.0 | ||
4.8.0 | ||
4.7.0 | ||
4.5.0 | ||
4.4.1 | ||
4.4.0 | ||
4.3.0 | ||
4.2.0 | ||
4.1.2 | ||
4.1.1 | ||
4.1.0 | ||
4.0.2 | ||
4.0.1 | ||
4.0.0 | ||
4.0.0-beta.15 | ||
3.50.2 | ||
3.50.1 | ||
3.50.0 | ||
3.49.0 | ||
3.48.0 | ||
3.47.1 | ||
3.47.0 | ||
3.46.1 | ||
3.46.0 | ||
3.45.2 | ||
3.45.1 | ||
3.45.0 | ||
3.44.4 | ||
3.44.3 | ||
3.44.2 | ||
3.44.1 | ||
3.44.0 | ||
3.43.2 | ||
3.43.1 | ||
3.43.0 | ||
3.42.0 | ||
3.41.2 | ||
3.41.1 | ||
3.41.0 |
Oops, something went wrong.