Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
jagapiou committed Dec 11, 2024
1 parent d1d122e commit 3b73a6f
Show file tree
Hide file tree
Showing 8 changed files with 169 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"name": "Concordia",
"image": "mcr.microsoft.com/devcontainers/python:0-3.11",
"postCreateCommand": ".devcontainer/setup.sh",
"postCreateCommand": "./bin/install.sh",
"customizations": {
"vscode": {
"extensions": [
Expand Down
10 changes: 1 addition & 9 deletions .github/actions/install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,13 @@ runs:
- name: Create venv
if: steps.restore.outputs.cache-hit != 'true'
shell: bash
run: |
python -m venv venv
run: ./bin/setup_venv.sh venv

- name: Activate venv
shell: bash
run: |
echo "${PWD}/venv/bin" >> $GITHUB_PATH
- name: Install
if: steps.restore.outputs.cache-hit != 'true'
shell: bash
run: |
pip install --require-virtualenv --require-hashes -r requirements.txt
pip install --require-virtualenv --no-deps --no-index --no-build-isolation --editable .
- name: Show installation
shell: bash
run: |
Expand Down
17 changes: 11 additions & 6 deletions .devcontainer/setup.sh → bin/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Set up devcontainer
set -e
# Install concordia.
set -euxo pipefail
cd "$(dirname "$0")/.."

python --version
pip --version
pip list
echo 'Installing requirements...'
pip install --no-deps --require-hashes --requirement requirements.txt
echo
echo

pip install --no-deps --require-hashes -r requirements.txt
echo 'Installing Concordia...'
pip install --no-deps --no-index --no-build-isolation --editable .
echo
echo

pip list
36 changes: 36 additions & 0 deletions bin/setup_venv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
#
# Copyright 2024 DeepMind Technologies Limited.
#
# 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.
#
# Sets up the virtual environment.
set -euo pipefail
cd "$(dirname "$0")/.."

readonly VENV_PATH="${1:-venv}"
if [[ -d "${VENV_PATH}" ]]; then
read -p "Virtual environment "${VENV_PATH}" already exists. Overwrite? (Y/N) " confirm
[[ "${confirm}" = [Yy]* ]] && rm -rf "${VENV_PATH}" || exit 1
fi

echo "Creating virtual environment at ${VENV_PATH}..."
python3 -m venv "${VENV_PATH}"
source "${VENV_PATH}"/bin/activate
python --version
pip --version
pip list
echo
echo

./bin/install.sh
41 changes: 41 additions & 0 deletions bin/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
#
# Copyright 2024 DeepMind Technologies Limited.
#
# 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.
#
# Test concordia.
set -euxo pipefail
cd "$(dirname "$0")/.."
FAILURES=false

echo "pytest concordia..."
pytest concordia || FAILURES=true
echo
echo

echo "pytype concordia..."
pytype concordia || FAILURES=true
echo
echo

echo "pylint concordia..."
pylint --errors-only concordia || FAILURES=true
echo
echo

if "${FAILURES}"; then
echo -e '\033[0;31mFAILURE\033[0m' && exit 1
else
echo -e '\033[0;32mSUCCESS\033[0m'
fi
56 changes: 56 additions & 0 deletions bin/test_examples.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash
#
# Copyright 2024 DeepMind Technologies Limited.
#
# 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.
#
# Test the examples.
set -euxo pipefail
cd "$(dirname "$0")/.."
FAILURES=false

echo "pytest examples..."
pytest examples || FAILURES=true
echo
echo

echo "pytype examples..."
pytype examples || FAILURES=true
echo
echo

echo "pylint examples..."
pylint --errors-only examples || FAILURES=true
echo
echo

echo "convert notebooks..."
./bin/convert_notebooks.sh notebooks
echo
echo

echo "pytype notebooks..."
pytype --pythonpath=. notebooks || FAILURES=true
echo
echo

echo "pylint notebooks..."
pylint --errors-only notebooks || FAILURES=true
echo
echo

if "${FAILURES}"; then
echo -e '\033[0;31mFAILURE\033[0m' && exit 1
else
echo -e '\033[0;32mSUCCESS\033[0m'
fi
22 changes: 22 additions & 0 deletions bin/update_requirements.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
#
# Copyright 2024 DeepMind Technologies Limited.
#
# 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.
#
# Update requirements.txt.
set -euxo pipefail
cd "$(dirname "$0")/.."

pip-compile --quiet --generate-hashes --reuse-hashes --upgrade --strip-extras \
--extra dev setup.py examples/requirements.in
2 changes: 1 addition & 1 deletion examples/requirements.txt → examples/requirements.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Requirements for the Concordia examples.
absl-py
docstring-parser
gdm-concordia
immutabledict
IPython
matplotlib
Expand Down

0 comments on commit 3b73a6f

Please sign in to comment.