Skip to content

Commit 4530e99

Browse files
committed
Merge branch 'master' into extend-locust-tests
2 parents d9b9f52 + 904b669 commit 4530e99

File tree

175 files changed

+3269
-1052
lines changed

Some content is hidden

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

175 files changed

+3269
-1052
lines changed

.codecov.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ component_management:
3131
- component_id: pkg_aws_library
3232
paths:
3333
- packages/aws-library/**
34+
- component_id: pkg_celery_library
35+
paths:
36+
- packages/celery-library/**
3437
- component_id: pkg_dask_task_models_library
3538
paths:
3639
- packages/dask-task-models-library/**

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Makefile @pcrespov @sanderegg
1313
/api/ @sanderegg @pcrespov @matusdrobuliak66
1414
/ci/ @sanderegg @pcrespov
1515
/docs/ @pcrespov
16+
/packages/celery-library/ @giancarloromeo
1617
/packages/common-library/ @giancarloromeo
1718
/packages/models-library/ @sanderegg @pcrespov @matusdrobuliak66 @giancarloromeo
1819
/packages/postgres-database/ @matusdrobuliak66

.github/tips.md renamed to .github/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,15 @@ WARNING: do not name this file as README.md since it will be rendered in the mai
77
- ``PULL_REQUEST_TEMPLATE.md``
88
- ``ISSUE_TEMPLATE`` folder:
99
- Add [top-level syntax](https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-issue-forms#top-level-syntax) to ISSUE_TEMPLATE/*.md files to configure them and view them as [template in the github web](https://github.com/ITISFoundation/osparc-simcore/issues/new/choose)
10+
11+
12+
---
13+
14+
## Copilot Usage Tips
15+
16+
1. **Be Specific**: Provide clear and detailed prompts to Copilot for better suggestions.
17+
2. **Iterate**: Review and refine Copilot's suggestions to ensure they meet project standards.
18+
3. **Split Tasks**: Break down complex tasks into smaller, manageable parts for better suggestions.
19+
4. **Test Suggestions**: Always test Copilot-generated code to ensure it works as expected.
20+
21+
- SEE https://code.visualstudio.com/docs/copilot/copilot-customization#_custom-instructions

.github/codeql/codeql-config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ disable-default-queries: false
44

55
paths:
66
- packages/aws-library/src
7+
- packages/celery-library/src
78
- packages/dask-task-models-library/src
89
- packages/models-library/src/models_library
910
- packages/postgres-database/src/simcore_postgres_database

.github/copilot-instructions.md

Lines changed: 43 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,52 +4,58 @@ This document provides guidelines and best practices for using GitHub Copilot in
44

55
## General Guidelines
66

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.
7+
1. **Test-Driven Development**: Write unit tests for all new functions and features. Use `pytest` for Python and appropriate testing frameworks for Node.js.
8+
2. **Environment Variables**: Use [Environment Variables Guide](../docs/env-vars.md) for configuration. Avoid hardcoding sensitive information.
9+
3. **Documentation**: Prefer self-explanatory code; add documentation only if explicitly requested by the developer.
1310

14-
## Python-Specific Instructions
11+
---
1512

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-
- use f-string formatting
25-
- Only add comments in function if strictly necessary
26-
- use relative imports
27-
- imports should be at top of the file
13+
## 🛠️Coding Instructions for Python in This Repository
2814

15+
Follow these rules strictly when generating Python code:
2916

30-
### Json serialization
17+
### 1. Python Version
3118

32-
- Generally use `json_dumps`/`json_loads` from `common_library.json_serialization` to built-in `json.dumps` / `json.loads`.
33-
- Prefer Pydantic model methods (e.g., `model.model_dump_json()`) for serialization.
19+
* Use Python 3.11: Ensure all code uses features and syntax compatible with Python 3.11.
3420

21+
### 2. **Type Annotations**
3522

36-
## Node.js-Specific Instructions
23+
* Always use full type annotations for all functions and class attributes.
24+
***Exception**: Do **not** add return type annotations in `test_*` functions.
3725

38-
- Use ES6+ syntax and features.
39-
- Follow the `package.json` configuration for dependencies and scripts.
40-
- Use `eslint` for linting and `prettier` for code formatting.
41-
- Write modular and reusable code, adhering to the project's structure.
26+
### 3. **Code Style & Formatting**
4227

43-
## Copilot Usage Tips
28+
* Follow [Python Coding Conventions](../docs/coding-conventions.md) **strictly**.
29+
* Format code with `black`.
30+
* Lint code with `ruff` and `pylint`.
4431

45-
1. **Be Specific**: Provide clear and detailed prompts to Copilot for better suggestions.
46-
2. **Iterate**: Review and refine Copilot's suggestions to ensure they meet project standards.
47-
3. **Split Tasks**: Break down complex tasks into smaller, manageable parts for better suggestions.
48-
4. **Test Suggestions**: Always test Copilot-generated code to ensure it works as expected.
32+
### 4. **Library Compatibility**
4933

50-
## Additional Resources
34+
Ensure compatibility with the following library versions:
5135

52-
- [Python Coding Conventions](../docs/coding-conventions.md)
53-
- [Environment Variables Guide](../docs/env-vars.md)
54-
- [Pydantic Annotated fields](../docs/llm-prompts/pydantic-annotated-fields.md)
55-
- [Steps to Upgrade Python](../docs/steps-to-upgrade-python.md)
36+
* `sqlalchemy` ≥ 2.x
37+
* `pydantic` ≥ 2.x
38+
* `fastapi` ≥ 0.100
39+
40+
41+
### 5. **Code Practices**
42+
43+
* Use `f-string` formatting for all string interpolation except for logging message strings.
44+
* Use **relative imports** within the same package/module.
45+
* Place **all imports at the top** of the file.
46+
* Add comments **only when the code is not self-explanatory**.
47+
48+
49+
### 6. **JSON Serialization**
50+
51+
* Prefer `json_dumps` / `json_loads` from `common_library.json_serialization` instead of the built-in `json.dumps` / `json.loads`.
52+
* When using Pydantic models, prefer methods like `model.model_dump_json()` for serialization.
53+
54+
---
55+
56+
## 🛠️Coding Instructions for Node.js in This Repository
57+
58+
* Use ES6+ syntax and features.
59+
* Follow the `package.json` configuration for dependencies and scripts.
60+
* Use `eslint` for linting and `prettier` for code formatting.
61+
* Write modular and reusable code, adhering to the project's structure.

docs/llm-prompts/pydantic-annotated-fields.md renamed to .github/prompts/pydantic-annotated-fields.prompt.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
# Prompt
1+
---
2+
mode: 'edit'
3+
description: 'Convert Pydantic model fields to use Annotated pattern'
4+
---
5+
26

3-
```
47
Please convert all pydantic model fields that use `Field()` with default values to use the Annotated pattern instead.
58
Follow these guidelines:
69

@@ -10,7 +13,8 @@ Follow these guidelines:
1013
4. Add the import: `from common_library.basic_types import DEFAULT_FACTORY` if it's not already present.
1114
5. If `Field()` has no parameters (empty), don't use Annotated at all. Just use: `field_name: field_type = default_value`.
1215
6. Leave any model validations, `model_config` settings, and `field_validators` untouched.
13-
```
16+
17+
1418
## Examples
1519

1620
### Before:
@@ -53,13 +57,11 @@ class ProjectModel(BaseModel):
5357
id: str = Field(default_factory=uuid.uuid4, description="Unique project identifier")
5458
name: str = Field(default="Untitled Project", min_length=3, max_length=50)
5559
created_at: datetime = Field(default_factory=datetime.now)
60+
value: int = Field(..., description="Project value")
61+
str_with_default: str = Field(default="foo")
62+
5663
config: dict = Field(default={"version": "1.0", "theme": "default"})
5764

58-
@field_validator("name")
59-
def validate_name(cls, v):
60-
if v.isdigit():
61-
raise ValueError("Name cannot be only digits")
62-
return v
6365
```
6466

6567
### After:
@@ -74,11 +76,9 @@ class ProjectModel(BaseModel):
7476
id: Annotated[str, Field(default_factory=uuid.uuid4, description="Unique project identifier")] = DEFAULT_FACTORY
7577
name: Annotated[str, Field(min_length=3, max_length=50)] = "Untitled Project"
7678
created_at: Annotated[datetime, Field(default_factory=datetime.now)] = DEFAULT_FACTORY
79+
value: Annotated[int, Field(description="Project value")]
80+
str_with_default: str = "foo"
81+
7782
config: dict = {"version": "1.0", "theme": "default"}
7883

79-
@field_validator("name")
80-
def validate_name(cls, v):
81-
if v.isdigit():
82-
raise ValueError("Name cannot be only digits")
83-
return v
8484
```

.github/workflows/ci-testing-deploy.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ jobs:
4747
# Set job outputs to values from filter step
4848
outputs:
4949
aws-library: ${{ steps.filter.outputs.aws-library }}
50+
celery-library: ${{ steps.filter.outputs.celery-library }}
5051
dask-task-models-library: ${{ steps.filter.outputs.dask-task-models-library }}
5152
models-library: ${{ steps.filter.outputs.models-library }}
5253
common-library: ${{ steps.filter.outputs.common-library }}
@@ -94,6 +95,12 @@ jobs:
9495
- 'services/docker-compose*'
9596
- 'scripts/mypy/*'
9697
- 'mypy.ini'
98+
celery-library:
99+
- 'packages/celery-library/**'
100+
- 'packages/pytest-simcore/**'
101+
- 'services/docker-compose*'
102+
- 'scripts/mypy/*'
103+
- 'mypy.ini'
97104
dask-task-models-library:
98105
- 'packages/dask-task-models-library/**'
99106
- 'packages/pytest-simcore/**'
@@ -1035,6 +1042,49 @@ jobs:
10351042
with:
10361043
flags: unittests #optional
10371044

1045+
unit-test-celery-library:
1046+
needs: changes
1047+
if: ${{ needs.changes.outputs.celery-library == 'true' || github.event_name == 'push' || github.event.inputs.force_all_builds == 'true' }}
1048+
timeout-minutes: 18 # if this timeout gets too small, then split the tests
1049+
name: "[unit] celery-library"
1050+
runs-on: ${{ matrix.os }}
1051+
strategy:
1052+
matrix:
1053+
python: ["3.11"]
1054+
os: [ubuntu-24.04]
1055+
fail-fast: false
1056+
steps:
1057+
- uses: actions/checkout@v4
1058+
- name: setup docker buildx
1059+
id: buildx
1060+
uses: docker/setup-buildx-action@v3
1061+
with:
1062+
driver: docker-container
1063+
- name: setup python environment
1064+
uses: actions/setup-python@v5
1065+
with:
1066+
python-version: ${{ matrix.python }}
1067+
- name: install uv
1068+
uses: astral-sh/setup-uv@v6
1069+
with:
1070+
version: "0.6.x"
1071+
enable-cache: false
1072+
cache-dependency-glob: "**/celery-library/requirements/ci.txt"
1073+
- name: show system version
1074+
run: ./ci/helpers/show_system_versions.bash
1075+
- name: install
1076+
run: ./ci/github/unit-testing/celery-library.bash install
1077+
- name: typecheck
1078+
run: ./ci/github/unit-testing/celery-library.bash typecheck
1079+
- name: test
1080+
if: ${{ !cancelled() }}
1081+
run: ./ci/github/unit-testing/celery-library.bash test
1082+
- uses: codecov/codecov-action@v5
1083+
if: ${{ !cancelled() }}
1084+
env:
1085+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
1086+
with:
1087+
flags: unittests #optional
10381088

10391089
unit-test-dask-task-models-library:
10401090
needs: changes
@@ -1824,6 +1874,7 @@ jobs:
18241874
unit-test-clusters-keeper,
18251875
unit-test-dask-sidecar,
18261876
unit-test-aws-library,
1877+
unit-test-celery-library,
18271878
unit-test-dask-task-models-library,
18281879
unit-test-datcore-adapter,
18291880
unit-test-director-v2,

.vscode/launch.template.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,28 @@
4444
"justMyCode": false
4545
},
4646
{
47+
// This test adds --external-envfile and expects a file named ".secrets" in the workspace root.
48+
"name": "Python: Test w/ repo.config",
49+
"type": "debugpy",
50+
"request": "launch",
51+
"module": "pytest",
52+
"args": [
53+
"--ff",
54+
"--log-cli-level=INFO",
55+
"--external-envfile=${workspaceFolder}/.secrets",
56+
"--pdb",
57+
"--setup-show",
58+
"--durations=5",
59+
"-s",
60+
"-vv",
61+
"${file}"
62+
],
63+
"cwd": "${workspaceFolder}",
64+
"console": "integratedTerminal",
65+
"justMyCode": false
66+
},
67+
{
68+
// This tests enables the httpx spy and dumps captures in a json. Mainly for api-server
4769
"name": "Python: Test-Httpx-Spy",
4870
"type": "debugpy",
4971
"request": "launch",

.vscode/settings.template.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"python.analysis.typeCheckingMode": "basic",
3434
"python.analysis.extraPaths": [
3535
"./packages/aws-library/src",
36+
"./packages/celery-library/src",
3637
"./packages/common-library/src",
3738
"./packages/dask-task-models-library/src",
3839
"./packages/models-library/src",
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
3+
set -o errexit # abort on nonzero exitstatus
4+
set -o nounset # abort on unbound variable
5+
set -o pipefail # don't hide errors within pipes
6+
IFS=$'\n\t'
7+
8+
install() {
9+
make devenv
10+
# shellcheck source=/dev/null
11+
source .venv/bin/activate
12+
pushd packages/celery-library
13+
make install-ci
14+
popd
15+
uv pip list
16+
}
17+
18+
test() {
19+
# shellcheck source=/dev/null
20+
source .venv/bin/activate
21+
pushd packages/celery-library
22+
make tests-ci
23+
popd
24+
}
25+
26+
typecheck() {
27+
# shellcheck source=/dev/null
28+
source .venv/bin/activate
29+
uv pip install mypy
30+
pushd packages/celery-library
31+
make mypy
32+
popd
33+
}
34+
35+
# Check if the function exists (bash specific)
36+
if declare -f "$1" >/dev/null; then
37+
# call arguments verbatim
38+
"$@"
39+
else
40+
# Show a helpful error
41+
echo "'$1' is not a known function name" >&2
42+
exit 1
43+
fi

0 commit comments

Comments
 (0)