Skip to content

Commit 671206a

Browse files
committed
WIP
1 parent e787e1b commit 671206a

File tree

13 files changed

+2127
-78
lines changed

13 files changed

+2127
-78
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// on large machines).
1515
"--shm-size=6gb"
1616
],
17-
"postCreateCommand": "pip install --editable .[dev]",
17+
"postCreateCommand": ".devcontainer/setup.sh",
1818
"customizations": {
1919
"vscode": {
2020
"extensions": [

.devcontainer/setup.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
# Set up devcontainer
18+
set -e
19+
pip install --require-virtualenv --require-hashes -r requirements.txt
20+
pip install --require-virtualenv --no-deps --no-index --no-build-isolation --editable .

.github/actions/install-examples/action.yml

Lines changed: 0 additions & 57 deletions
This file was deleted.

.github/actions/install-meltingpot/action.yml renamed to .github/actions/install/action.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: install-meltingpot
1+
name: install
22

33
inputs:
44
python-version:
@@ -34,16 +34,16 @@ runs:
3434
else
3535
exit 1
3636
fi
37-
echo "key=${name}-${version}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('setup.py') }}" >> $GITHUB_OUTPUT
37+
echo "key=${name}-${version}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('requirements.txt') }}" >> $GITHUB_OUTPUT
3838
39-
- name: Restore Melting Pot installation
39+
- name: Restore installation
4040
id: restore
4141
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
4242
with:
4343
path: |
4444
meltingpot/assets
4545
venv
46-
key: install-meltingpot-${{ steps.cache-key.outputs.key }}
46+
key: install-${{ steps.cache-key.outputs.key }}
4747

4848
- name: Create venv
4949
if: steps.restore.outputs.cache-hit != 'true'
@@ -56,11 +56,12 @@ runs:
5656
run: |
5757
echo "${PWD}/venv/bin" >> $GITHUB_PATH
5858
59-
- name: Install Melting Pot
59+
- name: Install
6060
if: steps.restore.outputs.cache-hit != 'true'
6161
shell: bash
6262
run: |
63-
pip install --editable .[dev]
63+
pip install --require-virtualenv --require-hashes -r requirements.txt
64+
pip install --require-virtualenv --no-deps --no-index --no-build-isolation --editable .
6465
6566
- name: Show installation
6667
shell: bash
@@ -77,7 +78,7 @@ runs:
7778
pytype --version
7879
pip list
7980
80-
- name: Save Melting Pot installation
81+
- name: Save installation
8182
if: steps.restore.outputs.cache-hit != 'true'
8283
uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
8384
with:

.github/workflows/test-examples.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@ on:
55
branches:
66
- main
77
paths:
8-
- '.github/actions/install-examples/action.yml'
9-
- '.github/actions/install-meltingpot/action.yml'
8+
- '.github/actions/install/action.yml'
109
- '.github/workflows/test-examples.yml'
1110
- '.pylintrc'
1211
- 'examples/**'
1312
- 'meltingpot/**'
1413
- 'pyproject.toml'
14+
- 'requirements.txt'
1515
- 'setup.py'
1616
pull_request:
1717
branches:
1818
- main
1919
paths:
20-
- '.github/actions/install-examples.yml'
21-
- '.github/actions/install-meltingpot.yml'
20+
- '.github/actions/install/action.yml'
2221
- '.github/workflows/test-examples.yml'
2322
- '.pylintrc'
2423
- 'examples/**'
2524
- 'meltingpot/**'
2625
- 'pyproject.toml'
26+
- 'requirements.txt'
2727
- 'setup.py'
2828
workflow_dispatch:
2929

@@ -42,8 +42,8 @@ jobs:
4242
- name: Checkout Melting Pot
4343
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
4444

45-
- name: Install examples
46-
uses: ./.github/actions/install-examples
45+
- name: Install Melting Pot
46+
uses: ./.github/actions/install
4747

4848
- name: Test examples
4949
run: pytest examples

.github/workflows/test-meltingpot.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,23 @@ on:
55
branches:
66
- main
77
paths:
8-
- '.github/actions/install-meltingpot/action.yml'
8+
- '.github/actions/install/action.yml'
99
- '.github/workflows/test-meltingpot.yml'
1010
- '.pylintrc'
1111
- 'meltingpot/**'
1212
- 'pyproject.toml'
13+
- 'requirements.txt'
1314
- 'setup.py'
1415
pull_request:
1516
branches:
1617
- main
1718
paths:
18-
- '.github/actions/install-meltingpot/action.yml'
19+
- '.github/actions/install/action.yml'
1920
- '.github/workflows/test-meltingpot.yml'
2021
- '.pylintrc'
2122
- 'meltingpot/**'
2223
- 'pyproject.toml'
24+
- 'requirements.txt'
2325
- 'setup.py'
2426
workflow_dispatch:
2527

@@ -38,7 +40,7 @@ jobs:
3840
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
3941

4042
- name: Install Melting Pot
41-
uses: ./.github/actions/install-meltingpot
43+
uses: ./.github/actions/install
4244

4345
- name: Test Melting Pot
4446
run: pytest meltingpot

bin/install.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+
# Installation script.
18+
set -e
19+
python3 -m venv venv
20+
source venv/bin/activate
21+
pip install --require-virtualenv --require-hashes -r requirements.txt
22+
pip install --require-virtualenv --no-deps --no-index --no-build-isolation --editable .

bin/test.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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 meltingpot.
18+
FAILURES=false
19+
20+
echo "pytest meltingpot..."
21+
pytest meltingpot || FAILURES=true
22+
echo
23+
echo
24+
25+
echo "pytype meltingpot..."
26+
pytype meltingpot || FAILURES=true
27+
echo
28+
echo
29+
30+
echo "pylint meltingpot..."
31+
pylint --errors-only meltingpot || FAILURES=true
32+
echo
33+
echo
34+
35+
if "${FAILURES}"; then
36+
echo -e '\033[0;31mFAILURE\033[0m' && exit 1
37+
else
38+
echo -e '\033[0;32mSUCCESS\033[0m'
39+
fi

bin/test_examples.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
FAILURES=false
19+
20+
echo "pytest examples..."
21+
pytest examples || FAILURES=true
22+
echo
23+
echo
24+
25+
echo "pytype examples..."
26+
pytype examples || FAILURES=true
27+
echo
28+
echo
29+
30+
echo "pylint examples..."
31+
pylint --errors-only examples || FAILURES=true
32+
echo
33+
echo
34+
35+
if "${FAILURES}"; then
36+
echo -e '\033[0;31mFAILURE\033[0m' && exit 1
37+
else
38+
echo -e '\033[0;32mSUCCESS\033[0m'
39+
fi

bin/update_requirements.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
19+
pip-compile \
20+
--quiet --generate-hashes --reuse-hashes --upgrade --strip-extras \
21+
--extra dev setup.py || exit 1

0 commit comments

Comments
 (0)