Skip to content

Commit f63eb83

Browse files
committed
revert
1 parent a96cf46 commit f63eb83

File tree

6 files changed

+56
-116
lines changed

6 files changed

+56
-116
lines changed
Lines changed: 18 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
from contextlib import suppress
2-
from typing import Any, Final
3-
4-
from packaging.version import Version
5-
6-
from ..._meta import API_VERSION
1+
from typing import Final
72

83
#
94
# CHANGELOG formatted-messages for API routes
@@ -14,48 +9,49 @@
149
# - Inspired on this idea https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#describing-changes-between-versions
1510
#
1611

17-
# newly created endpoint in given version
12+
# new routes
1813
FMSG_CHANGELOG_NEW_IN_VERSION: Final[str] = "New in *version {}*\n"
1914

20-
# changes in given version with message
15+
# new inputs/outputs in routes
16+
FMSG_CHANGELOG_ADDED_IN_VERSION: Final[str] = "Added in *version {}*: {}\n"
17+
18+
# changes on inputs/outputs in routes
2119
FMSG_CHANGELOG_CHANGED_IN_VERSION: Final[str] = "Changed in *version {}*: {}\n"
2220

23-
# marked as deprecated
24-
FMSG_CHANGELOG_DEPRECATED_IN_VERSION: Final[str] = (
21+
# removed on inputs/outputs in routes
22+
FMSG_CHANGELOG_REMOVED_IN_VERSION_FORMAT: Final[str] = "Removed in *version {}*: {}\n"
23+
24+
FMSG_DEPRECATED_ROUTE_NOTICE: Final[str] = (
2525
"🚨 **Deprecated**: This endpoint is deprecated and will be removed in a future release.\n"
2626
"Please use `{}` instead.\n\n"
2727
)
2828

29-
# marked as deprecated and will be removed in given version
30-
FMSG_CHANGELOG_REMOVED_IN_VERSION: Final[str] = "Removed in *version {}*: {}\n"
31-
32-
3329
DEFAULT_MAX_STRING_LENGTH: Final[int] = 500
3430

3531

3632
def create_route_description(
3733
*,
3834
base: str = "",
39-
changelog: list[str] | None = None,
40-
deprecated_in: str | None = None,
41-
alternative: str | None = None,
35+
deprecated: bool = False,
36+
alternative: str | None = None, # alternative
37+
changelog: list[str] | None = None
4238
) -> str:
4339
"""
4440
Builds a consistent route description with optional deprecation and changelog information.
4541
4642
Args:
4743
base (str): Main route description.
48-
changelog (list[str]): List of formatted changelog strings.
49-
deprecated_in (str, optional): Version when this endpoint was deprecated.
50-
alternative (str, optional): Alternative route to use if deprecated.
44+
deprecated (tuple): (retirement_date, alternative_route) if deprecated.
45+
changelog (List[str]): List of formatted changelog strings.
5146
5247
Returns:
5348
str: Final description string.
5449
"""
5550
parts = []
5651

57-
if deprecated_in and alternative:
58-
parts.append(FMSG_CHANGELOG_DEPRECATED_IN_VERSION.format(alternative))
52+
if deprecated:
53+
assert alternative, "If deprecated, alternative must be provided" # nosec
54+
parts.append(FMSG_DEPRECATED_ROUTE_NOTICE.format(alternative))
5955

6056
if base:
6157
parts.append(base)
@@ -64,68 +60,3 @@ def create_route_description(
6460
parts.append("\n".join(changelog))
6561

6662
return "\n\n".join(parts)
67-
68-
69-
def create_route_config(
70-
base_description: str = "",
71-
*,
72-
changelog: list[str] | None = None,
73-
) -> dict[str, Any]:
74-
"""
75-
Creates route configuration options including description based on changelog history.
76-
77-
The function analyzes the changelog to determine if the endpoint:
78-
- Is not yet released (if the earliest entry is in a future version)
79-
- Is deprecated (if there's a removal notice in the changelog)
80-
81-
Args:
82-
base_description: Main route description
83-
changelog: List of formatted changelog strings indicating version history
84-
85-
Returns:
86-
dict: Route configuration options that can be used as kwargs for route decorators
87-
"""
88-
route_options: dict[str, Any] = {}
89-
changelog = changelog or []
90-
91-
# Parse changelog to determine endpoint state
92-
is_deprecated = False
93-
alternative = None
94-
is_released = False
95-
current_version = Version(API_VERSION)
96-
97-
for entry in changelog:
98-
# Check for deprecation/removal entries
99-
if FMSG_CHANGELOG_DEPRECATED_IN_VERSION.split("{")[0] in entry:
100-
is_deprecated = True
101-
# Extract alternative from deprecation message if possible
102-
with suppress(IndexError, AttributeError):
103-
alternative = entry.split("Please use `")[1].split("`")[0]
104-
105-
# Check for new version entries to determine if this is unreleased
106-
elif FMSG_CHANGELOG_NEW_IN_VERSION.split("{")[0] in entry:
107-
try:
108-
version_str = entry.split("New in *version ")[1].split("*")[0]
109-
entry_version = Version(version_str)
110-
# If the first/earliest entry version is greater than current API version,
111-
# this endpoint is not yet released
112-
if current_version < entry_version:
113-
is_released = True
114-
except (IndexError, ValueError, AttributeError):
115-
pass
116-
117-
# Set route options based on endpoint state
118-
route_options["include_in_schema"] = is_released
119-
route_options["deprecated"] = is_deprecated
120-
121-
# Create description
122-
route_options["description"] = create_route_description(
123-
base=base_description,
124-
changelog=changelog,
125-
deprecated_in=(
126-
"Unknown" if is_deprecated else None
127-
), # We don't extract exact version
128-
alternative=alternative,
129-
)
130-
131-
return route_options

services/api-server/src/simcore_service_api_server/api/routes/files.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@
3030
)
3131
from simcore_sdk.node_ports_common.filemanager import upload_path as storage_upload_path
3232
from simcore_service_api_server.api.routes._constants import (
33-
FMSG_CHANGELOG_NEW_IN_VERSION,
34-
create_route_config,
33+
FMSG_CHANGELOG_ADDED_IN_VERSION,
34+
FMSG_CHANGELOG_REMOVED_IN_VERSION_FORMAT,
35+
create_route_description,
3536
)
3637
from starlette.datastructures import URL
3738
from starlette.responses import RedirectResponse
@@ -140,12 +141,16 @@ async def _create_domain_file(
140141
"",
141142
response_model=list[OutputFile],
142143
responses=_FILE_STATUS_CODES,
143-
**create_route_config(
144-
base_description="Lists all files stored in the system",
145-
to_be_removed_in="0.7",
144+
description=create_route_description(
145+
base="Lists all files stored in the system",
146+
deprecated=True,
146147
alternative="GET /v0/files/page",
147148
changelog=[
148-
FMSG_CHANGELOG_NEW_IN_VERSION.format("0.5"),
149+
FMSG_CHANGELOG_ADDED_IN_VERSION.format("0.5", ""),
150+
FMSG_CHANGELOG_REMOVED_IN_VERSION_FORMAT.format(
151+
"0.7",
152+
"This endpoint is deprecated and will be removed in a future version",
153+
),
149154
],
150155
),
151156
)

services/api-server/src/simcore_service_api_server/api/routes/programs.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
from ..._service_programs import ProgramService
2424
from ...api.routes._constants import (
2525
DEFAULT_MAX_STRING_LENGTH,
26-
create_route_config,
26+
FMSG_CHANGELOG_NEW_IN_VERSION,
27+
create_route_description,
2728
)
2829
from ...models.basic_types import VersionStr
2930
from ...models.pagination import Page, PaginationParams
@@ -38,10 +39,13 @@
3839
@router.get(
3940
"",
4041
response_model=Page[Program],
41-
**create_route_config(
42-
base_description="Lists the latest of all available programs",
43-
to_be_released_in="0.8",
42+
description=create_route_description(
43+
base="Lists the latest of all available programs",
44+
changelog=[
45+
FMSG_CHANGELOG_NEW_IN_VERSION.format("0.8"),
46+
],
4447
),
48+
include_in_schema=False, # TO BE RELEASED in 0.8
4549
)
4650
async def list_programs(
4751
user_id: Annotated[PositiveInt, Depends(get_current_user_id)],
@@ -74,10 +78,13 @@ async def list_programs(
7478
@router.get(
7579
"/{program_key:path}/releases",
7680
response_model=Page[Program],
77-
**create_route_config(
78-
base_description="Lists the latest of all available programs",
79-
to_be_released_in="0.8",
81+
description=create_route_description(
82+
base="Lists the latest of all available programs",
83+
changelog=[
84+
FMSG_CHANGELOG_NEW_IN_VERSION.format("0.8"),
85+
],
8086
),
87+
include_in_schema=False, # TO BE RELEASED in 0.8
8188
)
8289
async def list_program_history(
8390
program_key: ProgramKeyId,

services/api-server/src/simcore_service_api_server/api/routes/solvers.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
from ..dependencies.webserver_http import AuthSession, get_webserver_session
2727
from ._constants import (
2828
FMSG_CHANGELOG_NEW_IN_VERSION,
29-
FMSG_CHANGELOG_REMOVED_IN_VERSION,
30-
create_route_config,
29+
FMSG_CHANGELOG_REMOVED_IN_VERSION_FORMAT,
3130
create_route_description,
3231
)
3332

@@ -60,13 +59,13 @@
6059
"",
6160
response_model=list[Solver],
6261
responses=_SOLVER_STATUS_CODES,
63-
**create_route_config(
64-
base_description="Lists all available solvers (latest version)",
65-
to_be_removed_in="0.7",
62+
description=create_route_description(
63+
base="Lists all available solvers (latest version)",
64+
deprecated=True,
6665
alternative="GET /v0/solvers/page",
6766
changelog=[
6867
FMSG_CHANGELOG_NEW_IN_VERSION.format("0.5.0", ""),
69-
FMSG_CHANGELOG_REMOVED_IN_VERSION.format(
68+
FMSG_CHANGELOG_REMOVED_IN_VERSION_FORMAT.format(
7069
"0.7",
7170
"This endpoint is deprecated and will be removed in a future version",
7271
),
@@ -142,7 +141,7 @@ async def get_solvers_page(
142141
alternative="GET /v0/solvers/{solver_key}/releases/page",
143142
changelog=[
144143
FMSG_CHANGELOG_NEW_IN_VERSION.format("0.5.0", ""),
145-
FMSG_CHANGELOG_REMOVED_IN_VERSION.format(
144+
FMSG_CHANGELOG_REMOVED_IN_VERSION_FORMAT.format(
146145
"0.7",
147146
"This endpoint is deprecated and will be removed in a future version",
148147
),

services/api-server/src/simcore_service_api_server/api/routes/solvers_jobs.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
from ..dependencies.services import get_api_client, get_solver_service
3838
from ..dependencies.webserver_http import AuthSession, get_webserver_session
3939
from ._constants import (
40+
FMSG_CHANGELOG_ADDED_IN_VERSION,
4041
FMSG_CHANGELOG_CHANGED_IN_VERSION,
4142
FMSG_CHANGELOG_NEW_IN_VERSION,
4243
)
@@ -163,10 +164,8 @@ async def delete_job(
163164
},
164165
},
165166
description="Starts job job_id created with the solver solver_key:version\n\n"
166-
+ FMSG_CHANGELOG_CHANGED_IN_VERSION.format(
167-
"0.4.3", "adds query parameter `cluster_id`"
168-
)
169-
+ FMSG_CHANGELOG_CHANGED_IN_VERSION.format(
167+
+ FMSG_CHANGELOG_ADDED_IN_VERSION.format("0.4.3", "query parameter `cluster_id`")
168+
+ FMSG_CHANGELOG_ADDED_IN_VERSION.format(
170169
"0.6", "responds with a 202 when successfully starting a computation"
171170
)
172171
+ FMSG_CHANGELOG_CHANGED_IN_VERSION.format(

services/api-server/src/simcore_service_api_server/api/routes/solvers_jobs_getters.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@
5959
from ..dependencies.webserver_http import AuthSession, get_webserver_session
6060
from ._constants import (
6161
FMSG_CHANGELOG_NEW_IN_VERSION,
62-
FMSG_CHANGELOG_REMOVED_IN_VERSION,
63-
create_route_config,
62+
FMSG_CHANGELOG_REMOVED_IN_VERSION_FORMAT,
6463
create_route_description,
6564
)
6665
from .solvers_jobs import (
@@ -193,13 +192,13 @@ async def list_all_solvers_jobs(
193192
"/{solver_key:path}/releases/{version}/jobs",
194193
response_model=list[Job],
195194
responses=JOBS_STATUS_CODES,
196-
**create_route_config(
197-
base_description="List of jobs in a specific released solver (limited to 20 jobs)",
195+
description=create_route_description(
196+
base="List of jobs in a specific released solver",
198197
deprecated=True,
199198
alternative="GET /{solver_key}/releases/{version}/jobs/page",
200199
changelog=[
201200
FMSG_CHANGELOG_NEW_IN_VERSION.format("0.5"),
202-
FMSG_CHANGELOG_REMOVED_IN_VERSION.format(
201+
FMSG_CHANGELOG_REMOVED_IN_VERSION_FORMAT.format(
203202
"0.7",
204203
"This endpoint is deprecated and will be removed in a future version",
205204
),

0 commit comments

Comments
 (0)