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

services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/core/dependencies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
def get_app_state(request: Request) -> State:
10-
return request.app.state # type: ignore
10+
return request.app.state
1111

1212

1313
def get_application_health(

services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/core/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ async def write_to_tmp_file(file_contents: str) -> AsyncGenerator[Path, None]:
5353
try:
5454
yield file_path
5555
finally:
56-
await aiofiles.os.remove(file_path)
56+
await aiofiles.os.remove(file_path) # type: ignore
5757

5858

5959
@asynccontextmanager

services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5276,6 +5276,8 @@ paths:
52765276
type: integer
52775277
parent_id:
52785278
type: string
5279+
entity_tag:
5280+
type: string
52795281
example:
52805282
file_uuid: simcore-testing/105/1000/3
52815283
location_id: '0'
@@ -5296,6 +5298,7 @@ paths:
52965298
last_modified: '2019-06-19T12:29:03.78852Z'
52975299
file_size: 73
52985300
parent_id: 'N:collection:e263da07-2d89-45a6-8b0f-61061b913873'
5301+
entity_tag: a87ff679a2f3e71d9181a67b7542122c
52995302
default:
53005303
description: Default http error response body
53015304
content:
@@ -5528,6 +5531,8 @@ paths:
55285531
type: integer
55295532
parent_id:
55305533
type: string
5534+
entity_tag:
5535+
type: string
55315536
example:
55325537
file_uuid: simcore-testing/105/1000/3
55335538
location_id: '0'
@@ -5548,6 +5553,7 @@ paths:
55485553
last_modified: '2019-06-19T12:29:03.78852Z'
55495554
file_size: 73
55505555
parent_id: 'N:collection:e263da07-2d89-45a6-8b0f-61061b913873'
5556+
entity_tag: a87ff679a2f3e71d9181a67b7542122c
55515557
patch:
55525558
summary: Update File Metadata
55535559
tags:
@@ -5608,6 +5614,8 @@ paths:
56085614
type: integer
56095615
parent_id:
56105616
type: string
5617+
entity_tag:
5618+
type: string
56115619
example:
56125620
file_uuid: simcore-testing/105/1000/3
56135621
location_id: '0'
@@ -5628,6 +5636,7 @@ paths:
56285636
last_modified: '2019-06-19T12:29:03.78852Z'
56295637
file_size: 73
56305638
parent_id: 'N:collection:e263da07-2d89-45a6-8b0f-61061b913873'
5639+
entity_tag: a87ff679a2f3e71d9181a67b7542122c
56315640
responses:
56325641
'200':
56335642
description: Returns file metadata
@@ -5674,6 +5683,8 @@ paths:
56745683
type: integer
56755684
parent_id:
56765685
type: string
5686+
entity_tag:
5687+
type: string
56775688
example:
56785689
file_uuid: simcore-testing/105/1000/3
56795690
location_id: '0'
@@ -5694,6 +5705,7 @@ paths:
56945705
last_modified: '2019-06-19T12:29:03.78852Z'
56955706
file_size: 73
56965707
parent_id: 'N:collection:e263da07-2d89-45a6-8b0f-61061b913873'
5708+
entity_tag: a87ff679a2f3e71d9181a67b7542122c
56975709
'/storage/locations/{location_id}/datasets/{dataset_id}/metadata':
56985710
get:
56995711
summary: Get Files Metadata
@@ -5759,6 +5771,8 @@ paths:
57595771
type: integer
57605772
parent_id:
57615773
type: string
5774+
entity_tag:
5775+
type: string
57625776
example:
57635777
file_uuid: simcore-testing/105/1000/3
57645778
location_id: '0'
@@ -5779,6 +5793,7 @@ paths:
57795793
last_modified: '2019-06-19T12:29:03.78852Z'
57805794
file_size: 73
57815795
parent_id: 'N:collection:e263da07-2d89-45a6-8b0f-61061b913873'
5796+
entity_tag: a87ff679a2f3e71d9181a67b7542122c
57825797
default:
57835798
description: Default http error response body
57845799
content:

0 commit comments

Comments
 (0)