Skip to content

Commit 259e394

Browse files
authored
Improve the devcontainer settings (keras-team#1511)
* update container setup * use black formatting on save * add the flake8 extension
1 parent cd12204 commit 259e394

File tree

7 files changed

+46
-53
lines changed

7 files changed

+46
-53
lines changed

.devcontainer/Dockerfile

+2-16
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,2 @@
1-
ARG VERSION
2-
3-
FROM tensorflow/tensorflow:${VERSION}
4-
5-
RUN apt-get update && apt-get install -y \
6-
locales \
7-
&& rm -rf /var/lib/apt/lists/*
8-
9-
RUN pip install \
10-
black[jupyter] \
11-
flake8 \
12-
isort \
13-
pytest \
14-
regex \
15-
tensorflow_datasets \
16-
pycocotools
1+
FROM mcr.microsoft.com/vscode/devcontainers/python:3.8
2+
COPY setup.sh /setup.sh

.devcontainer/devcontainer.json

+30-27
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,48 @@
22
"name": "Keras-cv",
33
"build": {
44
"dockerfile": "Dockerfile",
5-
"args": {
5+
"args": {
66
"VERSION": "2.11.0"
77
// Uncomment this if GPU support is required
88
// "VERSION": "2.11.0-gpu",
99
}
1010
},
11-
12-
"settings": {
13-
"python.pythonPath": "/usr/bin/python3",
14-
"python.linting.enabled": true,
15-
"python.linting.flake8Enabled": true,
16-
"python.testing.pytestEnabled":true,
17-
"python.editor.defaultFormatter": "ms-python.black-formatter",
18-
"python.editor.formatOnSave": true,
19-
"python.editor.codeActionsOnSave": {
20-
"source.organizeImports": true
11+
"customizations": {
12+
"vscode": {
13+
"settings": {
14+
"python.linting.enabled": true,
15+
"python.linting.flake8Enabled": true,
16+
"python.linting.pylintEnabled": false,
17+
"python.testing.pytestEnabled": true,
18+
"editor.formatOnSave": true,
19+
"editor.codeActionsOnSave": {
20+
"source.organizeImports": true
21+
},
22+
"[python]": {
23+
"editor.defaultFormatter": "ms-python.black-formatter"
24+
},
25+
"editor.rulers": [
26+
80
27+
]
28+
},
29+
"extensions": [
30+
"ms-python.python",
31+
"ms-python.isort",
32+
"ms-python.flake8",
33+
"ms-python.black-formatter"
34+
]
2135
}
2236
},
23-
24-
"extensions": [
25-
"ms-python.python",
26-
"ms-python.isort",
27-
"ms-python.black-formatter"
28-
],
29-
3037
"features": {
31-
"git": {
32-
"version": "os-provided"
33-
}
38+
"ghcr.io/devcontainers/features/github-cli:1": {}
3439
},
35-
3640
// TODO: Improve to allow dynamic runArgs, see microsoft/vscode-remote-release#3972
3741
// Uncomment this if GPU support is required
3842
// "runArgs": [
39-
// "--gpus=all"
43+
// "--gpus=all"
4044
// ],
41-
42-
"onCreateCommand": "locale-gen \"en_US.UTF-8\""
45+
"onCreateCommand": "locale-gen \"en_US.UTF-8\"",
4346
// Optional: install pre-commit hooks
4447
// "postCreateCommand": "git config core.hooksPath .github/.githooks"
45-
46-
}
48+
"postCreateCommand": "sh /setup.sh"
49+
}

.devcontainer/setup.sh

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
sudo pip install --upgrade pip
2+
sudo pip install -e ".[tests]"

pyproject.toml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[tool.black]
2+
line-length = 80
3+
4+
[tool.isort]
5+
profile = "black"
6+
force_single_line = "True"
7+
known_first_party = ["keras_cv", "tests"]
8+
default_section = "THIRDPARTY"
9+
line_length = 80

setup.cfg

-7
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,3 @@ ignore =
3535
W605
3636
# Ignore for tf.cond lambda
3737
E731
38-
39-
[isort]
40-
profile = black
41-
force_single_line = True
42-
known_first_party = keras_cv,tests
43-
default_section = THIRDPARTY
44-
line_length = 80

shell/format.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
2-
isort --sl .
3-
black --line-length 80 .
2+
isort .
3+
black .

shell/lint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ then
3131
exit 1
3232
fi
3333
[ $# -eq 0 ] && echo "no issues with flake8"
34-
black --line-length 80 --check $files
34+
black --check $files
3535
if ! [ $? -eq 0 ]
3636
then
3737
echo "Please run \"sh shell/format.sh\" to format the code."

0 commit comments

Comments
 (0)