Skip to content

Commit

Permalink
Merge pull request #1998 from fractal-analytics-platform/1945-replace…
Browse files Browse the repository at this point in the history
…-the-two-args_schema-query-parameters-in-get-apiv2task-with-just-one

Replace the two args_schema query parameters in `GET /api/v2/task/` with just one
  • Loading branch information
tcompa authored Nov 4, 2024
2 parents 878a14e + 43ff665 commit 32781a1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 19 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Now `pip install` uses `--no-cache` (\#1980).
* API
* Deprecate the `verbose` query parameter in `GET /api/v2/task/collect/{state_id}/` (\#1980).
* Combine the `args_schema_parallel` and `args_schema_non_parallel` query parameters in `GET /api/v2/task/` into a single parameter `args_schema` (\#1998).

# 2.7.1

Expand Down Expand Up @@ -80,9 +81,9 @@
* Stop logging warnings for non-common tasks in workflow export (\#1893).
* Drop `WorkflowTaskCreateV2.order` (\#1906).
* Update endpoints for workflow import/export (\#1925, \#1939, \#1960).
* Datasets
* Datasets:
* Remove `TaskDumpV2.owner` attribute (\#1909).
* Jobs
* Jobs:
* Prevent job submission if includes non-active or non-accessible tasks (\#1817).
* Remove rate limit for `POST /project/{project_id}/job/submit/` (\#1944).
* Admin:
Expand Down
7 changes: 2 additions & 5 deletions fractal_server/app/routes/api/v2/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@

@router.get("/", response_model=list[TaskReadV2])
async def get_list_task(
args_schema_parallel: bool = True,
args_schema_non_parallel: bool = True,
args_schema: bool = True,
category: Optional[str] = None,
modality: Optional[str] = None,
author: Optional[str] = None,
Expand Down Expand Up @@ -72,11 +71,9 @@ async def get_list_task(
res = await db.execute(stm)
task_list = res.scalars().all()
await db.close()
if args_schema_parallel is False:
if args_schema is False:
for task in task_list:
setattr(task, "args_schema_parallel", None)
if args_schema_non_parallel is False:
for task in task_list:
setattr(task, "args_schema_non_parallel", None)

return task_list
Expand Down
13 changes: 1 addition & 12 deletions tests/v2/03_api/test_api_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,7 @@ async def test_task_get_list(
assert data[2]["args_schema_non_parallel"] == dict(a=1)
assert data[2]["args_schema_parallel"] == dict(b=2)

res = await client.get(f"{PREFIX}/?args_schema_non_parallel=false")
assert res.json()[2]["args_schema_non_parallel"] is None
assert res.json()[2]["args_schema_parallel"] == dict(b=2)

res = await client.get(f"{PREFIX}/?args_schema_parallel=false")
assert res.json()[2]["args_schema_non_parallel"] == dict(a=1)
assert res.json()[2]["args_schema_parallel"] is None

res = await client.get(
f"{PREFIX}/"
"?args_schema_parallel=false&args_schema_non_parallel=False"
)
res = await client.get(f"{PREFIX}/?args_schema=false")
assert res.json()[2]["args_schema_non_parallel"] is None
assert res.json()[2]["args_schema_parallel"] is None

Expand Down

0 comments on commit 32781a1

Please sign in to comment.