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

Issue:
Deprecate obsolete function `workflow_query_job_status`



Discussion / hints:

Fix patch:
diff --git a/fractal/cmd/__init__.py b/fractal/cmd/__init__.py
index e5fe8904f..458b827b8 100644
--- a/fractal/cmd/__init__.py
+++ b/fractal/cmd/__init__.py
@@ -14,7 +14,7 @@
 from ._dataset import dataset_show
 from ._job import job_download_logs
 from ._job import job_list
-from ._job import job_status
+from ._job import job_show
 from ._project import project_add_dataset
 from ._project import project_create
 from ._project import project_delete
@@ -193,8 +193,8 @@ async def job(
 ) -> BaseInterface:
     if subcmd == "list":
         iface = await job_list(client, batch=batch, **kwargs)
-    elif subcmd == "status":
-        iface = await job_status(client, batch=batch, **kwargs)
+    elif subcmd == "show":
+        iface = await job_show(client, batch=batch, **kwargs)
     elif subcmd == "download-logs":
         iface = await job_download_logs(client, **kwargs)
     else:
diff --git a/fractal/cmd/_job.py b/fractal/cmd/_job.py
index 3b176481f..ea390e837 100644
--- a/fractal/cmd/_job.py
+++ b/fractal/cmd/_job.py
@@ -15,7 +15,7 @@
 from ..response import check_response
 
 
-async def job_status(
+async def job_show(
     client: AuthClient,
     job_id: int,
     batch: bool = False,
diff --git a/fractal/cmd/_workflow.py b/fractal/cmd/_workflow.py
index 12a0df5a8..fd3103bcc 100644
--- a/fractal/cmd/_workflow.py
+++ b/fractal/cmd/_workflow.py
@@ -20,35 +20,6 @@
 from .utils import get_cached_task_by_name
 
 
-async def workflow_query_job_status(
-    client: AuthClient,
-    job_id: int,
-    batch: bool = False,
-    do_not_separate_logs: bool = False,
-    **kwargs,
-) -> BaseInterface:
-    """
-    Query the status of a workflow job
-    """
-
-    res = await client.get(f"{settings.BASE_URL}/job/{job_id}")
-    job = check_response(
-        res, expected_status_code=200, coerce=ApplyWorkflowRead
-    )
-    if batch:
-        return PrintInterface(retcode=0, data=job.status)
-    else:
-        data = job.sanitised_dict()
-        if do_not_separate_logs or (job.log is None):
-            return RichJsonInterface(retcode=0, data=data)
-        else:
-            log = data.pop("log")
-            extra_lines = ["\nThis is the job log:\n", log]
-            return RichJsonInterface(
-                retcode=0, data=data, extra_lines=extra_lines
-            )
-
-
 async def workflow_new(
     client: AuthClient,
     name: str,
diff --git a/fractal/parser.py b/fractal/parser.py
index 712786b27..05a5ddd5a 100644
--- a/fractal/parser.py
+++ b/fractal/parser.py
@@ -484,17 +484,17 @@
     help="Project ID",
 )
 
-# job status
-job_status_parser = job_subparsers.add_parser(
-    "status",
+# job show
+job_show_parser = job_subparsers.add_parser(
+    "show",
     description="Query status of workflow-execution job",
     argument_default=ap.SUPPRESS,
 )
-job_status_parser.add_argument(
+job_show_parser.add_argument(
     "job_id",
     help="ID of the job",
 )
-job_status_parser.add_argument(
+job_show_parser.add_argument(
     "--do-not-separate-logs",
     dest="do_not_separate_logs",
     help="Show the job logs in the main output, instead of a separate field",


Test patch:
diff --git a/tests/test_job.py b/tests/test_job.py
index 6ffe86849..f2dfebc18 100644
--- a/tests/test_job.py
+++ b/tests/test_job.py
@@ -8,7 +8,7 @@
 
 
 @pytest.mark.parametrize("status", ["done", "failed"])
-async def test_job_status(
+async def test_job_show(
     register_user,
     invoke,
     tmp_path: Path,
@@ -18,7 +18,7 @@ async def test_job_status(
 ):
     """
     GIVEN a job entry in the database
-    WHEN calling the `job status` command with multiple options
+    WHEN calling the `job show` command with multiple options
     THEN the client response has the expected status and log attributes
     """
 
@@ -36,8 +36,8 @@ async def test_job_status(
     )
     debug(job)
 
-    # Check `job status` output
-    cmd = f"job status {job.id}"
+    # Check `job show` output
+    cmd = f"job show {job.id}"
     debug(cmd)
     res = await invoke(cmd)
     assert res.retcode == 0
@@ -50,15 +50,15 @@ async def test_job_status(
         assert LOG in res.extra_lines
         res.show()
 
-    # Check `job status` output with --batch
-    cmd = f"--batch job status {job.id}"
+    # Check `job show` output with --batch
+    cmd = f"--batch job show {job.id}"
     res = await invoke(cmd)
     assert res.retcode == 0
     assert res.data == status
 
-    # Check `job status` output with `--do-not-separate-logs`
+    # Check `job show` output with `--do-not-separate-logs`
     if status == "failed":
-        cmd = f"job status {job.id} --do-not-separate-logs"
+        cmd = f"job show {job.id} --do-not-separate-logs"
         res = await invoke(cmd)
         debug(res.data)
         assert res.retcode == 0
@@ -101,7 +101,7 @@ async def test_job_list(
     debug(job1)
     debug(job2)
 
-    # Check `job status` output with --batch option
+    # Check `job list` output with --batch option
     cmd = f"--batch job list {project_id}"
     debug(cmd)
     res = await invoke(cmd)
@@ -111,7 +111,7 @@ async def test_job_list(
     assert job1.id in job_ids
     assert job2.id in job_ids
 
-    # Check `job status` output
+    # Check `job list` output
     cmd = f"job list {project_id}"
     debug(cmd)
     res = await invoke(cmd)
diff --git a/tests/test_workflow.py b/tests/test_workflow.py
index 9fc73512a..a0c01e8f9 100644
--- a/tests/test_workflow.py
+++ b/tests/test_workflow.py
@@ -435,10 +435,10 @@ async def test_workflow_apply(
     assert res.retcode == 0
     assert res.data["status"] == "submitted"
 
-    # TODO: add an assertion about the output, instead of calling `job status`
+    # TODO: add an assertion about the output, instead of calling `job show`
 
     # Check that job completed successfully
-    cmd = f"job status {job_id}"
+    cmd = f"job show {job_id}"
     starting_time = time.perf_counter()
     debug(cmd)
     while True:
@@ -470,7 +470,7 @@ async def test_workflow_apply(
     job_id = res.data["id"]
 
     # Verify that status is failed, and that there is a log
-    cmd = f"job status {job_id} --do-not-separate-logs"
+    cmd = f"job show {job_id} --do-not-separate-logs"
     starting_time = time.perf_counter()
     while True:
         res = await invoke(cmd)