diff --git a/CHANGELOG.md b/CHANGELOG.md index 40c2ab6d12..5aafad7895 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ into pre-release sections below. * Do not process task owners in task/task-group CRUD operations (\#1861). * Expand use and validators for `TaskGroupCreateV2` schema (\#1861). * Add `DELETE /auth/group/{id}` endpoint (\#1885). + * Forbid extras in `TaskCollectPipV2` (\#1891). * Database: * Add `taskgroupv2_id` foreign key to `CollectionStateV2` (\#1867). * Make `TaskV2.source` nullable and drop its uniqueness constraint (\#1861). diff --git a/fractal_server/__main__.py b/fractal_server/__main__.py index 6de002ecb6..8430406177 100644 --- a/fractal_server/__main__.py +++ b/fractal_server/__main__.py @@ -61,12 +61,6 @@ "update-db-data", description="Apply data-migration script to an existing database.", ) -update_db_data_parser.add_argument( - "--dry-run", - action="store_true", - help="If set, perform a dry run of the data migration.", - default=False, -) def save_openapi(dest="openapi.json"): @@ -126,7 +120,7 @@ def set_db(skip_init_data: bool = False): print() -def update_db_data(dry_run: bool = False): +def update_db_data(): """ Apply data migrations. """ @@ -191,7 +185,7 @@ def _slugify_version(raw_version: str) -> str: sys.exit() print("OK, now starting data-migration script\n") - current_update_db_data_module.fix_db(dry_run=dry_run) + current_update_db_data_module.fix_db() def run(): @@ -202,7 +196,7 @@ def run(): elif args.cmd == "set-db": set_db(skip_init_data=args.skip_init_data) elif args.cmd == "update-db-data": - update_db_data(dry_run=args.dry_run) + update_db_data() elif args.cmd == "start": uvicorn.run( "fractal_server.main:app", diff --git a/fractal_server/app/schemas/v2/task_collection.py b/fractal_server/app/schemas/v2/task_collection.py index 08fb9935c5..17bfa52dd3 100644 --- a/fractal_server/app/schemas/v2/task_collection.py +++ b/fractal_server/app/schemas/v2/task_collection.py @@ -6,6 +6,7 @@ from typing import Optional from pydantic import BaseModel +from pydantic import Extra from pydantic import root_validator from pydantic import validator @@ -24,7 +25,7 @@ class CollectionStatusV2(str, Enum): OK = "OK" -class TaskCollectPipV2(BaseModel): +class TaskCollectPipV2(BaseModel, extra=Extra.forbid): """ TaskCollectPipV2 class diff --git a/fractal_server/data_migrations/2_7_0.py b/fractal_server/data_migrations/2_7_0.py index ea1ef557a1..1773c749b7 100644 --- a/fractal_server/data_migrations/2_7_0.py +++ b/fractal_server/data_migrations/2_7_0.py @@ -110,7 +110,6 @@ def prepare_task_groups( user_mapping: dict[str, int], default_user_group_id: int, default_user_id: int, - dry_run: bool, db: Session, ): stm_tasks = select(TaskV2).order_by(TaskV2.id) @@ -236,14 +235,6 @@ def prepare_task_groups( print() - if dry_run: - print( - "End dry-run of handling task group with key " - f"'{task_group_key}" - ) - print("-" * 80) - continue - task_group = TaskGroupV2(**task_group_attributes) db.add(task_group) db.commit() @@ -254,7 +245,7 @@ def prepare_task_groups( return -def fix_db(dry_run: bool = False): +def fix_db(): logger.warning("START execution of fix_db function") _check_current_version("2.7.0") @@ -268,7 +259,6 @@ def fix_db(dry_run: bool = False): default_user_id=default_user_id, default_user_group_id=default_user_group_id, db=db, - dry_run=dry_run, ) logger.warning("END of execution of fix_db function") diff --git a/tests/v2/03_api/test_api_task_collection.py b/tests/v2/03_api/test_api_task_collection.py index bb528963ce..631368251e 100644 --- a/tests/v2/03_api/test_api_task_collection.py +++ b/tests/v2/03_api/test_api_task_collection.py @@ -400,7 +400,6 @@ async def test_task_collection_custom( source="source1", package_root=None, package_name=package_name, - version=None, ) # Fail because no package is installed in sys.executable @@ -442,7 +441,6 @@ async def test_task_collection_custom( source="source3", package_root=package_root, package_name=None, - version=None, ) res = await client.post( f"{PREFIX}/collect/custom/", json=payload_root.dict() diff --git a/tests/v2/03_api/test_api_task_collection_ssh.py b/tests/v2/03_api/test_api_task_collection_ssh.py index ac88b5918b..8912f6d6c0 100644 --- a/tests/v2/03_api/test_api_task_collection_ssh.py +++ b/tests/v2/03_api/test_api_task_collection_ssh.py @@ -270,9 +270,12 @@ async def test_task_collection_ssh_from_wheel( f"{PREFIX}/collect/pip/", json=dict( package=remote_wheel_path, - version="1.2.3", + package_version="1.2.3", python_version=current_py_version, ), ) assert res.status_code == 422 - debug(res.json()) + error_msg = ( + "Cannot provide package version when package " "is a wheel file." + ) + assert error_msg in str(res.json()["detail"])