Skip to content

Commit

Permalink
✨Releases public-api 0.7 (ITISFoundation#6489)
Browse files Browse the repository at this point in the history
pcrespov authored and mrnicegyu11 committed Oct 14, 2024
1 parent b936411 commit 2dfed79
Showing 9 changed files with 2,061 additions and 537 deletions.
2 changes: 1 addition & 1 deletion services/api-server/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.6.0
0.7.0
2,516 changes: 2,029 additions & 487 deletions services/api-server/openapi.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions services/api-server/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.6.0
current_version = 0.7.0
commit = True
message = services/api-server version: {current_version} → {new_version}
tag = False
@@ -10,12 +10,12 @@ commit_args = --no-verify
[tool:pytest]
asyncio_mode = auto
addopts = --strict-markers
markers =
markers =
slow: marks tests as slow (deselect with '-m "not slow"')
acceptance_test: "marks tests as 'acceptance tests' i.e. does the system do what the user expects? Typically those are workflows."
testit: "marks test to run during development"

[mypy]
plugins =
plugins =
pydantic.mypy
sqlalchemy.ext.mypy.plugin
Original file line number Diff line number Diff line change
@@ -2,15 +2,13 @@
import datetime
import io
import logging
from textwrap import dedent
from typing import IO, Annotated, Any
from uuid import UUID

from fastapi import APIRouter, Body, Depends
from fastapi import File as FileParam
from fastapi import Header, Request, UploadFile, status
from fastapi.exceptions import HTTPException
from fastapi.responses import HTMLResponse
from fastapi_pagination.api import create_page
from models_library.api_schemas_storage import ETag, FileUploadCompletionBody, LinkType
from models_library.basic_types import SHA256Str
@@ -29,7 +27,6 @@
from starlette.datastructures import URL
from starlette.responses import RedirectResponse

from ..._meta import API_VTAG
from ...exceptions.service_errors_utils import DEFAULT_BACKEND_SERVICE_STATUS_CODES
from ...models.pagination import Page, PaginationParams
from ...models.schemas.errors import ErrorGet
@@ -158,7 +155,11 @@ def _get_spooled_file_size(file_io: IO) -> int:
return file_size


@router.put("/content", response_model=File, responses=_FILE_STATUS_CODES)
@router.put(
"/content",
response_model=File,
responses=_FILE_STATUS_CODES,
)
@cancel_on_disconnect
async def upload_file(
request: Request,
@@ -433,24 +434,3 @@ async def download_file(

_logger.info("Downloading %s to %s ...", file_meta, presigned_download_link)
return RedirectResponse(presigned_download_link)


async def files_upload_multiple_view():
"""Extra **Web form** to upload multiple files at http://localhost:8000/v0/files/upload-form-view
and overcomes the limitations of Swagger-UI view
NOTE: Only enabled if DEBUG=1
NOTE: As of 2020-10-07, Swagger UI doesn't support multiple file uploads in the same form field
"""
return HTMLResponse(
content=dedent(
f"""
<body>
<form action="/{API_VTAG}/files:upload" enctype="multipart/form-data" method="post">
<input name="files" type="file" multiple>
<input type="submit">
</form>
</body>
"""
)
)
Original file line number Diff line number Diff line change
@@ -265,7 +265,8 @@ async def list_solver_ports(
@router.get(
"/{solver_key:path}/releases/{version}/pricing_plan",
response_model=ServicePricingPlanGet,
include_in_schema=API_SERVER_DEV_FEATURES_ENABLED,
description="Gets solver pricing plan\n\n"
+ FMSG_CHANGELOG_NEW_IN_VERSION.format("0.7"),
responses=_SOLVER_STATUS_CODES,
)
async def get_solver_pricing_plan(
Original file line number Diff line number Diff line change
@@ -40,7 +40,6 @@
from ..dependencies.authentication import get_current_user_id, get_product_name
from ..dependencies.services import get_api_client
from ..dependencies.webserver import AuthSession, get_webserver_session
from ._common import API_SERVER_DEV_FEATURES_ENABLED
from ._constants import FMSG_CHANGELOG_ADDED_IN_VERSION, FMSG_CHANGELOG_NEW_IN_VERSION

_logger = logging.getLogger(__name__)
@@ -145,9 +144,8 @@ async def create_job(
"/{solver_key:path}/releases/{version}/jobs/{job_id:uuid}",
status_code=status.HTTP_204_NO_CONTENT,
responses=JOBS_STATUS_CODES,
include_in_schema=API_SERVER_DEV_FEATURES_ENABLED,
description="Deletes an existing solver job\n\n"
+ FMSG_CHANGELOG_NEW_IN_VERSION.format("0.5"),
+ FMSG_CHANGELOG_NEW_IN_VERSION.format("0.7"),
)
async def delete_job(
solver_key: SolverKeyId,
@@ -271,9 +269,8 @@ async def inspect_job(
"/{solver_key:path}/releases/{version}/jobs/{job_id:uuid}/metadata",
response_model=JobMetadata,
responses=METADATA_STATUS_CODES,
include_in_schema=API_SERVER_DEV_FEATURES_ENABLED,
description="Updates custom metadata from a job\n\n"
+ FMSG_CHANGELOG_NEW_IN_VERSION.format("0.5"),
+ FMSG_CHANGELOG_NEW_IN_VERSION.format("0.7"),
)
async def replace_job_custom_metadata(
solver_key: SolverKeyId,
Original file line number Diff line number Diff line change
@@ -52,7 +52,6 @@
from ..dependencies.rabbitmq import get_log_check_timeout, get_log_distributor
from ..dependencies.services import get_api_client
from ..dependencies.webserver import AuthSession, get_webserver_session
from ._common import API_SERVER_DEV_FEATURES_ENABLED
from ._constants import FMSG_CHANGELOG_NEW_IN_VERSION
from .solvers_jobs import (
JOBS_STATUS_CODES,
@@ -128,7 +127,8 @@ async def list_jobs(
):
"""List of jobs in a specific released solver (limited to 20 jobs)
SEE `get_jobs_page` for paginated version of this function
- DEPRECATION: This implementation and returned values are deprecated and the will be replaced by that of get_jobs_page
- SEE `get_jobs_page` for paginated version of this function
"""

solver = await catalog_client.get_service(
@@ -158,7 +158,6 @@ async def list_jobs(
"/{solver_key:path}/releases/{version}/jobs/page",
response_model=Page[Job],
responses=JOBS_STATUS_CODES,
include_in_schema=API_SERVER_DEV_FEATURES_ENABLED,
description=(
"List of jobs on a specific released solver (includes pagination)\n\n"
+ FMSG_CHANGELOG_NEW_IN_VERSION.format("0.7")
@@ -349,9 +348,8 @@ async def get_job_output_logfile(
"/{solver_key:path}/releases/{version}/jobs/{job_id:uuid}/metadata",
response_model=JobMetadata,
responses=METADATA_STATUS_CODES,
include_in_schema=API_SERVER_DEV_FEATURES_ENABLED,
description="Gets custom metadata from a job\n\n"
+ FMSG_CHANGELOG_NEW_IN_VERSION.format("0.5"),
+ FMSG_CHANGELOG_NEW_IN_VERSION.format("0.7"),
)
async def get_job_custom_metadata(
solver_key: SolverKeyId,
@@ -380,7 +378,7 @@ async def get_job_custom_metadata(
"/{solver_key:path}/releases/{version}/jobs/{job_id:uuid}/wallet",
response_model=WalletGetWithAvailableCredits | None,
responses=WALLET_STATUS_CODES,
include_in_schema=API_SERVER_DEV_FEATURES_ENABLED,
description=("Get job wallet\n\n" + FMSG_CHANGELOG_NEW_IN_VERSION.format("0.7")),
)
async def get_job_wallet(
solver_key: SolverKeyId,
@@ -400,7 +398,9 @@ async def get_job_wallet(
"/{solver_key:path}/releases/{version}/jobs/{job_id:uuid}/pricing_unit",
response_model=PricingUnitGet | None,
responses=_PRICING_UNITS_STATUS_CODES,
include_in_schema=API_SERVER_DEV_FEATURES_ENABLED,
description=(
"Get job pricing unit\n\n" + FMSG_CHANGELOG_NEW_IN_VERSION.format("0.7")
),
)
async def get_job_pricing_unit(
solver_key: SolverKeyId,
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@
from ...services.webserver import AuthSession
from ..dependencies.application import get_reverse_url_mapper
from ._common import API_SERVER_DEV_FEATURES_ENABLED
from ._constants import FMSG_CHANGELOG_CHANGED_IN_VERSION
from ._constants import FMSG_CHANGELOG_CHANGED_IN_VERSION, FMSG_CHANGELOG_NEW_IN_VERSION

_logger = logging.getLogger(__name__)
router = APIRouter()
@@ -333,15 +333,17 @@ async def get_study_job_output_logfile(
@router.get(
"/{study_id}/jobs/{job_id}/metadata",
response_model=JobMetadata,
include_in_schema=API_SERVER_DEV_FEATURES_ENABLED,
description=(
"Get custom metadata from a study's job\n\n"
+ FMSG_CHANGELOG_NEW_IN_VERSION.format("0.7")
),
)
async def get_study_job_custom_metadata(
study_id: StudyID,
job_id: JobID,
webserver_api: Annotated[AuthSession, Depends(get_webserver_session)],
url_for: Annotated[Callable, Depends(get_reverse_url_mapper)],
):
"""Gets custom metadata from a job"""
job_name = _compose_job_resource_name(study_id, job_id)
msg = f"Gets metadata attached to study_id={study_id!r} job_id={job_id!r}.\njob_name={job_name!r}.\nSEE https://github.com/ITISFoundation/osparc-simcore/issues/4313"
_logger.debug(msg)
@@ -361,7 +363,10 @@ async def get_study_job_custom_metadata(
@router.put(
"/{study_id}/jobs/{job_id}/metadata",
response_model=JobMetadata,
include_in_schema=API_SERVER_DEV_FEATURES_ENABLED,
description=(
"Changes custom metadata of a study's job\n\n"
+ FMSG_CHANGELOG_NEW_IN_VERSION.format("0.7")
),
)
async def replace_study_job_custom_metadata(
study_id: StudyID,
@@ -370,7 +375,6 @@ async def replace_study_job_custom_metadata(
webserver_api: Annotated[AuthSession, Depends(get_webserver_session)],
url_for: Annotated[Callable, Depends(get_reverse_url_mapper)],
):
"""Changes job's custom metadata"""
job_name = _compose_job_resource_name(study_id, job_id)

msg = f"Attaches metadata={replace.metadata!r} to study_id={study_id!r} job_id={job_id!r}.\njob_name={job_name!r}.\nSEE https://github.com/ITISFoundation/osparc-simcore/issues/4313"
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
from ...exceptions.service_errors_utils import DEFAULT_BACKEND_SERVICE_STATUS_CODES
from ...models.schemas.errors import ErrorGet
from ..dependencies.webserver import AuthSession, get_webserver_session
from ._common import API_SERVER_DEV_FEATURES_ENABLED
from ._constants import FMSG_CHANGELOG_NEW_IN_VERSION

_logger = logging.getLogger(__name__)

@@ -28,8 +28,8 @@

@router.get(
"/default",
description="Get default wallet\n\n" + FMSG_CHANGELOG_NEW_IN_VERSION.format("0.7"),
response_model=WalletGetWithAvailableCredits,
include_in_schema=API_SERVER_DEV_FEATURES_ENABLED,
responses=WALLET_STATUS_CODES,
)
async def get_default_wallet(
@@ -41,8 +41,8 @@ async def get_default_wallet(
@router.get(
"/{wallet_id}",
response_model=WalletGetWithAvailableCredits,
include_in_schema=API_SERVER_DEV_FEATURES_ENABLED,
responses=WALLET_STATUS_CODES,
description="Get wallet\n\n" + FMSG_CHANGELOG_NEW_IN_VERSION.format("0.7"),
)
async def get_wallet(
wallet_id: int,

0 comments on commit 2dfed79

Please sign in to comment.