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

📝 services.md: autodocs openapi specs and images for each service #6779

Merged
merged 15 commits into from
Nov 21, 2024
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -595,12 +595,17 @@ settings-schema.json: ## [container] dumps json-schema settings of all services


.PHONY: auto-doc
auto-doc: .stack-simcore-version.yml ## updates diagrams for README.md
auto-doc: .stack-simcore-version.yml ## Auto generates diagrams for README.md
# Parsing docker compose config $< and creating graph
@./scripts/docker-compose-viz.bash $<
# Updating docs/img
@mv --verbose $<.png docs/img/

.PHONY: services.md
services.md: ## Auto generates service.md
# Making $@
scripts/echo_services_markdown.py > $@


.PHONY: postgres-upgrade
postgres-upgrade: ## initalize or upgrade postgres db to latest state
Expand Down
134 changes: 134 additions & 0 deletions scripts/echo_services_markdown.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
#!/bin/env python
""" Usage
cd osparc-simcore
./scripts/echo_services_markdown.py >services.md
"""

import itertools
import sys
from collections.abc import Iterable
from datetime import datetime
from operator import attrgetter
from pathlib import Path
from typing import Final, NamedTuple

CURRENT_FILE = Path(sys.argv[0] if __name__ == "__main__" else __file__).resolve()
CURRENT_DIR = CURRENT_FILE.parent

_URL_PREFIX: Final[
str
] = "https://raw.githubusercontent.com/ITISFoundation/osparc-simcore/refs/heads/master"

_REDOC_URL_PREFIX: Final[str] = f"https://redocly.github.io/redoc/?url={_URL_PREFIX}"
_SWAGGER_URL_PREFIX: Final[str] = f"https://petstore.swagger.io/?url={_URL_PREFIX}"


class CaptureTuple(NamedTuple):
service_name: str
file_path: Path


_service_names_aliases: dict[str, str] = {
"web": "webserver",
}


def generate_markdown_table(
pcrespov marked this conversation as resolved.
Show resolved Hide resolved
*captured_files: Iterable[CaptureTuple],
) -> str:
title = ("Name", "Files", " ")
num_cols = len(title)
lines = ["-" * 10] * num_cols

def _to_row_data(values: Iterable) -> list[str]:
row = list(map(str, values))
assert len(row) == num_cols, f"len({row=}) != {num_cols=}"
return row

rows = [
_to_row_data(title),
_to_row_data(lines),
]

found = itertools.groupby(
sorted(itertools.chain(*captured_files), key=attrgetter("service_name")),
key=attrgetter("service_name"),
)

for name, service_files in found:
rows.append(
_to_row_data(
(
f"**{name.upper()}**",
"",
"",
)
)
)
for _, file_path in service_files:
linked_path = f"[{file_path}](./{file_path})"

# SEE https://shields.io/badges
badges = []

if file_path.stem.lower() == "dockerfile":
repo = _service_names_aliases.get(f"{name}") or name
badges = [
f"[![Docker Image Size](https://img.shields.io/docker/image-size/itisfoundation/{repo})](https://hub.docker.com/r/itisfoundation/{repo}/tags)"
]

elif file_path.stem.lower() == "openapi":
badges = [
f"[![ReDoc](https://img.shields.io/badge/OpenAPI-ReDoc-85ea2d?logo=openapiinitiative)]({_REDOC_URL_PREFIX}/{file_path}) "
f"[![Swagger UI](https://img.shields.io/badge/OpenAPI-Swagger_UI-85ea2d?logo=swagger)]({_SWAGGER_URL_PREFIX}/{file_path})",
]

rows.append(
_to_row_data(
(
"",
linked_path,
" ".join(badges),
)
)
)
rows.append(_to_row_data(["" * 10] * num_cols))

# converts to markdown table
return "\n".join(f"| {'|'.join(r)} |" for r in rows)


if __name__ == "__main__":

repo_base_path = CURRENT_DIR.parent.resolve()
services_path = repo_base_path / "services"

def _to_tuple(file: Path):
return CaptureTuple(
f"{file.relative_to(services_path).parents[-2]}",
file.relative_to(repo_base_path),
)

dockerfiles_found = (_to_tuple(file) for file in services_path.rglob("Dockerfile"))

openapi_files_found = (
_to_tuple(file)
for file in services_path.rglob("openapi.*")
if file.suffix in {".json", ".yaml", ".yml"}
)

markdown_table = generate_markdown_table(
openapi_files_found,
dockerfiles_found,
)
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")

print("# services")
print(">")
print(f"> Auto generated on `{now}` using ")
print("```cmd")
print("cd osparc-simcore")
print(f"python ./{CURRENT_FILE.relative_to(repo_base_path)}")
print("```")
print(markdown_table)
62 changes: 62 additions & 0 deletions services.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# services
>
> Auto generated on `2024-11-21 10:29:41` using
```cmd
cd osparc-simcore
python ./scripts/echo_services_markdown.py
```
| Name|Files| |
| ----------|----------|---------- |
| **AGENT**|| |
| |[services/agent/Dockerfile](./services/agent/Dockerfile)|[![Docker Image Size](https://img.shields.io/docker/image-size/itisfoundation/agent)](https://hub.docker.com/r/itisfoundation/agent/tags) |
| **API-SERVER**|| |
| |[services/api-server/openapi.json](./services/api-server/openapi.json)|[![ReDoc](https://img.shields.io/badge/OpenAPI-ReDoc-85ea2d?logo=openapiinitiative)](https://redocly.github.io/redoc/?url=https://raw.githubusercontent.com/ITISFoundation/osparc-simcore/refs/heads/master/services/api-server/openapi.json) [![Swagger UI](https://img.shields.io/badge/OpenAPI-Swagger_UI-85ea2d?logo=swagger)](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/ITISFoundation/osparc-simcore/refs/heads/master/services/api-server/openapi.json) |
| |[services/api-server/Dockerfile](./services/api-server/Dockerfile)|[![Docker Image Size](https://img.shields.io/docker/image-size/itisfoundation/api-server)](https://hub.docker.com/r/itisfoundation/api-server/tags) |
| **AUTOSCALING**|| |
| |[services/autoscaling/Dockerfile](./services/autoscaling/Dockerfile)|[![Docker Image Size](https://img.shields.io/docker/image-size/itisfoundation/autoscaling)](https://hub.docker.com/r/itisfoundation/autoscaling/tags) |
| **CATALOG**|| |
| |[services/catalog/openapi.json](./services/catalog/openapi.json)|[![ReDoc](https://img.shields.io/badge/OpenAPI-ReDoc-85ea2d?logo=openapiinitiative)](https://redocly.github.io/redoc/?url=https://raw.githubusercontent.com/ITISFoundation/osparc-simcore/refs/heads/master/services/catalog/openapi.json) [![Swagger UI](https://img.shields.io/badge/OpenAPI-Swagger_UI-85ea2d?logo=swagger)](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/ITISFoundation/osparc-simcore/refs/heads/master/services/catalog/openapi.json) |
| |[services/catalog/Dockerfile](./services/catalog/Dockerfile)|[![Docker Image Size](https://img.shields.io/docker/image-size/itisfoundation/catalog)](https://hub.docker.com/r/itisfoundation/catalog/tags) |
| **CLUSTERS-KEEPER**|| |
| |[services/clusters-keeper/Dockerfile](./services/clusters-keeper/Dockerfile)|[![Docker Image Size](https://img.shields.io/docker/image-size/itisfoundation/clusters-keeper)](https://hub.docker.com/r/itisfoundation/clusters-keeper/tags) |
| **DASK-SIDECAR**|| |
| |[services/dask-sidecar/Dockerfile](./services/dask-sidecar/Dockerfile)|[![Docker Image Size](https://img.shields.io/docker/image-size/itisfoundation/dask-sidecar)](https://hub.docker.com/r/itisfoundation/dask-sidecar/tags) |
| **DATCORE-ADAPTER**|| |
| |[services/datcore-adapter/Dockerfile](./services/datcore-adapter/Dockerfile)|[![Docker Image Size](https://img.shields.io/docker/image-size/itisfoundation/datcore-adapter)](https://hub.docker.com/r/itisfoundation/datcore-adapter/tags) |
| **DIRECTOR**|| |
| |[services/director/src/simcore_service_director/api/v0/openapi.yaml](./services/director/src/simcore_service_director/api/v0/openapi.yaml)|[![ReDoc](https://img.shields.io/badge/OpenAPI-ReDoc-85ea2d?logo=openapiinitiative)](https://redocly.github.io/redoc/?url=https://raw.githubusercontent.com/ITISFoundation/osparc-simcore/refs/heads/master/services/director/src/simcore_service_director/api/v0/openapi.yaml) [![Swagger UI](https://img.shields.io/badge/OpenAPI-Swagger_UI-85ea2d?logo=swagger)](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/ITISFoundation/osparc-simcore/refs/heads/master/services/director/src/simcore_service_director/api/v0/openapi.yaml) |
| |[services/director/Dockerfile](./services/director/Dockerfile)|[![Docker Image Size](https://img.shields.io/docker/image-size/itisfoundation/director)](https://hub.docker.com/r/itisfoundation/director/tags) |
| **DIRECTOR-V2**|| |
| |[services/director-v2/openapi.json](./services/director-v2/openapi.json)|[![ReDoc](https://img.shields.io/badge/OpenAPI-ReDoc-85ea2d?logo=openapiinitiative)](https://redocly.github.io/redoc/?url=https://raw.githubusercontent.com/ITISFoundation/osparc-simcore/refs/heads/master/services/director-v2/openapi.json) [![Swagger UI](https://img.shields.io/badge/OpenAPI-Swagger_UI-85ea2d?logo=swagger)](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/ITISFoundation/osparc-simcore/refs/heads/master/services/director-v2/openapi.json) |
| |[services/director-v2/Dockerfile](./services/director-v2/Dockerfile)|[![Docker Image Size](https://img.shields.io/docker/image-size/itisfoundation/director-v2)](https://hub.docker.com/r/itisfoundation/director-v2/tags) |
| **DYNAMIC-SCHEDULER**|| |
| |[services/dynamic-scheduler/openapi.json](./services/dynamic-scheduler/openapi.json)|[![ReDoc](https://img.shields.io/badge/OpenAPI-ReDoc-85ea2d?logo=openapiinitiative)](https://redocly.github.io/redoc/?url=https://raw.githubusercontent.com/ITISFoundation/osparc-simcore/refs/heads/master/services/dynamic-scheduler/openapi.json) [![Swagger UI](https://img.shields.io/badge/OpenAPI-Swagger_UI-85ea2d?logo=swagger)](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/ITISFoundation/osparc-simcore/refs/heads/master/services/dynamic-scheduler/openapi.json) |
| |[services/dynamic-scheduler/Dockerfile](./services/dynamic-scheduler/Dockerfile)|[![Docker Image Size](https://img.shields.io/docker/image-size/itisfoundation/dynamic-scheduler)](https://hub.docker.com/r/itisfoundation/dynamic-scheduler/tags) |
| **DYNAMIC-SIDECAR**|| |
| |[services/dynamic-sidecar/openapi.json](./services/dynamic-sidecar/openapi.json)|[![ReDoc](https://img.shields.io/badge/OpenAPI-ReDoc-85ea2d?logo=openapiinitiative)](https://redocly.github.io/redoc/?url=https://raw.githubusercontent.com/ITISFoundation/osparc-simcore/refs/heads/master/services/dynamic-sidecar/openapi.json) [![Swagger UI](https://img.shields.io/badge/OpenAPI-Swagger_UI-85ea2d?logo=swagger)](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/ITISFoundation/osparc-simcore/refs/heads/master/services/dynamic-sidecar/openapi.json) |
| |[services/dynamic-sidecar/Dockerfile](./services/dynamic-sidecar/Dockerfile)|[![Docker Image Size](https://img.shields.io/docker/image-size/itisfoundation/dynamic-sidecar)](https://hub.docker.com/r/itisfoundation/dynamic-sidecar/tags) |
| **EFS-GUARDIAN**|| |
| |[services/efs-guardian/Dockerfile](./services/efs-guardian/Dockerfile)|[![Docker Image Size](https://img.shields.io/docker/image-size/itisfoundation/efs-guardian)](https://hub.docker.com/r/itisfoundation/efs-guardian/tags) |
| **INVITATIONS**|| |
| |[services/invitations/openapi.json](./services/invitations/openapi.json)|[![ReDoc](https://img.shields.io/badge/OpenAPI-ReDoc-85ea2d?logo=openapiinitiative)](https://redocly.github.io/redoc/?url=https://raw.githubusercontent.com/ITISFoundation/osparc-simcore/refs/heads/master/services/invitations/openapi.json) [![Swagger UI](https://img.shields.io/badge/OpenAPI-Swagger_UI-85ea2d?logo=swagger)](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/ITISFoundation/osparc-simcore/refs/heads/master/services/invitations/openapi.json) |
| |[services/invitations/Dockerfile](./services/invitations/Dockerfile)|[![Docker Image Size](https://img.shields.io/docker/image-size/itisfoundation/invitations)](https://hub.docker.com/r/itisfoundation/invitations/tags) |
| **MIGRATION**|| |
| |[services/migration/Dockerfile](./services/migration/Dockerfile)|[![Docker Image Size](https://img.shields.io/docker/image-size/itisfoundation/migration)](https://hub.docker.com/r/itisfoundation/migration/tags) |
| **OSPARC-GATEWAY-SERVER**|| |
| |[services/osparc-gateway-server/Dockerfile](./services/osparc-gateway-server/Dockerfile)|[![Docker Image Size](https://img.shields.io/docker/image-size/itisfoundation/osparc-gateway-server)](https://hub.docker.com/r/itisfoundation/osparc-gateway-server/tags) |
| **PAYMENTS**|| |
| |[services/payments/openapi.json](./services/payments/openapi.json)|[![ReDoc](https://img.shields.io/badge/OpenAPI-ReDoc-85ea2d?logo=openapiinitiative)](https://redocly.github.io/redoc/?url=https://raw.githubusercontent.com/ITISFoundation/osparc-simcore/refs/heads/master/services/payments/openapi.json) [![Swagger UI](https://img.shields.io/badge/OpenAPI-Swagger_UI-85ea2d?logo=swagger)](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/ITISFoundation/osparc-simcore/refs/heads/master/services/payments/openapi.json) |
| |[services/payments/gateway/openapi.json](./services/payments/gateway/openapi.json)|[![ReDoc](https://img.shields.io/badge/OpenAPI-ReDoc-85ea2d?logo=openapiinitiative)](https://redocly.github.io/redoc/?url=https://raw.githubusercontent.com/ITISFoundation/osparc-simcore/refs/heads/master/services/payments/gateway/openapi.json) [![Swagger UI](https://img.shields.io/badge/OpenAPI-Swagger_UI-85ea2d?logo=swagger)](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/ITISFoundation/osparc-simcore/refs/heads/master/services/payments/gateway/openapi.json) |
| |[services/payments/Dockerfile](./services/payments/Dockerfile)|[![Docker Image Size](https://img.shields.io/docker/image-size/itisfoundation/payments)](https://hub.docker.com/r/itisfoundation/payments/tags) |
| **RESOURCE-USAGE-TRACKER**|| |
| |[services/resource-usage-tracker/openapi.json](./services/resource-usage-tracker/openapi.json)|[![ReDoc](https://img.shields.io/badge/OpenAPI-ReDoc-85ea2d?logo=openapiinitiative)](https://redocly.github.io/redoc/?url=https://raw.githubusercontent.com/ITISFoundation/osparc-simcore/refs/heads/master/services/resource-usage-tracker/openapi.json) [![Swagger UI](https://img.shields.io/badge/OpenAPI-Swagger_UI-85ea2d?logo=swagger)](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/ITISFoundation/osparc-simcore/refs/heads/master/services/resource-usage-tracker/openapi.json) |
| |[services/resource-usage-tracker/Dockerfile](./services/resource-usage-tracker/Dockerfile)|[![Docker Image Size](https://img.shields.io/docker/image-size/itisfoundation/resource-usage-tracker)](https://hub.docker.com/r/itisfoundation/resource-usage-tracker/tags) |
| **STATIC-WEBSERVER**|| |
| |[services/static-webserver/client/tools/qooxdoo-kit/builder/Dockerfile](./services/static-webserver/client/tools/qooxdoo-kit/builder/Dockerfile)|[![Docker Image Size](https://img.shields.io/docker/image-size/itisfoundation/static-webserver)](https://hub.docker.com/r/itisfoundation/static-webserver/tags) |
| **STORAGE**|| |
| |[services/storage/src/simcore_service_storage/api/v0/openapi.yaml](./services/storage/src/simcore_service_storage/api/v0/openapi.yaml)|[![ReDoc](https://img.shields.io/badge/OpenAPI-ReDoc-85ea2d?logo=openapiinitiative)](https://redocly.github.io/redoc/?url=https://raw.githubusercontent.com/ITISFoundation/osparc-simcore/refs/heads/master/services/storage/src/simcore_service_storage/api/v0/openapi.yaml) [![Swagger UI](https://img.shields.io/badge/OpenAPI-Swagger_UI-85ea2d?logo=swagger)](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/ITISFoundation/osparc-simcore/refs/heads/master/services/storage/src/simcore_service_storage/api/v0/openapi.yaml) |
| |[services/storage/Dockerfile](./services/storage/Dockerfile)|[![Docker Image Size](https://img.shields.io/docker/image-size/itisfoundation/storage)](https://hub.docker.com/r/itisfoundation/storage/tags) |
| **WEB**|| |
| |[services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml](./services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml)|[![ReDoc](https://img.shields.io/badge/OpenAPI-ReDoc-85ea2d?logo=openapiinitiative)](https://redocly.github.io/redoc/?url=https://raw.githubusercontent.com/ITISFoundation/osparc-simcore/refs/heads/master/services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml) [![Swagger UI](https://img.shields.io/badge/OpenAPI-Swagger_UI-85ea2d?logo=swagger)](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/ITISFoundation/osparc-simcore/refs/heads/master/services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml) |
| |[services/web/Dockerfile](./services/web/Dockerfile)|[![Docker Image Size](https://img.shields.io/docker/image-size/itisfoundation/webserver)](https://hub.docker.com/r/itisfoundation/webserver/tags) |
| || |
14 changes: 0 additions & 14 deletions services/agent/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
# agent

[![image-size]](https://microbadger.com/images/itisfoundation/agent. "More on itisfoundation/agent.:staging-latest image")

[![image-badge]](https://microbadger.com/images/itisfoundation/agent "More on agent image in registry")
[![image-version]](https://microbadger.com/images/itisfoundation/agent "More on agent image in registry")
[![image-commit]](https://microbadger.com/images/itisfoundation/agent "More on agent image in registry")

Service for executing commands on docker nodes

<!-- Add badges urls here-->
[image-size]:https://img.shields.io/microbadger/image-size/itisfoundation/agent./staging-latest.svg?label=agent.&style=flat
[image-badge]:https://images.microbadger.com/badges/image/itisfoundation/agent.svg
[image-version]https://images.microbadger.com/badges/version/itisfoundation/agent.svg
[image-commit]:https://images.microbadger.com/badges/commit/itisfoundation/agent.svg
<!------------------------->

To develop this project, just

Expand Down
15 changes: 0 additions & 15 deletions services/datcore-adapter/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
# datcore-adapter

[![image-size]](https://microbadger.com/images/itisfoundation/datcore-adapter. "More on itisfoundation/datcore-adapter.:staging-latest image")

[![image-badge]](https://microbadger.com/images/itisfoundation/datcore-adapter "More on datcore-adapter image in registry")
[![image-version]](https://microbadger.com/images/itisfoundation/datcore-adapter "More on datcore-adapter image in registry")
[![image-commit]](https://microbadger.com/images/itisfoundation/datcore-adapter "More on datcore-adapter image in registry")

Interfaces with datcore storage

<!-- Add badges urls here-->
[image-size]:https://img.shields.io/microbadger/image-size/itisfoundation/datcore-adapter./staging-latest.svg?label=datcore-adapter.&style=flat
[image-badge]:https://images.microbadger.com/badges/image/itisfoundation/datcore-adapter.svg
[image-version]https://images.microbadger.com/badges/version/itisfoundation/datcore-adapter.svg
[image-commit]:https://images.microbadger.com/badges/commit/itisfoundation/datcore-adapter.svg
<!------------------------->

## Development

Setup environment
Expand Down
4 changes: 0 additions & 4 deletions services/storage/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
# storage

[![Docker Pulls](https://img.shields.io/docker/pulls/itisfoundation/storage.svg)](https://hub.docker.com/r/itisfoundation/storage/tags)
[![](https://images.microbadger.com/badges/image/itisfoundation/storage.svg)](https://microbadger.com/images/itisfoundation/storage "More on service image in registry")
[![](https://images.microbadger.com/badges/version/itisfoundation/storage.svg)](https://microbadger.com/images/itisfoundation/storage "More on service image in registry")
[![](https://images.microbadger.com/badges/commit/itisfoundation/storage.svg)](https://microbadger.com/images/itisfoundation/storage "More on service image in registry")

Service to manage data storage in simcore
Loading
Loading