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

♻️ Major cleanup of catalog service #5904

Merged
merged 49 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
9a59915
ruffed
pcrespov May 31, 2024
0b87d64
moves exceptions
pcrespov May 31, 2024
ffb0d17
annotated dependencies
pcrespov May 31, 2024
7ccb33a
annotated routes
pcrespov May 31, 2024
9edd36f
minor
pcrespov May 31, 2024
8af13f1
cleanup core
pcrespov May 31, 2024
2ca27a4
errors
pcrespov May 31, 2024
b98e284
cleanup
pcrespov May 31, 2024
7374727
cleanup
pcrespov May 31, 2024
58572ad
timing middleware
pcrespov May 31, 2024
c55e59e
middleware
pcrespov May 31, 2024
778bcab
annotated
pcrespov May 31, 2024
de72c82
cleanup events
pcrespov May 31, 2024
9cdfbee
cleanup
pcrespov May 31, 2024
3a3a663
cleanup routes
pcrespov May 31, 2024
6590f24
loggers
pcrespov May 31, 2024
d37db77
fix routes
pcrespov May 31, 2024
1149901
OAS
pcrespov May 31, 2024
7686cdf
cleaiup
pcrespov Jun 3, 2024
a155cd0
reuse docker
pcrespov Jun 3, 2024
33aa982
cleanup catalog
pcrespov Jun 3, 2024
1a685a3
rm local env
pcrespov Jun 3, 2024
bc33aee
create and validate oas
pcrespov Jun 3, 2024
0dbdf16
cleanup tests
pcrespov Jun 3, 2024
c5090ee
cleanup pytest_simcore
pcrespov Jun 3, 2024
829d6cb
adds asgi
pcrespov Jun 3, 2024
f76b85e
missing env
pcrespov Jun 3, 2024
76bc125
fixing tests
pcrespov Jun 3, 2024
ced78f8
app_environment
pcrespov Jun 3, 2024
f8fdc6f
users fixture
pcrespov Jun 3, 2024
aa7a069
fixes test
pcrespov Jun 3, 2024
cbde3ca
adapts product
pcrespov Jun 3, 2024
eb7c897
fixes link
pcrespov Jun 3, 2024
331bc9e
fixes payments fixture
pcrespov Jun 3, 2024
fbef162
naming
pcrespov Jun 3, 2024
4ae4cf6
cleanup injection in db
pcrespov Jun 3, 2024
09d9e82
new postgres fixture
pcrespov Jun 3, 2024
502b1d5
new postgres fixture
pcrespov Jun 3, 2024
bc25e07
fixes tests
pcrespov Jun 3, 2024
fb0628c
fixes fixtures in payments
pcrespov Jun 3, 2024
dfa495e
fixes fixture
pcrespov Jun 3, 2024
6df9b4b
Merge branch 'master' into is1404/mai-service-catalog
pcrespov Jun 4, 2024
84aec43
minor
pcrespov Jun 4, 2024
0f851ea
@GitHK review: annotations
pcrespov Jun 4, 2024
0fed0e9
@sanderegg review: bad cancel decorator
pcrespov Jun 4, 2024
36cc34c
@sanderegg review: upgraded uv
pcrespov Jun 4, 2024
a728a45
@sanderegg review: fixed statement bug
pcrespov Jun 4, 2024
75cea17
@sanderegg review: started using NewType
pcrespov Jun 4, 2024
a2de9fe
rm default
pcrespov Jun 5, 2024
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 .env-devel
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ AUTOSCALING_LOGLEVEL=WARNING
AUTOSCALING_NODES_MONITORING=null
AUTOSCALING_POLL_INTERVAL=10

CATALOG_BACKGROUND_TASK_REST_TIME=60
pcrespov marked this conversation as resolved.
Show resolved Hide resolved
CATALOG_DEV_FEATURES_ENABLED=0
CATALOG_HOST=catalog
CATALOG_LOGLEVEL=WARNING
Expand Down
20 changes: 20 additions & 0 deletions scripts/common-service.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,23 @@ _run-test-ci: _check_venv_active
.PHONY: _assert_target_defined
_assert_target_defined:
$(if $(target),,$(error unset argument 'target' is required))




#
# OPENAPI SPECIFICATIONS ROUTINES
#


# specification of the used openapi-generator-cli (see also https://github.com/ITISFoundation/openapi-generator)
OPENAPI_GENERATOR_NAME := itisfoundation/openapi-generator-cli-openapi-generator-v4.2.3
OPENAPI_GENERATOR_TAG := v0
OPENAPI_GENERATOR_IMAGE := $(OPENAPI_GENERATOR_NAME):$(OPENAPI_GENERATOR_TAG)

define validate_openapi_specs
# Validating OAS '$(1)' ...
docker run --rm \
--volume "$(CURDIR):/local" \
$(OPENAPI_GENERATOR_IMAGE) validate --input-spec /local/$(strip $(1))
endef
pcrespov marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion services/api-server/tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def mocked_catalog_service_api_base(
text="simcore_service_catalog.api.routes.health@2023-07-03T12:59:12.024551+00:00",
)
respx_mock.get("/v0/meta").respond(
status.HTTP_200_OK, json=schemas["Meta"]["example"]
status.HTTP_200_OK, json=schemas["BaseMeta"]["example"]
)

# SEE https://github.com/pcrespov/sandbox-python/blob/f650aad57aced304aac9d0ad56c00723d2274ad0/respx-lib/test_disable_mock.py
Expand Down
28 changes: 0 additions & 28 deletions services/catalog/.env-devel

This file was deleted.

66 changes: 8 additions & 58 deletions services/catalog/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,69 +5,19 @@ include ../../scripts/common.Makefile
include ../../scripts/common-service.Makefile


.PHONY: requirements reqs
requirements reqs: ## (or reqs) compiles pip requirements (.in -> .txt)
@$(MAKE_C) requirements reqs





# DEVELOPMENT ########

.env:
cp .env-devel $@


.PHONY: run-devel up-extra down down-extra

up-extra: .env down-extra ## creates and starts adjacent services and migrates postgres database
# starting all adjacent services
docker compose -f docker-compose-extra.yml up --detach
sleep 1
# discovering postgres services
@export $(shell grep -v '^#' .env | xargs) && sc-pg discover
@sc-pg info
# upgrading postgres database to HEAD version
@sc-pg upgrade

down down-extra: docker-compose-extra.yml ## stops pg fixture
# cleanup discover cache
-@sc-pg clean
# stopping extra services
-@docker compose -f docker-compose-extra.yml down
# killing any process using port 8000
-@fuser --kill --verbose --namespace tcp 8000


run-devel: .env up-extra ## starts app with extra stack
# start app (within $<) in devel mode
uvicorn $(APP_PACKAGE_NAME).__main__:the_app \
--reload --reload-dir $(SRC_DIR) \
--port=8000 --host=0.0.0.0

run-prod: .env up-extra
# start app (within $<) in prod mode
$(APP_CLI_NAME)



# BUILD #####################


# specification of the used openapi-generator-cli (see also https://github.com/ITISFoundation/openapi-generator)
OPENAPI_GENERATOR_NAME := itisfoundation/openapi-generator-cli-openapi-generator-v4.2.3
OPENAPI_GENERATOR_TAG := v0
OPENAPI_GENERATOR_IMAGE := $(OPENAPI_GENERATOR_NAME):$(OPENAPI_GENERATOR_TAG)
.env-ignore:
$(APP_CLI_NAME) echo-dotenv > $@


.PHONY: openapi-specs openapi.json
openapi-specs: openapi.json
openapi.json: .env
# generating openapi specs file
openapi.json: .env-ignore
# generating openapi specs file (need to have the environment set for this)
@set -o allexport; \
source $<; \
set +o allexport; \
python3 -c "import json; from $(APP_PACKAGE_NAME).main import *; print( json.dumps(the_app.openapi(), indent=2) )" > $@
pcrespov marked this conversation as resolved.
Show resolved Hide resolved

# validates OAS file: $@
docker run --rm \
--volume "$(CURDIR):/local" \
$(OPENAPI_GENERATOR_IMAGE) validate --input-spec /local/$@
$(call validate_openapi_specs,$@)
41 changes: 0 additions & 41 deletions services/catalog/README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,3 @@
# catalog

[![image-size]](https://microbadger.com/images/itisfoundation/catalog. "More on itisfoundation/catalog:staging-latest image")
[![image-badge]](https://microbadger.com/images/itisfoundation/catalog "More on Components Catalog Service image in registry")
[![image-version]](https://microbadger.com/images/itisfoundation/catalog "More on Components Catalog Service image in registry")
[![image-commit]](https://microbadger.com/images/itisfoundation/catalog "More on Components Catalog Service image in registry")

Manages and maintains a catalog of all published components (e.g. macro-algorithms, scripts, etc)

## Development

Typical development workflow:

```cmd
make devenv
source .venv/bin/activate

cd services/api-service
make install-dev
```

Then
```cmd
make run-devel
```
will start the service in development-mode together with a postgres db initialized with test data. The API can be query using
- http://127.0.0.1:8000/api/docs: swagger-UI API doc


Finally
```cmd
make tests
make build-devel
make build
```



<!-- Add badges urls here-->
[image-size]:https://img.shields.io/microbadger/image-size/itisfoundation/catalog./staging-latest.svg?label=catalog.&style=flat
[image-badge]:https://images.microbadger.com/badges/image/itisfoundation/catalog.svg
[image-version]:https://images.microbadger.com/badges/version/itisfoundation/catalog.svg
[image-commit]:https://images.microbadger.com/badges/commit/itisfoundation/catalog.svg
<!------------------------->
79 changes: 0 additions & 79 deletions services/catalog/docker-compose-extra.yml

This file was deleted.

Loading
Loading