Skip to content

Commit c194216

Browse files
authored
♻️ Maintenance: diverse fixes (codestyle, openapi, dockerignore) (#2593)
* fix missing openapi entries * ignore mypy cache files in dockerignore * fix call of codestyle recipe in packages * director-v2 to restart when packages are updated
1 parent c215bf9 commit c194216

File tree

13 files changed

+73
-42
lines changed

13 files changed

+73
-42
lines changed

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ dask*-space/
2828

2929
# produced when mounting volumes on docker and pip installing
3030
.local/
31+
32+
# mypy cache
33+
**/.mypy_cache/

api/specs/webserver/components/schemas/files.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ FileMetaData:
5151
type: integer
5252
parent_id:
5353
type: string
54+
entity_tag:
55+
type: string
5456
example:
5557
file_uuid: "simcore-testing/105/1000/3"
5658
location_id: "0"
@@ -71,6 +73,7 @@ FileMetaData:
7173
last_modified: "2019-06-19T12:29:03.78852Z"
7274
file_size: 73
7375
parent_id: "N:collection:e263da07-2d89-45a6-8b0f-61061b913873"
76+
entity_tag: a87ff679a2f3e71d9181a67b7542122c
7477

7578
FileMetaDataArray:
7679
type: array

ci/github/unit-testing/dynamic-sidecar.bash

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,32 @@
11
#!/bin/bash
22
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
3-
set -o errexit # abort on nonzero exitstatus
4-
set -o nounset # abort on unbound variable
5-
set -o pipefail # don't hide errors within pipes
3+
set -o errexit # abort on nonzero exitstatus
4+
set -o nounset # abort on unbound variable
5+
set -o pipefail # don't hide errors within pipes
66
IFS=$'\n\t'
77

88
install() {
9-
bash ci/helpers/ensure_python_pip.bash;
10-
pushd services/dynamic-sidecar; pip3 install -r requirements/ci.txt -r requirements/_tools.txt; popd;
11-
pip list -v
9+
bash ci/helpers/ensure_python_pip.bash
10+
pushd services/dynamic-sidecar
11+
pip3 install -r requirements/ci.txt -r requirements/_tools.txt
12+
popd
13+
pip list -v
1214
}
1315

14-
codestyle(){
15-
scripts/codestyle.bash ci simcore_service_dynamic_sidecar services/dynamic-sidecar
16+
codestyle() {
17+
pushd services/dynamic-sidecar
18+
make codestyle-ci
19+
popd
1620
}
1721

1822
test() {
19-
pytest --cov=simcore_service_dynamic_sidecar --durations=10 --cov-append \
20-
--color=yes --cov-report=term-missing --cov-report=xml --cov-config=.coveragerc \
21-
-v -m "not travis" services/dynamic-sidecar/tests/unit
23+
pytest --cov=simcore_service_dynamic_sidecar --durations=10 --cov-append \
24+
--color=yes --cov-report=term-missing --cov-report=xml --cov-config=.coveragerc \
25+
-v -m "not travis" services/dynamic-sidecar/tests/unit
2226
}
2327

2428
# Check if the function exists (bash specific)
25-
if declare -f "$1" > /dev/null
26-
then
29+
if declare -f "$1" >/dev/null; then
2730
# call arguments verbatim
2831
"$@"
2932
else

packages/models-library/requirements/ci.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
--requirement _test.txt
1212

1313
# installs this repo's packages
14+
../postgres-database/[migration]
1415
../pytest-simcore/
15-
../postgres-database/
1616

1717
# current module
1818
.

packages/models-library/requirements/dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
--requirement _tools.txt
1313

1414
# installs this repo's packages
15-
--editable ../pytest-simcore/
1615
--editable ../postgres-database/[migration]
16+
--editable ../pytest-simcore/
1717

1818
# current module
1919
--editable .

scripts/codestyle.bash

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@ set -o pipefail
66
IFS=$'\n\t'
77

88
SRC_DIRECTORY_NAME=${2}
9-
BASE_PATH_DIR=${3-MISSING_DIR}
109

1110

1211
# global config for entire repo
1312
PYLINT_CONFIG="$(git rev-parse --show-toplevel)/.pylintrc"
14-
MYPY_CONFIG="$(git rev-parse --show-toplevel)/mypy.ini"
1513

1614

1715
# used for development (fails on pylint and mypy)
@@ -24,23 +22,20 @@ development() {
2422
echo "pylint"
2523
pylint --rcfile="$PYLINT_CONFIG" src/"$SRC_DIRECTORY_NAME" tests/
2624
echo "mypy"
27-
mypy --ignore-missing-imports --config-file "$MYPY_CONFIG" src/"$SRC_DIRECTORY_NAME" tests/
25+
make mypy
2826
}
2927

3028
# invoked by ci as test (also fails on isort and black)
3129
ci() {
32-
echo "checking codestyle in service=$BASE_PATH_DIR with source_directory=$SRC_DIRECTORY_NAME"
30+
echo "enforcing codestyle to source_directory=$SRC_DIRECTORY_NAME"
3331
echo "isort"
34-
isort --check setup.py "$BASE_PATH_DIR"/src/"$SRC_DIRECTORY_NAME" "$BASE_PATH_DIR"/tests
32+
isort --check setup.py src/"$SRC_DIRECTORY_NAME" tests
3533
echo "black"
36-
black --check "$BASE_PATH_DIR"/src/"$SRC_DIRECTORY_NAME" "$BASE_PATH_DIR"/tests
34+
black --check src/"$SRC_DIRECTORY_NAME" tests
3735
echo "pylint ..."
38-
pylint --rcfile="$PYLINT_CONFIG" "$BASE_PATH_DIR"/src/"$SRC_DIRECTORY_NAME" "$BASE_PATH_DIR"/tests
36+
pylint --rcfile="$PYLINT_CONFIG" src/"$SRC_DIRECTORY_NAME" tests/
3937
echo "mypy ..."
40-
# installing all missing stub packages (e.g. types-PyYAML, types-aiofiles, etc)
41-
python3 -m pip install types-aiofiles types-PyYAML types-ujson
42-
# runs mypy
43-
mypy --config-file "$MYPY_CONFIG" --ignore-missing-imports "$BASE_PATH_DIR"/src/"$SRC_DIRECTORY_NAME" "$BASE_PATH_DIR"/tests
38+
make --silent mypy
4439
}
4540

4641
# Allows to call a function based on arguments passed to the script

scripts/common-package.Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
# NOTE $(CURDIR) in this file refers to the directory where this file is included
1515

1616
# Variable based on conventions (override if they do not apply)
17+
PACKAGE_NAME = $(notdir $(CURDIR))
18+
PY_PACKAGE_NAME = $(subst -,_,$(PACKAGE_NAME))
1719
PACKAGE_VERSION := $(shell cat VERSION)
20+
SRC_DIR = $(abspath $(CURDIR)/src/$(PY_PACKAGE_NAME))
1821

1922
export PACKAGE_VERSION
2023

scripts/common.Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ code-analysis: $(REPO_BASE_DIR)/.codeclimate.yml ## runs code-climate analysis
133133

134134

135135
.PHONY: codestyle
136-
codestyle: ## enforces codestyle (isort & black) finally runs pylint & mypy
137-
@$(SCRIPTS_DIR)/codestyle.bash development $(shell basename "${SRC_DIR}")
136+
codestyle codestyle-ci: ## enforces codestyle (isort & black) finally runs pylint & mypy
137+
@$(SCRIPTS_DIR)/codestyle.bash $(if $(findstring -ci,$@),ci,development) $(shell basename "${SRC_DIR}")
138138

139139
.PHONY: github-workflow-job
140140
github-workflow-job: ## runs a github workflow job using act locally, run using "make github-workflow-job job=JOB_NAME"

scripts/mypy.bash

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,35 @@ set -o pipefail
66
IFS=$'\n\t'
77

88

9-
image_name="$(basename $0):latest"
9+
image_name="$(basename "$0"):latest"
1010

1111

12-
docker build --tag "$image_name" -<<EOF
12+
docker buildx build --tag "$image_name" &>/dev/null -<<EOF
1313
FROM python:3.8.10-slim-buster
14-
RUN pip install --upgrade pip && pip install mypy pydantic[email]
14+
RUN pip install --upgrade pip \
15+
&& pip install mypy \
16+
pydantic[email] \
17+
types-aiofiles \
18+
types-PyYAML \
19+
types-ujson \
20+
types-setuptools
1521
ENTRYPOINT ["mypy"]
1622
EOF
1723

1824

19-
target_path=$(realpath ${1:-Please give target path as argument})
25+
target_path=$(realpath "${1:-Please give target path as argument}")
2026
cd "$(dirname "$0")"
21-
default_mypy_config="$(dirname ${PWD})/mypy.ini"
22-
mypy_config=$(realpath ${2:-${default_mypy_config}})
27+
default_mypy_config="$(git rev-parse --show-toplevel)/mypy.ini"
28+
mypy_config=$(realpath "${2:-${default_mypy_config}}")
2329

24-
echo mypying ${target_path} using config in ${mypy_config}...
25-
26-
echo $default_mypy_config
30+
echo mypying "${target_path}" using config in "${mypy_config}"...
31+
echo using "$(docker run --rm "$image_name" --version)"
2732
docker run --rm \
28-
-v ${mypy_config}:/config/mypy.ini \
29-
-v ${target_path}:/src \
33+
--volume /etc/passwd:/etc/passwd:ro \
34+
--volume /etc/group:/etc/group:ro \
35+
--user $(id -u):$(id -g) \
36+
--volume "${mypy_config}":/config/mypy.ini \
37+
--volume "${target_path}":/src \
3038
--workdir=/src \
3139
"$image_name" \
3240
--config-file /config/mypy.ini \

services/director-v2/docker/boot.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ if [ "${SC_BOOT_MODE}" = "debug-ptvsd" ]; then
3939
exec uvicorn simcore_service_director_v2.main:the_app \
4040
--reload \
4141
--host 0.0.0.0 \
42-
--reload-dir services/director-v2/src/simcore_service_director_v2
42+
--reload-dir services/director-v2/src/simcore_service_director_v2 \
43+
--reload-dir packages
4344
else
4445
exec uvicorn simcore_service_director_v2.main:the_app \
4546
--host 0.0.0.0

0 commit comments

Comments
 (0)