Repository: fractal-analytics-platform/fractal-client (language: python)

Issue:
Review `workflow add-task` after server updates
Ref:
* https://github.com/fractal-analytics-platform/fractal-server/pull/421
* https://github.com/fractal-analytics-platform/fractal-server/issues/400
* #374
Review `workflow add-task` after server updates
Ref:
* https://github.com/fractal-analytics-platform/fractal-server/pull/421
* https://github.com/fractal-analytics-platform/fractal-server/issues/400
* #374


Discussion / hints:

Fix patch:
diff --git a/fractal/cmd/_workflow.py b/fractal/cmd/_workflow.py
index 2f0ddce47..12a0df5a8 100644
--- a/fractal/cmd/_workflow.py
+++ b/fractal/cmd/_workflow.py
@@ -141,16 +141,14 @@ async def workflow_add_task(
         f"{settings.BASE_URL}/workflow/{workflow_id}/add-task/",
         json=workflow_task.dict(),
     )
-    workflow = check_response(
-        res, expected_status_code=201, coerce=WorkflowRead
+    workflow_task = check_response(
+        res, expected_status_code=201, coerce=WorkflowTaskRead
     )
 
     if batch:
-        return PrintInterface(
-            retcode=0, data=f"Added task {task_id} to workflow {workflow.id}"
-        )
+        return PrintInterface(retcode=0, data=str(workflow_task.id))
     else:
-        return RichJsonInterface(retcode=0, data=workflow.dict())
+        return RichJsonInterface(retcode=0, data=workflow_task.dict())
 
 
 async def workflow_edit_task(
diff --git a/poetry.lock b/poetry.lock
index 08e35c90c..955849cac 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -594,14 +594,14 @@ sqlmodel = "*"
 
 [[package]]
 name = "fractal-server"
-version = "1.0.0b12"
+version = "1.0.0rc0"
 description = "Server component of the Fractal analytics platform"
 category = "dev"
 optional = false
 python-versions = ">=3.8,<4.0"
 files = [
-    {file = "fractal_server-1.0.0b12-py3-none-any.whl", hash = "sha256:103f4e9c9b8a1f7152574f90fcf454746ffd138f9c628428973bd9f0ff4acd36"},
-    {file = "fractal_server-1.0.0b12.tar.gz", hash = "sha256:20400accb76432e523c7db5760a701afb0931bc89d483f73a919f760ddd6da70"},
+    {file = "fractal_server-1.0.0rc0-py3-none-any.whl", hash = "sha256:3a6bfcf8b31c6e8dae2eae02b52857d550049b69290ecf8ec64a4ccfde054ee9"},
+    {file = "fractal_server-1.0.0rc0.tar.gz", hash = "sha256:50abc954c24f13bd757e69ca9bdc6ff1afc190c4b73fcf558a1ff1261b810b06"},
 ]
 
 [package.dependencies]
@@ -618,7 +618,7 @@ uvicorn = ">=0.18.2,<0.19.0"
 [package.extras]
 gunicorn = ["gunicorn (>=20.1.0,<21.0.0)"]
 postgres = ["asyncpg (>=0.27.0,<0.28.0)", "psycopg2 (>=2.9.5,<3.0.0)"]
-slurm = ["clusterfutures (>=0.4,<0.5)"]
+slurm = ["clusterfutures (==0.4)"]
 
 [[package]]
 name = "greenlet"
@@ -730,14 +730,14 @@ socks = ["socksio (>=1.0.0,<2.0.0)"]
 
 [[package]]
 name = "httpx"
-version = "0.23.2"
+version = "0.23.3"
 description = "The next generation HTTP client."
 category = "main"
 optional = false
 python-versions = ">=3.7"
 files = [
-    {file = "httpx-0.23.2-py3-none-any.whl", hash = "sha256:106cded342a44e443060fab70ef327139248c61939e77d73964560c8d8b57069"},
-    {file = "httpx-0.23.2.tar.gz", hash = "sha256:e824a6fa18ffaa6423c6f3a32d5096fc15bd8dff43663a223f06242fc69451a8"},
+    {file = "httpx-0.23.3-py3-none-any.whl", hash = "sha256:a211fcce9b1254ea24f0cd6af9869b3d29aba40154e947d2a07bb499b3e310d6"},
+    {file = "httpx-0.23.3.tar.gz", hash = "sha256:9818458eb565bb54898ccb9b8b251a28785dd4a55afbc23d0eb410754fe7d0f9"},
 ]
 
 [package.dependencies]
@@ -1858,4 +1858,4 @@ testing = ["flake8 (<5)", "func-timeout", "jaraco.functools", "jaraco.itertools"
 [metadata]
 lock-version = "2.0"
 python-versions = "^3.8"
-content-hash = "f1d10619536f2e4057aeb2e8d9ca9c3c7ffa89917a559a66e3cea9d6403f4ef8"
+content-hash = "a6b89efe12010fe29cbf4c8591eb0ff0b825c06156c37bd33c71ce8082f8d0b0"
diff --git a/pyproject.toml b/pyproject.toml
index 9d303dd75..57aade453 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -29,7 +29,7 @@ pytest = "^7.1.2"
 bumpver = "^2022.1118"
 pytest-asyncio = "^0.19.0"
 # fractal-server = "^1.0.0"
-fractal-server = ">=1.0.0b12"
+fractal-server = ">=1.0.0rc0"
 coverage = {extras = ["toml"], version = "^6.5.0"}
 
 [tool.poetry.group.docs.dependencies]


Test patch:
diff --git a/tests/test_workflow.py b/tests/test_workflow.py
index 4e390d35a..9fc73512a 100644
--- a/tests/test_workflow.py
+++ b/tests/test_workflow.py
@@ -157,14 +157,17 @@ async def test_workflow_add_task(
 ):
     """
     GIVEN a workflow
-    WHEN the client is invoked to add a task, including custom args
+    WHEN
+        the client is invoked to add a task, with several different options
+        (custom args, custom meta, --batch)
     THEN
-        the WorkflowTask is correctly registered in the db, including custom
-        args
+        the WorkflowTask's are correctly registered in the db, and the returned
+        object has the right properties
     """
     wf = await workflow_factory()
     t = await task_factory()
 
+    # Add a WorkflowTask with --args-file and --meta-file arguments
     ARGS = {"arg": "arg_value"}
     META = {"executor": "some-executor"}
     args_file = tmp_path / "args_file.json"
@@ -173,7 +176,6 @@ async def test_workflow_add_task(
     meta_file = tmp_path / "meta_file.json"
     with meta_file.open("w") as f:
         json.dump(META, f)
-
     cmd = (
         f"workflow add-task {wf.id} {t.id} "
         f"--args-file {args_file} --meta-file {meta_file}"
@@ -181,18 +183,28 @@ async def test_workflow_add_task(
     debug(cmd)
     res = await invoke(cmd)
     assert res.retcode == 0
-    debug(res.data)
-    assert res.data["task_list"][0]["args"] == ARGS
-    assert res.data["task_list"][0]["meta"] == META
+    workflow_task = res.data
+    workflow_task_id_1 = workflow_task["id"]
+    debug(workflow_task)
+    assert workflow_task["args"] == ARGS
+    assert workflow_task["meta"] == META
 
+    # Add a WorkflowTask with the --batch option
     cmd = f"--batch workflow add-task {wf.id} {t.id}"
     debug(cmd)
     res = await invoke(cmd)
     assert res.retcode == 0
     debug(res.data)
-    # Note: this check will change if we include some actual information (e.g.
-    # a WorkflowTask id) in the --batch case
-    assert res.data.startswith("Added")
+    workflow_task_id_2 = int(res.data)
+
+    # Check that the WorkflowTask's in Workflow.task_list have the correct IDs
+    cmd = f"workflow show {wf.id}"
+    res = await invoke(cmd)
+    assert res.retcode == 0
+    workflow = res.data
+    debug(workflow)
+    list_IDs = [wftask["id"] for wftask in workflow["task_list"]]
+    assert list_IDs == [workflow_task_id_1, workflow_task_id_2]
 
 
 async def test_workflow_add_task_by_name(
@@ -216,9 +228,8 @@ async def test_workflow_add_task_by_name(
     debug(cmd)
     res = await invoke(cmd)
     assert res.retcode == 0
-    debug(res)
     debug(res.data)
-    assert res.data["task_list"][0]["id"] == task.id
+    assert res.data["task"]["id"] == task.id
 
 
 async def test_task_cache_with_non_unique_names(
@@ -276,7 +287,7 @@ async def test_workflow_rm_task(
     assert res.retcode == 0
     res = await invoke(cmd)
     assert res.retcode == 0
-    workflow_task_id_1 = res.data["task_list"][0]["id"]
+    workflow_task_id_1 = res.data["id"]
 
     # Remove task 1 from workflow
     cmd = f"workflow rm-task {wf.id} {workflow_task_id_1}"
@@ -321,7 +332,7 @@ async def test_workflow_edit_task(
 
     # Edit workflow task
     debug(res.data)
-    workflow_task_id = res.data["task_list"][0]["id"]
+    workflow_task_id = res.data["id"]
     cmd = (
         f"workflow edit-task {wf.id} {workflow_task_id} "
         f"--args-file {args_file} --meta-file {meta_file}"
@@ -410,7 +421,7 @@ async def test_workflow_apply(
     res = await invoke(f"workflow add-task {workflow_id} {TASK_ID}")
     assert res.retcode == 0
     debug(res.data)
-    TASK_NAME = res.data["task_list"][0]["task"]["name"]
+    TASK_NAME = res.data["task"]["name"]
     debug(TASK_NAME)
 
     cmd = (