Skip to content

Commit

Permalink
Merge branch 'main' into 1845-allow-deleting-a-usergroup-apart-from-t…
Browse files Browse the repository at this point in the history
…he-default-all-one
  • Loading branch information
ychiucco committed Oct 10, 2024
2 parents 89f78d6 + 993df2f commit 79bf2fb
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 25 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
12 changes: 3 additions & 9 deletions fractal_server/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down Expand Up @@ -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.
"""
Expand Down Expand Up @@ -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():
Expand All @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion fractal_server/app/schemas/v2/task_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -24,7 +25,7 @@ class CollectionStatusV2(str, Enum):
OK = "OK"


class TaskCollectPipV2(BaseModel):
class TaskCollectPipV2(BaseModel, extra=Extra.forbid):
"""
TaskCollectPipV2 class
Expand Down
12 changes: 1 addition & 11 deletions fractal_server/data_migrations/2_7_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand All @@ -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")

Expand All @@ -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")
2 changes: 0 additions & 2 deletions tests/v2/03_api/test_api_task_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
7 changes: 5 additions & 2 deletions tests/v2/03_api/test_api_task_collection_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

0 comments on commit 79bf2fb

Please sign in to comment.