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

Devcontainer configuration #621

Merged
merged 35 commits into from
Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
d6d3670
First Devcontainer configuration
twsl Nov 14, 2021
88b8675
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 14, 2021
2ded793
Fix manifest missing error
twsl Nov 14, 2021
0ad69ea
Updated CHANGELOG
twsl Nov 14, 2021
1a791da
Set default interpreter
twsl Nov 14, 2021
3ec79e9
Add docs
twsl Nov 15, 2021
245c564
Merge branch 'master' into devcontainer
twsl Nov 15, 2021
22c3af8
Merge branch 'master' into devcontainer
twsl Nov 21, 2021
f3b9ff0
Add docs support
twsl Nov 21, 2021
f074381
Update devcontainer.json
twsl Nov 24, 2021
c592d2a
Merge branch 'master' into devcontainer
Borda Nov 24, 2021
9bc44ae
drop yapf
Borda Nov 24, 2021
aa08127
Merge branch 'master' into devcontainer
SkafteNicki Nov 25, 2021
8f25cca
Apply suggestions from code review
Borda Nov 25, 2021
41f6629
Add sorting
twsl Nov 25, 2021
400f30e
Merge branch 'master' into devcontainer
mergify[bot] Nov 25, 2021
80c99fb
Merge branch 'master' into devcontainer
mergify[bot] Nov 25, 2021
e4b8235
Fix pre-commit python version
twsl Nov 26, 2021
a0e6b9b
Use existing configurations
twsl Nov 26, 2021
9ce751c
Moved pip dependencies to docker image
twsl Nov 26, 2021
4d0154e
Update tabs
twsl Nov 27, 2021
93ae299
Merge branch 'master' into devcontainer
mergify[bot] Nov 29, 2021
d5e93f3
Merge branch 'master' into devcontainer
mergify[bot] Nov 29, 2021
a7b89bd
Create docker_devcontainer.yml
justusschock Nov 30, 2021
f23decb
Update .github/workflows/docker_devcontainer.yml
justusschock Nov 30, 2021
040c2d3
Apply suggestions from code review
justusschock Nov 30, 2021
1e9b2d2
Update .github/workflows/docker_devcontainer.yml
justusschock Nov 30, 2021
6008ecc
Create ci_docker.yml
justusschock Nov 30, 2021
cc6191e
Update ci_docker.yml
justusschock Nov 30, 2021
3c94b7d
Update ci_docker.yml
justusschock Nov 30, 2021
f297510
Update docker_devcontainer.yml
justusschock Nov 30, 2021
3e90658
Update ci_docker.yml
justusschock Nov 30, 2021
4a7e938
Update docker_devcontainer.yml
justusschock Nov 30, 2021
57714f0
Update .github/workflows/ci_docker.yml
justusschock Nov 30, 2021
757410e
Update .devcontainer/devcontainer.json
justusschock Nov 30, 2021
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
26 changes: 26 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.194.0/containers/python-3/.devcontainer/base.Dockerfile

# [Choice] Python version: 3, 3.9, 3.8, 3.7, 3.6
ARG VARIANT="3.9"
Borda marked this conversation as resolved.
Show resolved Hide resolved
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}
justusschock marked this conversation as resolved.
Show resolved Hide resolved

# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
ARG NODE_VERSION="none"
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi

COPY requirements/ /tmp/pip-tmp/requirements/
COPY requirements.txt /tmp/pip-tmp/
RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements/devel.txt -r /tmp/pip-tmp/requirements/docs.txt \
&& rm -rf /tmp/pip-tmp

# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image.
# COPY requirements.txt /tmp/pip-tmp/
# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
# && rm -rf /tmp/pip-tmp

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>

# [Optional] Uncomment this line to install global node packages.
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
91 changes: 91 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.194.0/containers/python-3
{
"name": "Python 3",
justusschock marked this conversation as resolved.
Show resolved Hide resolved
"image": "pytorchlightning/metrics-dev"
"build": {
"dockerfile": "Dockerfile",
"context": "..",
"args": {
// Update 'VARIANT' to pick a Python version: 3, 3.6, 3.7, 3.8, 3.9
"VARIANT": "3.9",
// Options
"NODE_VERSION": "none"
}
},
"runArgs": [
// Enable GPU passthrough, requires WSL2 on Windows
//"--gpus=all",
],
// Set *default* container specific settings.json values on container create.
"settings": {
"editor.formatOnSave": true,
"editor.rulers": [
120
],
"python.pythonPath": "/usr/local/bin/python",
"python.defaultInterpreterPath": "/usr/local/bin/python",
"python.languageServer": "Pylance",
"python.autoComplete.addBrackets": true,
"python.analysis.autoImportCompletions": true,
"python.analysis.completeFunctionParens": true,
"python.analysis.autoSearchPaths": true,
"python.analysis.useImportHeuristic": true,
"python.sortImports": true,
"python.sortImports.args": [
"--settings-path=${workspaceFolder}/pyproject.toml",
],
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
"python.formatting.provider": "black",
"python.formatting.blackArgs": [
"--config=${workspaceFolder}/pyproject.toml"
],
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint",
"python.linting.enabled": true,
"python.linting.pylintEnabled": false,
"python.linting.flake8Enabled": true,
"python.linting.flake8Args": [
"--config=${workspaceFolder}/setup.cfg",
"--verbose"
],
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"restructuredtext.confPath": "${workspaceFolder}/docs/source",
"restructuredtext.builtDocumentationPath": "${workspaceFolder}/docs/build",
"restructuredtext.languageServer.disabled": false,
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true,
}
}
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",
"visualstudioexptteam.vscodeintellicode",
"kevinrose.vsc-python-indent",
"littlefoxteam.vscode-python-test-adapter",
"hbenl.vscode-test-explorer",
"medo64.render-crlf",
"shardulm94.trailing-spaces",
"njqdev.vscode-python-typehint",
"lextudio.restructuredtext",
"trond-snekvik.simple-rst",
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "pre-commit install",
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
35 changes: 35 additions & 0 deletions .github/workflows/ci_docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: CI Docker

on: # Trigger the workflow on push or pull request, but only for the master branch
push:
branches: [master]
pull_request:
branches: [master]
paths:
- "requirements/*"
- ".devcontainer/*"
- "environment.yml"
- "requirements.txt"
- ".github/workflows/*docker*.yml"
- "setup.py"

jobs:
build-PL:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
python_version: ["3.9"]
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Build Devcontainer Docker
# publish master/release
uses: docker/build-push-action@v2
with:
build-args: |
VARIANT=${{ matrix.python_version }}
file: .devcontainer/Dockerfile
push: false
timeout-minutes: 50
32 changes: 32 additions & 0 deletions .github/workflows/docker_devcontainer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: "Build & Push Docker Devcontainer"

on:
push:
branches: [master]

jobs:
build-devcontainer:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
python_version: ["3.9"]
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and Push Devcontainer
# publish master/release
uses: docker/build-push-action@v2
with:
build-args: |
VARIANT=${{ matrix.python_version }}
file: .devcontainer/Dockerfile
push: true
tags: pytorchlightning/metrics-dev
timeout-minutes: 50
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

default_language_version:
python: python3.8
python: python3.9

ci:
autofix_prs: true
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `SQuAD` ([#623](https://github.com/PyTorchLightning/metrics/pull/623))
- `CHRFScore` ([#641](https://github.com/PyTorchLightning/metrics/pull/641))

- Add a default VS Code devcontainer configuration ([#621](https://github.com/PyTorchLightning/metrics/pull/621))

- Added `MinMaxMetric` to wrappers ([#556](https://github.com/PyTorchLightning/metrics/pull/556))

Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ exclude *.yml
exclude *.yaml
exclude Makefile

prune .devcontainer
prune .git
prune .github
prune .circleci
Expand Down
9 changes: 9 additions & 0 deletions docs/source/pages/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,12 @@ Implementing your own metric is as easy as subclassing an :class:`torch.nn.Modul
3. Implement ``compute`` method, where the final metric computations happens

For practical examples and more info about implementing a metric, please see this :ref:`page <implement>`.


Development Environment
~~~~~~~~~~~~~~~~~~~~~~~

TorchMetrics provides a `Devcontainer <https://code.visualstudio.com/docs/remote/containers>`_ configuration for `Visual Studio Code <https://code.visualstudio.com/>`_ to use a `Docker container <https://www.docker.com/>`_ as a pre-configured development environment.
This avoids struggles setting up a development environment and makes them reproducible and consistent.
Please follow the `installation instructions <https://code.visualstudio.com/docs/remote/containers#_installation>`_ and make yourself familiar with the `container tutorials <https://code.visualstudio.com/docs/remote/containers-tutorial>`_ if you want to use them.
In order to use GPUs, you can enable them within the ``.devcontainer/devcontainer.json`` file.