Skip to content
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

chore(tests): create a test to check whether requirements.txt was generated with pip-compile #11512

Closed
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
40 changes: 40 additions & 0 deletions .github/resources/scripts/test-requirements.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash

check_requirements() {
local req_in="$1"
local req_txt="$2"

temp_file=$(mktemp)

pip-compile - < "$req_in" --output-file="$temp_file" --annotate --resolver=backtracking

# Compare the generated file with the existing requirements.txt
if diff -q "$temp_file" "$req_txt" >/dev/null; then
echo "Success: $req_txt matches the output of pip-compile for $req_in."
rm "$temp_file"
exit 0
else
echo "Error: $req_txt does not match the output of pip-compile for $req_in."
echo "Differences:"
diff "$temp_file" "$req_txt"
rm "$temp_file"
exit 1
fi
}

for req_in_file in $(find . -name "requirements.in"); do

echo $req_in_file
req_txt="${req_in_file/requirements.in/requirements.txt}"

# Check if the corresponding requirements.txt exists
if [[ -f "$req_txt" ]]; then
echo "Checking $req_in_file against $req_txt..."
check_requirements "$req_in_file" "$req_txt"
else
echo "Error: $req_txt not found for $req_in_file."
exit 1
fi
done

echo "All checks completed successfully."
30 changes: 30 additions & 0 deletions .github/workflows/requirements-txt-automatically-generated.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: requirements.txt automatically generated

on:
push:
branches: [master]

pull_request:
paths:
- '.github/workflows/requirements-txt-automatically-generated.yaml'

jobs:
requirements-generated-tests:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Install pip-tools
run: |
pip3 install pip-tools

- name: Run Tests
run: |
make test-requirements
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to create this target. Please name it test-requirements-txt-automatically-generated.
Also, follow the same pattern as in #11509, with a setup target. You'll have to create the Makefile.setup.mk file, in case that PR is not merged yet.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, i'll follow your guideline.

14 changes: 3 additions & 11 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# This file is autogenerated by pip-compile with Python 3.7
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# pip-compile --output-file=- -
# pip-compile --resolver=backtracking
#
cachetools==5.3.1
# via google-auth
Expand Down Expand Up @@ -41,10 +41,8 @@ googleapis-common-protos==1.60.0
# via google-api-core
idna==3.4
# via requests
importlib-metadata==6.7.0
# via click
kfp==2.0.1
# via -r -
# via -r requirements.in
kfp-pipeline-spec==0.2.2
# via kfp
kfp-server-api==2.0.1
Expand Down Expand Up @@ -93,10 +91,6 @@ six==1.16.0
# python-dateutil
tabulate==0.9.0
# via kfp
typing-extensions==4.7.1
# via
# importlib-metadata
# kfp
urllib3==1.26.16
# via
# google-auth
Expand All @@ -106,8 +100,6 @@ urllib3==1.26.16
# requests
websocket-client==1.6.1
# via kubernetes
zipp==3.15.0
# via importlib-metadata

# The following packages are considered to be unsafe in a requirements file:
# setuptools
64 changes: 25 additions & 39 deletions backend/src/apiserver/visualization/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# This file is autogenerated by pip-compile with Python 3.8
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# pip-compile --output-file=- --resolver=backtracking -
# pip-compile --output-file=- ./backend/src/apiserver/visualization/requirements.in
#
absl-py==1.4.0
# via
Expand All @@ -12,13 +12,12 @@ absl-py==1.4.0
# tensorflow-metadata
# tensorflow-model-analysis
# tfx-bsl
anyio==4.5.2
anyio==4.8.0
# via
# httpx
# jupyter-server
apache-beam[gcp]==2.46.0
# via
# apache-beam
# tensorflow-data-validation
# tensorflow-model-analysis
# tfx-bsl
Expand All @@ -42,10 +41,8 @@ backcall==0.2.0
# via ipython
beautifulsoup4==4.12.3
# via nbconvert
bleach[css]==6.1.0
# via
# bleach
# nbconvert
bleach[css]==6.2.0
# via nbconvert
bokeh==1.2.0
# via -r -
cachetools==4.2.4
Expand Down Expand Up @@ -79,7 +76,7 @@ docopt==0.6.2
# via hdfs
exceptiongroup==1.2.2
# via anyio
fastavro==1.9.7
fastavro==1.10.0
# via apache-beam
fasteners==0.19
# via
Expand All @@ -97,7 +94,6 @@ gcsfs==0.2.3
# via -r -
google-api-core[grpc]==2.24.0
# via
# google-api-core
# google-cloud-bigquery
# google-cloud-bigquery-storage
# google-cloud-bigtable
Expand Down Expand Up @@ -172,7 +168,7 @@ google-cloud-videointelligence==1.16.3
# via apache-beam
google-cloud-vision==3.7.2
# via apache-beam
google-crc32c==1.5.0
google-crc32c==1.6.0
# via google-resumable-media
google-pasta==0.2.0
# via tensorflow
Expand Down Expand Up @@ -211,7 +207,7 @@ grpcio-status==1.48.2
# google-cloud-pubsublite
h11==0.14.0
# via httpcore
h5py==3.11.0
h5py==3.12.1
# via tensorflow
hdfs==2.7.3
# via apache-beam
Expand Down Expand Up @@ -240,11 +236,6 @@ importlib-metadata==8.5.0
# jupyterlab-server
# markdown
# nbconvert
importlib-resources==6.4.5
# via
# jsonschema
# jsonschema-specifications
# jupyterlab
ipykernel==5.1.1
# via
# -r -
Expand Down Expand Up @@ -286,7 +277,7 @@ jsonschema[format-nongpl]==4.23.0
# jupyter-events
# jupyterlab-server
# nbformat
jsonschema-specifications==2023.12.1
jsonschema-specifications==2024.10.1
# via jsonschema
jupyter-client==8.6.3
# via
Expand All @@ -302,11 +293,11 @@ jupyter-core==5.7.2
# nbclient
# nbconvert
# nbformat
jupyter-events==0.10.0
jupyter-events==0.11.0
# via jupyter-server
jupyter-lsp==2.2.5
# via jupyterlab
jupyter-server==2.14.2
jupyter-server==2.15.0
# via
# jupyter-lsp
# jupyterlab
Expand Down Expand Up @@ -340,7 +331,7 @@ markupsafe==2.0.1
# nbconvert
mistune==3.1.0
# via nbconvert
nbclient==0.10.1
nbclient==0.10.2
# via nbconvert
nbconvert==7.16.5
# via
Expand Down Expand Up @@ -410,10 +401,8 @@ pexpect==4.9.0
# via ipython
pickleshare==0.7.5
# via ipython
pillow==10.4.0
pillow==11.1.0
# via bokeh
pkgutil-resolve-name==1.3.10
# via jsonschema
platformdirs==4.3.6
# via jupyter-core
prometheus-client==0.21.1
Expand Down Expand Up @@ -486,7 +475,7 @@ pygments==2.19.1
# nbconvert
pymongo==3.13.0
# via apache-beam
pyparsing==3.1.4
pyparsing==3.2.1
# via
# httplib2
# pydot
Expand All @@ -503,7 +492,6 @@ python-json-logger==3.2.1
pytz==2024.2
# via
# apache-beam
# babel
# pandas
pyyaml==6.0.2
# via
Expand All @@ -513,7 +501,7 @@ pyzmq==26.2.0
# via
# jupyter-client
# jupyter-server
referencing==0.35.1
referencing==0.36.1
# via
# jsonschema
# jsonschema-specifications
Expand All @@ -540,7 +528,7 @@ rfc3986-validator==0.1.1
# via
# jsonschema
# jupyter-events
rpds-py==0.20.1
rpds-py==0.22.3
# via
# jsonschema
# referencing
Expand All @@ -550,7 +538,7 @@ rsa==4.9
# oauth2client
scikit-learn==0.24.2
# via -r -
scipy==1.10.1
scipy==1.13.1
# via
# scikit-learn
# tensorflow-model-analysis
Expand All @@ -559,7 +547,6 @@ send2trash==1.8.3
six==1.17.0
# via
# astunparse
# bleach
# bokeh
# google-api-python-client
# google-apitools
Expand Down Expand Up @@ -595,7 +582,7 @@ tensorflow-data-validation==1.9.0
# via -r -
tensorflow-estimator==2.10.0
# via tensorflow
tensorflow-io-gcs-filesystem==0.34.0
tensorflow-io-gcs-filesystem==0.37.1
# via tensorflow
tensorflow-metadata==1.9.0
# via
Expand All @@ -609,7 +596,7 @@ tensorflow-serving-api==2.10.1
# via
# -r -
# tfx-bsl
termcolor==2.4.0
termcolor==2.5.0
# via tensorflow
terminado==0.18.1
# via
Expand All @@ -621,7 +608,7 @@ tfx-bsl==1.9.0
# tensorflow-model-analysis
threadpoolctl==3.5.0
# via scikit-learn
tinycss2==1.2.1
tinycss2==1.4.0
# via bleach
tomli==2.2.1
# via jupyterlab
Expand Down Expand Up @@ -658,16 +645,17 @@ typing-extensions==4.12.2
# async-lru
# mistune
# python-json-logger
# referencing
# tensorflow
uri-template==1.3.0
# via jsonschema
uritemplate==3.0.1
# via google-api-python-client
urllib3==2.2.3
urllib3==2.3.0
# via requests
wcwidth==0.2.13
# via prompt-toolkit
webcolors==24.8.0
webcolors==24.11.1
# via jsonschema
webencodings==0.5.1
# via
Expand All @@ -685,10 +673,8 @@ widgetsnbextension==3.6.10
# via ipywidgets
wrapt==1.17.2
# via tensorflow
zipp==3.20.2
# via
# importlib-metadata
# importlib-resources
zipp==3.21.0
# via importlib-metadata
zstandard==0.23.0
# via apache-beam

Expand Down
4 changes: 2 additions & 2 deletions sdk/python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# pip-compile --no-emit-index-url requirements.in
# pip-compile --resolver=backtracking
#
cachetools==5.4.0
# via google-auth
Expand Down
2 changes: 1 addition & 1 deletion test/kfp-functional-test/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# pip-compile requirements.in
# pip-compile --resolver=backtracking
#
cachetools==5.3.3
# via google-auth
Expand Down
Loading
Loading