Skip to content

Commit 6c871c7

Browse files
jagapioucopybara-github
authored andcommitted
Add useful scripts to repo
PiperOrigin-RevId: 705308893 Change-Id: I099ef104290569385037ab0d2168b04d0f678b5e
1 parent c32219b commit 6c871c7

File tree

5 files changed

+186
-0
lines changed

5 files changed

+186
-0
lines changed

bin/install.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
#
3+
# Copyright 2024 DeepMind Technologies Limited.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# Install concordia.
18+
set -euxo pipefail
19+
cd "$(dirname "$0")/.."
20+
21+
echo 'Installing requirements...'
22+
pip install --no-deps --require-hashes --requirement requirements.txt
23+
echo
24+
echo
25+
26+
echo 'Installing Concordia...'
27+
pip install --no-deps --no-index --no-build-isolation --editable .
28+
echo
29+
echo
30+
31+
pip list

bin/setup_venv.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
#
3+
# Copyright 2024 DeepMind Technologies Limited.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# Sets up the virtual environment.
18+
set -euo pipefail
19+
cd "$(dirname "$0")/.."
20+
21+
readonly VENV_PATH="${1:-venv}"
22+
if [[ -d "${VENV_PATH}" ]]; then
23+
read -p "Virtual environment "${VENV_PATH}" already exists. Overwrite? (Y/N) " confirm
24+
[[ "${confirm}" = [Yy]* ]] && rm -rf "${VENV_PATH}" || exit 1
25+
fi
26+
27+
echo "Creating virtual environment at ${VENV_PATH}..."
28+
python3 -m venv "${VENV_PATH}"
29+
source "${VENV_PATH}"/bin/activate
30+
python --version
31+
pip --version
32+
pip list
33+
echo
34+
echo
35+
36+
./bin/install.sh

bin/test.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
#
3+
# Copyright 2024 DeepMind Technologies Limited.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# Test concordia.
18+
set -euxo pipefail
19+
cd "$(dirname "$0")/.."
20+
FAILURES=false
21+
22+
echo "pytest concordia..."
23+
pytest concordia || FAILURES=true
24+
echo
25+
echo
26+
27+
echo "pytype concordia..."
28+
pytype concordia || FAILURES=true
29+
echo
30+
echo
31+
32+
echo "pylint concordia..."
33+
pylint --errors-only concordia || FAILURES=true
34+
echo
35+
echo
36+
37+
if "${FAILURES}"; then
38+
echo -e '\033[0;31mFAILURE\033[0m' && exit 1
39+
else
40+
echo -e '\033[0;32mSUCCESS\033[0m'
41+
fi

bin/test_examples.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
#
3+
# Copyright 2024 DeepMind Technologies Limited.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# Test the examples.
18+
set -euxo pipefail
19+
cd "$(dirname "$0")/.."
20+
FAILURES=false
21+
22+
echo "pytest examples..."
23+
pytest examples || FAILURES=true
24+
echo
25+
echo
26+
27+
echo "pytype examples..."
28+
pytype examples || FAILURES=true
29+
echo
30+
echo
31+
32+
echo "pylint examples..."
33+
pylint --errors-only examples || FAILURES=true
34+
echo
35+
echo
36+
37+
echo "convert notebooks..."
38+
./bin/convert_notebooks.sh notebooks
39+
echo
40+
echo
41+
42+
echo "pytype notebooks..."
43+
pytype --pythonpath=. notebooks || FAILURES=true
44+
echo
45+
echo
46+
47+
echo "pylint notebooks..."
48+
pylint --errors-only notebooks || FAILURES=true
49+
echo
50+
echo
51+
52+
if "${FAILURES}"; then
53+
echo -e '\033[0;31mFAILURE\033[0m' && exit 1
54+
else
55+
echo -e '\033[0;32mSUCCESS\033[0m'
56+
fi

bin/update_requirements.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
#
3+
# Copyright 2024 DeepMind Technologies Limited.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# Update requirements.txt.
18+
set -euxo pipefail
19+
cd "$(dirname "$0")/.."
20+
21+
pip-compile --generate-hashes --reuse-hashes --strip-extras \
22+
--upgrade --extra dev setup.py examples/requirements.in

0 commit comments

Comments
 (0)