Skip to content

Commit 3837231

Browse files
author
Andrei Neagu
committed
Merge remote-tracking branch 'upstream/master' into pr-osparc-resolve-project-and-node-in-exports
2 parents 2f54a14 + 44972f0 commit 3837231

File tree

230 files changed

+6628
-2516
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

230 files changed

+6628
-2516
lines changed

.coveragerc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ branch = True
33
omit =
44
*/tests/*
55
*/generated_code/*
6+
*/_original_fastapi_encoders.py
67
parallel = True
78

89
[report]

.github/copilot-instructions.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# GitHub Copilot Instructions
2+
3+
This document provides guidelines and best practices for using GitHub Copilot in the `osparc-simcore` repository and other Python and Node.js projects.
4+
5+
## General Guidelines
6+
7+
1. **Use Python 3.11**: Ensure that all Python-related suggestions align with Python 3.11 features and syntax.
8+
2. **Node.js Compatibility**: For Node.js projects, ensure compatibility with the version specified in the project (e.g., Node.js 14 or later).
9+
3. **Follow Coding Conventions**: Adhere to the coding conventions outlined in the `docs/coding-conventions.md` file.
10+
4. **Test-Driven Development**: Write unit tests for all new functions and features. Use `pytest` for Python and appropriate testing frameworks for Node.js.
11+
5. **Environment Variables**: Use environment variables as specified in `docs/env-vars.md` for configuration. Avoid hardcoding sensitive information.
12+
6. **Documentation**: Prefer self-explanatory code; add documentation only if explicitly requested by the developer.
13+
14+
## Python-Specific Instructions
15+
16+
- Always use type hints and annotations to improve code clarity and compatibility with tools like `mypy`.
17+
- An exception to that rule is in `test_*` functions return type hint must not be added
18+
- Follow the dependency management practices outlined in `requirements/`.
19+
- Use `ruff` for code formatting and for linting.
20+
- Use `black` for code formatting and `pylint` for linting.
21+
- ensure we use `sqlalchemy` >2 compatible code.
22+
- ensure we use `pydantic` >2 compatible code.
23+
- ensure we use `fastapi` >0.100 compatible code
24+
25+
26+
## Node.js-Specific Instructions
27+
28+
- Use ES6+ syntax and features.
29+
- Follow the `package.json` configuration for dependencies and scripts.
30+
- Use `eslint` for linting and `prettier` for code formatting.
31+
- Write modular and reusable code, adhering to the project's structure.
32+
33+
## Copilot Usage Tips
34+
35+
1. **Be Specific**: Provide clear and detailed prompts to Copilot for better suggestions.
36+
2. **Iterate**: Review and refine Copilot's suggestions to ensure they meet project standards.
37+
3. **Split Tasks**: Break down complex tasks into smaller, manageable parts for better suggestions.
38+
4. **Test Suggestions**: Always test Copilot-generated code to ensure it works as expected.
39+
40+
## Additional Resources
41+
42+
- [Python Coding Conventions](../docs/coding-conventions.md)
43+
- [Environment Variables Guide](../docs/env-vars.md)
44+
- [Steps to Upgrade Python](../docs/steps-to-upgrade-python.md)
45+
- [Node.js Installation Script](../scripts/install_nodejs_14.bash)

api/specs/web-server/_computations.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
from fastapi import APIRouter, status
2-
from models_library.api_schemas_directorv2.comp_tasks import ComputationGet
3-
from models_library.api_schemas_webserver.computations import ComputationStart
1+
from typing import Annotated
2+
3+
from fastapi import APIRouter, Depends, status
4+
from models_library.api_schemas_webserver.computations import (
5+
ComputationGet,
6+
ComputationPathParams,
7+
ComputationStart,
8+
ComputationStarted,
9+
)
410
from models_library.generics import Envelope
5-
from models_library.projects import ProjectID
611
from simcore_service_webserver._meta import API_VTAG
7-
from simcore_service_webserver.director_v2._handlers import _ComputationStarted
812

913
router = APIRouter(
1014
prefix=f"/{API_VTAG}",
@@ -19,13 +23,12 @@
1923
"/computations/{project_id}",
2024
response_model=Envelope[ComputationGet],
2125
)
22-
async def get_computation(project_id: ProjectID):
23-
...
26+
async def get_computation(_path: Annotated[ComputationPathParams, Depends()]): ...
2427

2528

2629
@router.post(
2730
"/computations/{project_id}:start",
28-
response_model=Envelope[_ComputationStarted],
31+
response_model=Envelope[ComputationStarted],
2932
responses={
3033
status.HTTP_402_PAYMENT_REQUIRED: {
3134
"description": "Insufficient credits to run computation"
@@ -39,13 +42,14 @@ async def get_computation(project_id: ProjectID):
3942
status.HTTP_503_SERVICE_UNAVAILABLE: {"description": "Service not available"},
4043
},
4144
)
42-
async def start_computation(project_id: ProjectID, _start: ComputationStart):
43-
...
45+
async def start_computation(
46+
_path: Annotated[ComputationPathParams, Depends()],
47+
_body: ComputationStart,
48+
): ...
4449

4550

4651
@router.post(
4752
"/computations/{project_id}:stop",
4853
status_code=status.HTTP_204_NO_CONTENT,
4954
)
50-
async def stop_computation(project_id: ProjectID):
51-
...
55+
async def stop_computation(_path: Annotated[ComputationPathParams, Depends()]): ...
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# pylint: disable=redefined-outer-name
2+
# pylint: disable=unused-argument
3+
# pylint: disable=unused-variable
4+
# pylint: disable=too-many-arguments
5+
6+
7+
from typing import Annotated
8+
9+
from fastapi import APIRouter, Depends, status
10+
from models_library.generics import Envelope
11+
from servicelib.aiohttp.long_running_tasks._routes import _PathParam
12+
from servicelib.long_running_tasks._models import TaskGet, TaskStatus
13+
from simcore_service_webserver._meta import API_VTAG
14+
15+
router = APIRouter(
16+
prefix=f"/{API_VTAG}/tasks-legacy",
17+
tags=[
18+
"long-running-tasks-legacy",
19+
],
20+
)
21+
22+
23+
@router.get(
24+
"",
25+
response_model=Envelope[list[TaskGet]],
26+
name="list_tasks",
27+
description="Lists all long running tasks",
28+
)
29+
def list_tasks(): ...
30+
31+
32+
@router.get(
33+
"/{task_id}",
34+
response_model=Envelope[TaskStatus],
35+
name="get_task_status",
36+
description="Retrieves the status of a task",
37+
)
38+
def get_task_status(
39+
_path_params: Annotated[_PathParam, Depends()],
40+
): ...
41+
42+
43+
@router.delete(
44+
"/{task_id}",
45+
name="cancel_and_delete_task",
46+
description="Cancels and deletes a task",
47+
status_code=status.HTTP_204_NO_CONTENT,
48+
)
49+
def cancel_and_delete_task(
50+
_path_params: Annotated[_PathParam, Depends()],
51+
): ...
52+
53+
54+
@router.get(
55+
"/{task_id}/result",
56+
name="get_task_result",
57+
description="Retrieves the result of a task",
58+
)
59+
def get_task_result(
60+
_path_params: Annotated[_PathParam, Depends()],
61+
): ...

api/specs/web-server/openapi.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"_exporter",
3737
"_folders",
3838
"_long_running_tasks",
39+
"_long_running_tasks_legacy",
3940
"_licensed_items",
4041
"_licensed_items_purchases",
4142
"_licensed_items_checkouts",

docs/env-vars.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ The following rules must be followed:
66

77
1. for each service that requires it, add it to the `services/docker-compose.yml` file (such as `MY_VAR=${MY_VAR}`)
88
2. add a meaningful default value for development inside `.env-devel` so that developers can work, and that `osparc-simcore` is **self contained**.
9-
- **NOTE** if the variable has a default inside the code, put the same value here
109
3. inside the repo where devops keep all the secrets follow the instructions to add the new env var

packages/models-library/src/models_library/api_schemas_catalog/services.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from ..boot_options import BootOptions
1010
from ..emails import LowerCaseEmailStr
1111
from ..groups import GroupID
12+
from ..rest_filters import Filters
1213
from ..services_access import ServiceAccessRights, ServiceGroupAccessRightsV2
1314
from ..services_authoring import Author
1415
from ..services_enums import ServiceType
@@ -376,4 +377,13 @@ class MyServiceGet(CatalogOutputSchema):
376377
my_access_rights: ServiceGroupAccessRightsV2
377378

378379

380+
class ServiceListFilters(Filters):
381+
service_type: Annotated[
382+
ServiceType | None,
383+
Field(
384+
description="Filter only services of a given type. If None, then all types are returned"
385+
),
386+
] = None
387+
388+
379389
__all__: tuple[str, ...] = ("ServiceRelease",)

packages/models-library/src/models_library/api_schemas_directorv2/comp_tasks.py

Lines changed: 0 additions & 104 deletions
This file was deleted.

0 commit comments

Comments
 (0)