Skip to content

Commit defac3c

Browse files
Merge branch 'master' into monitor-celery-tasks-cancellation
2 parents 4260e22 + 7113a91 commit defac3c

File tree

112 files changed

+2043
-905
lines changed

Some content is hidden

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

112 files changed

+2043
-905
lines changed

.github/copilot-instructions.md

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

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_directorv2/services.py

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import Final
22

3-
from pydantic import BaseModel, ConfigDict, Field, field_validator
3+
from pydantic import BaseModel, ConfigDict, Field, JsonValue, field_validator
4+
from pydantic.config import JsonDict
45
from pydantic.types import ByteSize, NonNegativeInt
56

67
from ..service_settings_labels import ContainerSpec
@@ -63,36 +64,43 @@ class ServiceExtras(BaseModel):
6364
service_build_details: ServiceBuildDetails | None = None
6465
container_spec: ContainerSpec | None = None
6566

67+
@staticmethod
68+
def _update_json_schema_extra(schema: JsonDict) -> None:
69+
70+
node_requirements_examples = NodeRequirements.model_json_schema()["examples"]
71+
72+
examples: list[JsonValue] = [
73+
{"node_requirements": node_example}
74+
for node_example in node_requirements_examples
75+
]
76+
examples += [
77+
{
78+
"node_requirements": node_example,
79+
"service_build_details": {
80+
"build_date": "2021-08-13T12:56:28Z",
81+
"vcs_ref": "8251ade",
82+
"vcs_url": "[email protected]:ITISFoundation/osparc-simcore.git",
83+
},
84+
}
85+
for node_example in node_requirements_examples
86+
]
87+
examples += [
88+
{
89+
"node_requirements": node_example,
90+
"service_build_details": {
91+
"build_date": "2021-08-13T12:56:28Z",
92+
"vcs_ref": "8251ade",
93+
"vcs_url": "[email protected]:ITISFoundation/osparc-simcore.git",
94+
},
95+
"container_spec": {"Command": ["run", "subcommand"]},
96+
}
97+
for node_example in node_requirements_examples
98+
]
99+
100+
schema.update({"examples": examples})
101+
66102
model_config = ConfigDict(
67-
json_schema_extra={
68-
"examples": [
69-
{"node_requirements": node_example}
70-
for node_example in NodeRequirements.model_json_schema()["examples"]
71-
]
72-
+ [
73-
{
74-
"node_requirements": node_example,
75-
"service_build_details": {
76-
"build_date": "2021-08-13T12:56:28Z",
77-
"vcs_ref": "8251ade",
78-
"vcs_url": "[email protected]:ITISFoundation/osparc-simcore.git",
79-
},
80-
}
81-
for node_example in NodeRequirements.model_json_schema()["examples"]
82-
]
83-
+ [
84-
{
85-
"node_requirements": node_example,
86-
"service_build_details": {
87-
"build_date": "2021-08-13T12:56:28Z",
88-
"vcs_ref": "8251ade",
89-
"vcs_url": "[email protected]:ITISFoundation/osparc-simcore.git",
90-
},
91-
"container_spec": {"Command": ["run", "subcommand"]},
92-
}
93-
for node_example in NodeRequirements.model_json_schema()["examples"]
94-
]
95-
}
103+
json_schema_extra=_update_json_schema_extra,
96104
)
97105

98106

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[project]
2+
name = "pytest-simcore"
3+
version = "0.1.0"
4+
requires-python = ">=3.11"
5+
dependencies = [
6+
"fastapi[standard]>=0.115.12",
7+
"python-socketio>=5.12.1",
8+
"uvicorn>=0.34.0",
9+
]

packages/pytest-simcore/src/pytest_simcore/helpers/logging_tools.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ def _timedelta_as_minute_second_ms(delta: datetime.timedelta) -> str:
2020
result += f"{int(seconds)}s "
2121

2222
if int(milliseconds * 1000) != 0:
23-
result += f"{int(milliseconds*1000)}ms"
23+
result += f"{int(milliseconds * 1000)}ms"
24+
if not result:
25+
result = "<1ms"
2426

25-
sign = "-" if total_seconds < 0 else "<1ms"
27+
sign = "-" if total_seconds < 0 else ""
2628

2729
return f"{sign}{result.strip()}"
2830

0 commit comments

Comments
 (0)