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

Adds dynamic-sidecar osparc service (🏗️actions required) #2271

Merged
merged 111 commits into from
Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from 78 commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
3cd301a
moved service-sidecar contents
Apr 14, 2021
7133a7b
added task to run unittests
Apr 14, 2021
6d00094
added unittests bash commands
Apr 14, 2021
279f585
added command to run unittests locally
Apr 14, 2021
8922769
added entry to build dynamic-sidecar
Apr 14, 2021
45229bc
coverage and deploy now await for dynamic-sidecar
Apr 14, 2021
076c742
Merge branch 'master' into adding-dynamic-sidecar
GitHK Apr 14, 2021
0e363f5
Merge branch 'adding-dynamic-sidecar' of github.com:GitHK/osparc-simc…
Apr 14, 2021
11d085a
renamed service-sidecar to dynamic-sidecar
Apr 14, 2021
cf64a12
renaming missing folder
Apr 14, 2021
2ee8f64
renaming missing fodler part 2
Apr 14, 2021
1288c9b
updating makefile
Apr 14, 2021
ad15255
updating tox
Apr 14, 2021
fd8e120
removing tox
Apr 14, 2021
45e43e3
added ci codestyle check before tests run
Apr 14, 2021
7160fe0
removed unsued targets
Apr 14, 2021
453342a
fixed error message
Apr 14, 2021
a293a1c
added missing test
Apr 14, 2021
77f550c
added codeoowner entry
Apr 14, 2021
b883ea5
moved mocked fucntions to the same module
Apr 14, 2021
27546d7
renamed module
Apr 14, 2021
31b60ea
updating log warning messages for mocked calls
Apr 14, 2021
4ede09d
added some help
Apr 14, 2021
e18ef58
clrifying command usage
Apr 14, 2021
4ec6147
using verbatim arguments
Apr 14, 2021
08da57c
fixed typo
Apr 14, 2021
0429949
renived tests
Apr 14, 2021
570067d
renaming ServiceSidecarSettings to DynamicSidecarSettings
Apr 14, 2021
3ace277
updated name in changelog
Apr 14, 2021
fa0641f
fixed ptsv entrypoint
Apr 14, 2021
a7ea456
fixed healt endpoint to fail when status is not healthy
Apr 14, 2021
7271897
fixed route and test
Apr 14, 2021
6db2beb
mappign docs on the same route as other services
Apr 14, 2021
98fd9da
added api prefix for interested routes
Apr 14, 2021
fec4078
codestyle
Apr 14, 2021
33425b5
container api routes refactored
Apr 14, 2021
849db29
renamed storage to shared_store
Apr 14, 2021
b41196f
Merge remote-tracking branch 'upstream/master' into adding-dynamic-si…
Apr 14, 2021
b90e7bb
refacted shared_store to use Pydantic models
Apr 14, 2021
2c172e4
missed a rename
Apr 14, 2021
4d98776
added makefile entry to generate openapi spec
Apr 14, 2021
769fe4e
adding correct mypy file
Apr 14, 2021
e19e1b0
mypy suggestions
Apr 15, 2021
793cf31
added openapi.json for the service
Apr 15, 2021
8f3b8cb
codestyle also updates openapi.json
Apr 15, 2021
bed77cb
added common scripts to enforce codestyles in development and CI
Apr 15, 2021
954ced1
imported statuses from fastapi/starlette definitions
Apr 15, 2021
bf8fbf1
updated docstring
Apr 15, 2021
e7614c2
fixed imports, now importing from starlette
Apr 15, 2021
c616040
moved mark.asyncio
Apr 15, 2021
52c1e39
moved act into bash script
Apr 16, 2021
5b34ef8
added act entry to common.Makefile
Apr 16, 2021
1567aa9
added entry for development of dunamic-sidecar
Apr 16, 2021
3afe893
Merge remote-tracking branch 'upstream/master' into adding-dynamic-si…
Apr 19, 2021
60780de
added test to check the spec has was updated
Apr 20, 2021
ce7c169
added missing fixture
Apr 20, 2021
8a988a6
updated readme
Apr 20, 2021
710f022
Merge remote-tracking branch 'upstream/master' into adding-dynamic-si…
Apr 22, 2021
5860b8f
removed unused APIs and renamed existing
Apr 22, 2021
4d6fb94
added docker-compose config validation
Apr 22, 2021
8e9b4cf
moved settings and shared state to dependencies
Apr 22, 2021
35d2490
minor improvments
Apr 22, 2021
e7030ff
updated requirements
Apr 22, 2021
8d4838b
added missing service to SERVICES_LIST
Apr 22, 2021
46fb131
Some suggestions (#3) from sanderegg
sanderegg Apr 22, 2021
25a952c
proposed refactoring on dynamic sidecar (#4)
pcrespov Apr 22, 2021
4a9cbe2
Merge remote-tracking branch 'upstream/master' into adding-dynamic-si…
Apr 23, 2021
9bf1ef9
fixed codestyle
Apr 23, 2021
0cc50a4
fixed typos
Apr 23, 2021
1442c8d
fixed compose API entrypoints and tests
Apr 23, 2021
f04a61e
refactored api structure and endpoints
Apr 23, 2021
1240824
extended utils
Apr 23, 2021
d03853e
adapted new tests
Apr 23, 2021
f810a48
updated API spec
Apr 23, 2021
e030501
Merge remote-tracking branch 'upstream/master' into adding-dynamic-si…
Apr 23, 2021
8e41560
moving routes under the same module
Apr 23, 2021
194a9e9
moved tests and updated openapi.json
Apr 23, 2021
4255341
updated script entryoint name
Apr 23, 2021
4536b93
renamed endpoint
Apr 23, 2021
7477184
refactor
Apr 23, 2021
9327327
refactor error raising and staus code for resource not found
Apr 23, 2021
e81a75f
regenerated openapi.json spec
Apr 23, 2021
959e106
codestyle :\
Apr 23, 2021
ca5c02e
merged /containers and /containers:inspect
Apr 23, 2021
ce31061
wrong default value
Apr 23, 2021
c742c6b
test clenup
Apr 23, 2021
08fc26f
updated openapi.json
Apr 23, 2021
88fbeac
clarify comment
Apr 23, 2021
8a8eb2f
removed unused API
Apr 23, 2021
ed3ace5
Merge remote-tracking branch 'upstream/master' into adding-dynamic-si…
Apr 23, 2021
b371357
removed command timeout when posting to createing services via docker…
Apr 23, 2021
0723f8a
removing unecessary timeouts
Apr 23, 2021
faf26f1
forgot to implement it
Apr 23, 2021
d2f1146
after the request is accepted the list of container names is returned
Apr 23, 2021
886727c
removed flag which is no longer used
Apr 23, 2021
cffe2ab
fixed tests
Apr 23, 2021
ac9fd17
moved ApplicationHealth and codestyle fixes
Apr 23, 2021
703b757
added test to check it can run twice the same compos spec with differ…
Apr 23, 2021
f7c25bc
fixed codestyle
Apr 23, 2021
f5b6524
Merge remote-tracking branch 'upstream/master' into adding-dynamic-si…
Apr 26, 2021
3e5246e
setting default and documentation to argument
Apr 26, 2021
30d3ac1
updated oepnapi.json
Apr 26, 2021
1f74e22
fixed test to properly work based on workspace
Apr 26, 2021
9cec746
refactoring application models structure
Apr 26, 2021
57dc0c1
rending applicaiton strucutre similar to other fastapi services
Apr 26, 2021
a7ee796
replacing with response.json()
Apr 26, 2021
b8937f9
applied codestyle
Apr 26, 2021
e5464a0
comitting new updated dependencies
Apr 26, 2021
5b44da3
refactoring error codes
Apr 26, 2021
9ad7a78
clened up exception throwing
Apr 26, 2021
b8ac2c6
restored error emssage
Apr 26, 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
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Makefile @pcrespov, @sanderegg
/scripts/template-projects/ @odeimaiz, @pcrespov
/services/api-server/ @pcrespov
/services/director*/ @sanderegg, @pcrespov
/services/dynamic-sidecar/ @GitHK
/services/catalog/ @pcrespov, @sanderegg
/services/migration/ @pcrespov
/services/sidecar/ @pcrespov, @mguidon
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/ci-testing-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,55 @@ jobs:
name: codeclimate-${{ github.job }}-coverage
path: codeclimate.${{ github.job }}_coverage.json

unit-test-dynamic-sidecar:
name: "[unit] dynamic-sidecar"
runs-on: ${{ matrix.os }}
strategy:
matrix:
python: [3.6]
os: [ubuntu-20.04]
fail-fast: false
steps:
- uses: actions/checkout@v2
- name: setup docker
run: |
sudo ./ci/github/helpers/setup_docker_compose.bash
./ci/github/helpers/setup_docker_experimental.bash
- name: setup python environment
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: show system version
run: ./ci/helpers/show_system_versions.bash
- uses: actions/cache@v2
name: getting cached data
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-dynamic-sidecar-${{ hashFiles('services/dynamic-sidecar/requirements/ci.txt') }}
restore-keys: |
${{ runner.os }}-pip-dynamic-sidecar-
${{ runner.os }}-pip-
${{ runner.os }}-
- name: install
run: ./ci/github/unit-testing/dynamic-sidecar.bash install
- name: codestyle
run: ./ci/github/unit-testing/dynamic-sidecar.bash codestyle
- name: test
run: ./ci/github/unit-testing/dynamic-sidecar.bash test
- uses: codecov/codecov-action@v1
with:
flags: unittests #optional
- name: prepare codeclimate coverage file
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-0.7.0-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter && ./cc-test-reporter --version
./cc-test-reporter format-coverage -t coverage.py -o codeclimate.${{ github.job }}_coverage.json coverage.xml
- name: upload codeclimate coverage
uses: actions/upload-artifact@v2
with:
name: codeclimate-${{ github.job }}-coverage
path: codeclimate.${{ github.job }}_coverage.json

unit-test-frontend:
name: "[unit] frontend"
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -1752,6 +1801,7 @@ jobs:
unit-test-director,
unit-test-director-v2,
unit-test-sidecar,
unit-test-dynamic-sidecar,
unit-test-service-integration,
unit-test-service-library,
unit-test-models-library,
Expand Down Expand Up @@ -1806,6 +1856,7 @@ jobs:
unit-test-director,
unit-test-director-v2,
unit-test-sidecar,
unit-test-dynamic-sidecar,
unit-test-frontend,
unit-test-python-linting,
unit-test-service-integration,
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ SERVICES_LIST := \
catalog \
director \
director-v2 \
dynamic-sidecar \
migration \
sidecar \
storage \
Expand Down
33 changes: 33 additions & 0 deletions ci/github/unit-testing/dynamic-sidecar.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -o errexit # abort on nonzero exitstatus
set -o nounset # abort on unbound variable
set -o pipefail # don't hide errors within pipes
IFS=$'\n\t'

install() {
bash ci/helpers/ensure_python_pip.bash;
pushd services/dynamic-sidecar; pip3 install -r requirements/ci.txt -r requirements/_tools.txt; popd;
pip list -v
}

codestyle(){
scripts/codestyle.bash ci simcore_service_dynamic_sidecar services/dynamic-sidecar
}

test() {
pytest --cov=simcore_service_dynamic_sidecar --durations=10 --cov-append \
--color=yes --cov-report=term-missing --cov-report=xml --cov-config=.coveragerc \
-v -m "not travis" services/dynamic-sidecar/tests/unit
}

# Check if the function exists (bash specific)
if declare -f "$1" > /dev/null
then
# call arguments verbatim
"$@"
else
# Show a helpful error
echo "'$1' is not a known function name" >&2
exit 1
fi
33 changes: 33 additions & 0 deletions scripts/act.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -o errexit
set -o nounset
set -o pipefail
IFS=$'\n\t'

# points to root soruce directory of this project, usually ../../
ROOT_PROJECT_DIR=$1
# name of the job, usually defined in the .github/workflows/ci-testing-deploy.yaml
JOB_TO_RUN=$2

DOCKER_IMAGE_NAME=dind-act-runner
ACT_RUNNER=ubuntu-20.04=catthehacker/ubuntu:act-20.04
ACT_VERSION_TAG=v0.2.20 # from https://github.com/nektos/act/releases

docker build -t $DOCKER_IMAGE_NAME - <<EOF
FROM docker:dind

RUN apk add curl bash
RUN curl -fsSL https://raw.githubusercontent.com/nektos/act/master/install.sh | bash /dev/stdin -d $ACT_VERSION_TAG

WORKDIR /project

CMD /bin/sh -c "act -v -P $ACT_RUNNER -j $JOB_TO_RUN"
EOF

echo "$(pwd)/${ROOT_PROJECT_DIR}"
docker run --rm -it \
-v /var/run/docker.sock:/var/run/docker.sock \
-v "$(pwd)"/"${ROOT_PROJECT_DIR}":/project \
-v "$(pwd)"/ci-logs:/logs \
$DOCKER_IMAGE_NAME
38 changes: 38 additions & 0 deletions scripts/codestyle.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -o errexit
set -o nounset
set -o pipefail
IFS=$'\n\t'

SRC_DIRECTORY_NAME=${2}
BASE_PATH_DIR=${3-MISSING_DIR}

# used for development (fails on pylint and mypy)
development() {
echo "enforcing codestyle to source_directory=$SRC_DIRECTORY_NAME"
echo "isort"
isort setup.py src/"$SRC_DIRECTORY_NAME" tests
echo "black"
black src/"$SRC_DIRECTORY_NAME" tests/
echo "pylint"
pylint --rcfile=../../.pylintrc src/"$SRC_DIRECTORY_NAME" tests/
echo "mypy"
mypy --ignore-missing-imports --config-file ../../mypy.ini src/"$SRC_DIRECTORY_NAME" tests/
}

# invoked by ci as test (also fails on isort and black)
ci() {
echo "checking codestyle in service=$BASE_PATH_DIR with source_directory=$SRC_DIRECTORY_NAME"
echo "isort"
isort --check setup.py "$BASE_PATH_DIR"/src/"$SRC_DIRECTORY_NAME" "$BASE_PATH_DIR"/tests
echo "black"
black --check "$BASE_PATH_DIR"/src/"$SRC_DIRECTORY_NAME" "$BASE_PATH_DIR"/tests
echo "pylint"
pylint --rcfile=.pylintrc "$BASE_PATH_DIR"/src/"$SRC_DIRECTORY_NAME" "$BASE_PATH_DIR"/tests
echo "mypy"
mypy --config-file mypy.ini --ignore-missing-imports "$BASE_PATH_DIR"/src/"$SRC_DIRECTORY_NAME" "$BASE_PATH_DIR"/tests
}

# Allows to call a function based on arguments passed to the script
"$@"
10 changes: 10 additions & 0 deletions scripts/common.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,16 @@ code-analysis: $(REPO_BASE_DIR)/.codeclimate.yml ## runs code-climate analysis
@-rm $(CURDIR)/.codeclimate.yml


.PHONY: codestyle
codestyle: ## enforces codestyle (isort & black) finally runs pylint & mypy
@$(SCRIPTS_DIR)/codestyle.bash development $(shell basename "${SRC_DIR}")

.PHONY: github-workflow-job
github-workflow-job: ## runs a github workflow job using act locally, run using "make github-workflow-job job=JOB_NAME"
# running job "${job}"
$(SCRIPTS_DIR)/act.bash ../.. ${job}


.PHONY: version-patch version-minor version-major
version-patch: ## commits version with bug fixes not affecting the cookiecuter config
$(_bumpversion)
Expand Down
16 changes: 16 additions & 0 deletions services/docker-compose-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,22 @@ services:
org.label-schema.vcs-url: "${VCS_URL}"
org.label-schema.vcs-ref: "${VCS_REF}"

dynamic-sidecar:
image: local/dynamic-sidecar:${BUILD_TARGET:?build_target_required}
build:
context: ../
dockerfile: services/dynamic-sidecar/Dockerfile
cache_from:
- local/dynamic-sidecar:${BUILD_TARGET:?build_target_required}
- ${DOCKER_REGISTRY:-itisfoundation}/dynamic-sidecar:cache
- ${DOCKER_REGISTRY:-itisfoundation}/dynamic-sidecar:${DOCKER_IMAGE_TAG:-latest}
target: ${BUILD_TARGET:?build_target_required}
labels:
org.label-schema.schema-version: "1.0"
org.label-schema.build-date: "${BUILD_DATE}"
org.label-schema.vcs-url: "${VCS_URL}"
org.label-schema.vcs-ref: "${VCS_REF}"

storage:
image: local/storage:${BUILD_TARGET:?build_target_required}
build:
Expand Down
12 changes: 12 additions & 0 deletions services/dynamic-sidecar/.env-devel
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Environment used to configure storage services
#
# - To expose in cmd: export $(grep -v '^#' .env-devel | xargs -0)
#

# environs in Dockerfile ----------------
SC_BOOT_MODE=local-development


# service specific required vars
DYNAMIC_SIDECAR_compose_namespace=dev-namespace
DYNAMIC_SIDECAR_docker_compose_down_timeout=15
13 changes: 13 additions & 0 deletions services/dynamic-sidecar/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog
All notable changes to this service will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

GitHK marked this conversation as resolved.
Show resolved Hide resolved
## [0.0.1] - 2021-04-14
### Added
- First working version of the service
- FastAPI based service
- all spawned services and networks are removed when receiving `SIGTERM`
Loading