From 3f79a6e32d329531e99b05da5f83b4227f75fd2d Mon Sep 17 00:00:00 2001 From: Andrea Censi Date: Tue, 22 Feb 2022 13:38:05 +0100 Subject: fix --- .devcontainer/Dockerfile | 21 +++++++++++++++++ .devcontainer/devcontainer.json | 52 +++++++++++++++++++++++++++++++++++++++++ Makefile | 6 ++++- requirements.txt | 1 + 4 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..86dee1b --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,21 @@ +# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.209.6/containers/python-3/.devcontainer/base.Dockerfile + +# [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.10, 3.9, 3.8, 3.7, 3.6, 3-bullseye, 3.10-bullseye, 3.9-bullseye, 3.8-bullseye, 3.7-bullseye, 3.6-bullseye, 3-buster, 3.10-buster, 3.9-buster, 3.8-buster, 3.7-buster, 3.6-buster +ARG VARIANT="3.10-bullseye" +FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT} + +# [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 + +# [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 + +# [Optional] Uncomment this line to install global node packages. +# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..6970d3c --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,52 @@ +// 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.209.6/containers/python-3 +{ + "name": "Python 3", + "build": { + "dockerfile": "Dockerfile", + "context": "..", + "args": { + // Update 'VARIANT' to pick a Python version: 3, 3.10, 3.9, 3.8, 3.7, 3.6 + // Append -bullseye or -buster to pin to an OS version. + // Use -bullseye variants on local on arm64/Apple Silicon. + "VARIANT": "3.10", + // Options + "NODE_VERSION": "none" + } + }, + + // Set *default* container specific settings.json values on container create. + "settings": { + "python.defaultInterpreterPath": "/usr/local/bin/python", + "python.linting.enabled": false, + "python.linting.pylintEnabled": false, + "python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8", + "python.formatting.blackPath": "/usr/local/py-utils/bin/black", + "python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf", + "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" + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "ms-python.python", + // "ms-python.vscode-pylance" + ], + + // 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": "pip3 install --user -r requirements.txt", + + // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode", + "features": { + "git": "os-provided", + "git-lfs": "latest" + } +} diff --git a/Makefile b/Makefile index 5177571..0aca7d6 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,6 @@ tag=mytag build: docker build --build-arg DOCKER_REGISTRY=${DOCKER_REGISTRY} -t $(tag) . - check: build docker run -it --rm -v $(PWD)/out-results:/ACT4E/out-results $(tag) \ act4e-test --collections act4e_checks --module act4e_solutions @@ -15,3 +14,8 @@ check-%: build docker run -it --rm -v $(PWD)/out-results:/ACT4E/out-results $(tag) \ act4e-test --collections act4e_checks --module act4e_solutions --group $* +local-check: + act4e-test --collections act4e_checks --module act4e_solutions + +local-check-%: + act4e-test --collections act4e_checks --module act4e_solutions --group $* \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index e69de29..87bfd82 100644 --- a/requirements.txt +++ b/requirements.txt @@ -0,0 +1 @@ +ACT4E-exercises \ No newline at end of file -- cgit v1.2.1 From e2dd6011ad2abcec220220f14efdb451c986aea3 Mon Sep 17 00:00:00 2001 From: Andrea Censi Date: Tue, 22 Feb 2022 13:54:04 +0100 Subject: fix --- .devcontainer/devcontainer.json | 3 ++- Makefile | 8 ++++---- README.md | 30 ++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 README.md diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 6970d3c..626e731 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -9,7 +9,7 @@ // Update 'VARIANT' to pick a Python version: 3, 3.10, 3.9, 3.8, 3.7, 3.6 // Append -bullseye or -buster to pin to an OS version. // Use -bullseye variants on local on arm64/Apple Silicon. - "VARIANT": "3.10", + "VARIANT": "3.10-bullseye", // Options "NODE_VERSION": "none" } @@ -34,6 +34,7 @@ // Add the IDs of extensions you want installed when the container is created. "extensions": [ "ms-python.python", + "tht13.html-preview-vscode", // "ms-python.vscode-pylance" ], diff --git a/Makefile b/Makefile index 0aca7d6..3090a59 100644 --- a/Makefile +++ b/Makefile @@ -5,17 +5,17 @@ tag=mytag build: docker build --build-arg DOCKER_REGISTRY=${DOCKER_REGISTRY} -t $(tag) . -check: build +docker-check: build docker run -it --rm -v $(PWD)/out-results:/ACT4E/out-results $(tag) \ act4e-test --collections act4e_checks --module act4e_solutions -check-%: build +docker-check-%: build docker run -it --rm -v $(PWD)/out-results:/ACT4E/out-results $(tag) \ act4e-test --collections act4e_checks --module act4e_solutions --group $* -local-check: +check: act4e-test --collections act4e_checks --module act4e_solutions -local-check-%: +check-%: act4e-test --collections act4e_checks --module act4e_solutions --group $* \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..bf98d63 --- /dev/null +++ b/README.md @@ -0,0 +1,30 @@ + + +## Setup + +Install VS Code. + +Select File -> Open and select *the entire folder*. + +VS Code will give you a message similar to: + +> Folder contains a Dev Container configuration file. Reopen folder to develop in a container. + +Select "Reopen in container". + +Now you should have the folder open while VS Code is in "container development mode". + +Create a new terminal using Terminal -> New Terminal. + +Run the following: + + make check-TestSimpleIntro + +This will have created a file `out-results/result-TestSimpleIntro.html`. + +From the file tree to the left, right-click the file and select "open preview". You will see the results of the testing. + +Now browse the Python files in `src/`. Verify that autocompletion works.. + + + -- cgit v1.2.1 From d33763817e7501bd2ff81f7d5da1900c9d15c8d2 Mon Sep 17 00:00:00 2001 From: Gioele Zardini <32289677+gzardini@users.noreply.github.com> Date: Tue, 22 Feb 2022 14:04:08 +0100 Subject: Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index bf98d63..5bb6b79 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ Install VS Code. Select File -> Open and select *the entire folder*. +VS Code will propose to install "Dev Container". Click "install". + VS Code will give you a message similar to: > Folder contains a Dev Container configuration file. Reopen folder to develop in a container. -- cgit v1.2.1 From c9c95b13effa1840b921a0606936510d7eafa611 Mon Sep 17 00:00:00 2001 From: Andrea Censi Date: Tue, 22 Feb 2022 14:09:51 +0100 Subject: updates --- .devcontainer/Dockerfile | 3 +++ .devcontainer/devcontainer.json | 4 ++-- .pre-commit-config.yaml | 18 ++---------------- .pylintrc | 6 ++++++ requirements.txt | 3 ++- src/act4e_solutions/maps_representation.py | 2 -- src/act4e_solutions/posets_bounds.py | 4 ++-- src/act4e_solutions/posets_representation.py | 1 - src/act4e_solutions/relations_representation.py | 1 - src/act4e_solutions/semigroups_representation.py | 1 - src/act4e_solutions/sets_properties.py | 2 +- src/act4e_solutions/sets_representation.py | 2 +- 12 files changed, 19 insertions(+), 28 deletions(-) create mode 100644 .pylintrc diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 86dee1b..f50f4d2 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -8,6 +8,9 @@ FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT} 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 +RUN pip3 --disable-pip-version-check --no-cache-dir install -U pip pre-commit + + # [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 \ diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 626e731..c3fc20e 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -18,8 +18,8 @@ // Set *default* container specific settings.json values on container create. "settings": { "python.defaultInterpreterPath": "/usr/local/bin/python", - "python.linting.enabled": false, - "python.linting.pylintEnabled": false, + "python.linting.enabled": true, + "python.linting.pylintEnabled": true, "python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8", "python.formatting.blackPath": "/usr/local/py-utils/bin/black", "python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf", diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d373e7a..f4adb4c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ --- repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.4.0 + rev: v4.1.0 hooks: - id: check-added-large-files - id: check-case-conflict @@ -16,27 +16,13 @@ repos: # - id: flake8 # args: [--max-line-length=100] - repo: https://github.com/psf/black - rev: 20.8b1 + rev: 22.1.0 hooks: - id: black - language_version: python3.8 args: [-l, '110'] -#- repo: https://github.com/adrienverge/yamllint.git -# rev: v1.26.1 # or higher tag -# hooks: -# - id: yamllint -# args: [--format, parsable] - repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt rev: 0.1.0 # or specific tag hooks: - id: yamlfmt args: [--mapping, '2', --sequence, '2', --offset, '0', --width, '150', --preserve-quotes] - -# args: [--mapping, '2', --sequence, '0', --offset, '0', --width, '150'] - - -#exclude: .bumpversion.cfg - files: (^src/.*py)|(.*yaml) - -# sigil 3d9109598d23dfbb339c65e4dae064bd diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 0000000..5671bbf --- /dev/null +++ b/.pylintrc @@ -0,0 +1,6 @@ +[MASTER] +disable= + C0114, # missing-module-docstring + C0115, # missing-class-docstring + C0116, # missing-function-docstring + C0103, # pylint complains about the TypeVar names https://github.com/PyCQA/pylint/issues/3324 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 87bfd82..28fee9e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -ACT4E-exercises \ No newline at end of file +ACT4E-exercises +pre-commit \ No newline at end of file diff --git a/src/act4e_solutions/maps_representation.py b/src/act4e_solutions/maps_representation.py index 45c816e..f532658 100644 --- a/src/act4e_solutions/maps_representation.py +++ b/src/act4e_solutions/maps_representation.py @@ -1,14 +1,12 @@ from typing import Any, TypeVar import act4e_interfaces as I - A = TypeVar("A") B = TypeVar("B") class SolFiniteMapRepresentation(I.FiniteMapRepresentation): - def load(self, h: I.IOHelper, s: I.FiniteMap_desc) -> I.FiniteMap[A, B]: raise NotImplementedError() diff --git a/src/act4e_solutions/posets_bounds.py b/src/act4e_solutions/posets_bounds.py index 73adc98..eca887f 100644 --- a/src/act4e_solutions/posets_bounds.py +++ b/src/act4e_solutions/posets_bounds.py @@ -3,7 +3,8 @@ from typing import Any, List, Optional, overload, TypeVar import act4e_interfaces as I E = TypeVar("E") -X = TypeVar("X") +X = TypeVar("X") + class SolFinitePosetMeasurement(I.FinitePosetMeasurement): def height(self, fp: I.FinitePoset[Any]) -> int: @@ -35,7 +36,6 @@ class SolFinitePosetSubsetProperties(I.FinitePosetSubsetProperties): class SolFinitePosetSubsetProperties2(I.FinitePosetSubsetProperties2): - def is_lower_set(self, fp: I.FinitePoset[X], s: List[X]) -> bool: raise NotImplementedError() diff --git a/src/act4e_solutions/posets_representation.py b/src/act4e_solutions/posets_representation.py index d7b2991..c43da82 100644 --- a/src/act4e_solutions/posets_representation.py +++ b/src/act4e_solutions/posets_representation.py @@ -4,7 +4,6 @@ import act4e_interfaces as I class SolFinitePosetRepresentation(I.FinitePosetRepresentation): - def load(self, h: I.IOHelper, s: I.FinitePoset_desc) -> I.FinitePoset[Any]: raise NotImplementedError() diff --git a/src/act4e_solutions/relations_representation.py b/src/act4e_solutions/relations_representation.py index 8dbde1c..69ccdf0 100644 --- a/src/act4e_solutions/relations_representation.py +++ b/src/act4e_solutions/relations_representation.py @@ -7,7 +7,6 @@ B = TypeVar("B") class SolFiniteRelationRepresentation(I.FiniteRelationRepresentation): - def load(self, h: I.IOHelper, data: I.FiniteRelation_desc) -> I.FiniteRelation[A, B]: raise NotImplementedError() diff --git a/src/act4e_solutions/semigroups_representation.py b/src/act4e_solutions/semigroups_representation.py index 23e2ba1..4d75708 100644 --- a/src/act4e_solutions/semigroups_representation.py +++ b/src/act4e_solutions/semigroups_representation.py @@ -6,7 +6,6 @@ X = TypeVar("X") class SolFiniteSemigroupRepresentation(I.FiniteSemigroupRepresentation): - def load(self, h: I.IOHelper, s: I.FiniteSemigroup_desc) -> I.FiniteSemigroup[Any]: raise NotImplementedError() diff --git a/src/act4e_solutions/sets_properties.py b/src/act4e_solutions/sets_properties.py index 1a2ab88..cca6de9 100644 --- a/src/act4e_solutions/sets_properties.py +++ b/src/act4e_solutions/sets_properties.py @@ -1,7 +1,7 @@ from typing import Any, overload, Sequence, TypeVar import act4e_interfaces as I - + X = TypeVar("X") diff --git a/src/act4e_solutions/sets_representation.py b/src/act4e_solutions/sets_representation.py index 10d89c9..7f3e818 100644 --- a/src/act4e_solutions/sets_representation.py +++ b/src/act4e_solutions/sets_representation.py @@ -1,7 +1,7 @@ from typing import Any import act4e_interfaces as I - + class SolFiniteSetRepresentation(I.FiniteSetRepresentation): def load(self, h: I.IOHelper, data: I.FiniteSet_desc) -> I.FiniteSet[Any]: -- cgit v1.2.1 From ded6a1bfc44269add5aa376760f8a209c8cd0c39 Mon Sep 17 00:00:00 2001 From: Andrea Censi Date: Tue, 22 Feb 2022 14:14:37 +0100 Subject: some excludes --- .pylintrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.pylintrc b/.pylintrc index 5671bbf..d13ca13 100644 --- a/.pylintrc +++ b/.pylintrc @@ -3,4 +3,5 @@ disable= C0114, # missing-module-docstring C0115, # missing-class-docstring C0116, # missing-function-docstring - C0103, # pylint complains about the TypeVar names https://github.com/PyCQA/pylint/issues/3324 \ No newline at end of file + C0103, # pylint complains about the TypeVar names https://github.com/PyCQA/pylint/issues/3324 + R0903, # too few public methods \ No newline at end of file -- cgit v1.2.1 From 8071f2f72dfb157d37f3239d7b1d85f960e77885 Mon Sep 17 00:00:00 2001 From: Andrea Censi Date: Tue, 22 Feb 2022 14:19:09 +0100 Subject: settings --- .gitignore | 4 +++- .vscode/settings.json | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .vscode/settings.json diff --git a/.gitignore b/.gitignore index ad71b0c..fcfda9f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ - +__pycache__ +*.pyc +*.egg-info .DS_Store .python-version diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..a77d3ce --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "files.exclude": { + "**/__pycache__": true, + "**/*.egg-info": true + } +} \ No newline at end of file -- cgit v1.2.1