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

Issue:
Support project_dir, deprecate cache_dir
Ref https://github.com/fractal-analytics-platform/fractal-server/pull/2121


Discussion / hints:

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 86aa6802..c3c1142c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,10 @@
 * Update versions of pre-commit hooks and add precommit GitHub Action (\#757).
 
 
+# 2.5.1
+
+* Deprecate user `cache_dir` , to align with [fractal-server 2.9.2](https://github.com/fractal-analytics-platform/fractal-server/blob/main/CHANGELOG.md#292) (\#758).
+
 # 2.5.0
 
 * Update task-collection commands, to align with [fractal-server 2.9.0](https://github.com/fractal-analytics-platform/fractal-server/blob/main/CHANGELOG.md#290) (\#738).
diff --git a/fractal_client/cmd/__init__.py b/fractal_client/cmd/__init__.py
index 3a8690a2..78bfe1b5 100644
--- a/fractal_client/cmd/__init__.py
+++ b/fractal_client/cmd/__init__.py
@@ -330,7 +330,6 @@ def user(
         parameters = [
             "new_email",
             "new_password",
-            "cache_dir",
             "slurm_user",
             "project_dir",
             "username",
@@ -352,7 +351,6 @@ def user(
             "new_password",
             "new_username",
             "new_slurm_user",
-            "new_cache_dir",
             "new_project_dir",
             "new_ssh_settings_json",
             "make_superuser",
diff --git a/fractal_client/cmd/_user.py b/fractal_client/cmd/_user.py
index e925ee1a..0e759714 100644
--- a/fractal_client/cmd/_user.py
+++ b/fractal_client/cmd/_user.py
@@ -44,7 +44,6 @@ def user_register(
     new_email: str,
     new_password: str,
     slurm_user: str | None = None,
-    cache_dir: str | None = None,
     project_dir: str | None = None,
     username: str | None = None,
     ssh_settings_json: str | None = None,
@@ -62,8 +61,6 @@ def user_register(
     new_settings = dict()
     if slurm_user:
         new_settings["slurm_user"] = slurm_user
-    if cache_dir:
-        new_settings["cache_dir"] = cache_dir
     if project_dir:
         new_settings["project_dir"] = project_dir
     if ssh_settings_json is not None:
@@ -130,7 +127,6 @@ def user_edit(
     new_password: str | None = None,
     new_username: str | None = None,
     new_slurm_user: str | None = None,
-    new_cache_dir: str | None = None,
     new_project_dir: str | None = None,
     new_ssh_settings_json: str | None = None,
     make_superuser: bool = False,
@@ -165,8 +161,6 @@ def user_edit(
         user_update["is_verified"] = False
     if new_username is not None:
         user_update["username"] = new_username
-    if new_cache_dir is not None:
-        settings_update["cache_dir"] = new_cache_dir
     if new_slurm_user is not None:
         settings_update["slurm_user"] = new_slurm_user
     if new_project_dir is not None:
diff --git a/fractal_client/parser.py b/fractal_client/parser.py
index 1e0f482f..d6c6ddce 100644
--- a/fractal_client/parser.py
+++ b/fractal_client/parser.py
@@ -783,14 +783,6 @@
 user_register_parser.add_argument(
     "new_password", help="Password for the new user."
 )
-user_register_parser.add_argument(
-    "--cache-dir",
-    help=(
-        "User's cache directory absolute path "
-        "(necessary for workflow execution when using the SLURM backend)."
-    ),
-    required=False,
-)
 user_register_parser.add_argument(
     "--project-dir",
     help="User-writeable base folder, used e.g. for default `zarr_dir` paths.",
@@ -857,14 +849,6 @@
 user_edit_parser.add_argument(
     "--new-username", help="New user username.", required=False
 )
-user_edit_parser.add_argument(
-    "--new-cache-dir",
-    help=(
-        "New user's cache directory absolute path "
-        "(necessary for workflow execution when using the SLURM backend)."
-    ),
-    required=False,
-)
 user_edit_parser.add_argument(
     "--new-project-dir",
     help="New value of `project_dir`.",
diff --git a/poetry.lock b/poetry.lock
index 3d12c612..643d5b24 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -1,4 +1,4 @@
-# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand.
+# This file is automatically @generated by Poetry 1.8.4 and should not be changed by hand.
 
 [[package]]
 name = "alembic"


Test patch:
diff --git a/tests/fixtures_testserver.py b/tests/fixtures_testserver.py
index 0b80db4b..f6bb2715 100644
--- a/tests/fixtures_testserver.py
+++ b/tests/fixtures_testserver.py
@@ -214,14 +214,14 @@ def user_factory(invoke_as_superuser):
     def __user_factory(
         email: str,
         password: str,
-        cache_dir: str | None = None,
+        project_dir: str | None = None,
         slurm_user: str | None = None,
         username: str | None = None,
         superuser: bool = False,
     ):
         cmd = "user register"
-        if cache_dir is not None:
-            cmd += f" --cache-dir {cache_dir}"
+        if project_dir is not None:
+            cmd += f" --project-dir {project_dir}"
         if slurm_user is not None:
             cmd += f" --slurm-user {slurm_user}"
         if username is not None:
diff --git a/tests/test_user.py b/tests/test_user.py
index ea5e4c59..740ac5e7 100644
--- a/tests/test_user.py
+++ b/tests/test_user.py
@@ -29,7 +29,7 @@ def test_register_as_superuser(
     else:
         res = invoke_as_superuser(
             f"user register {EMAIL_USER} {PWD_USER} "
-            "--slurm-user SOMETHING --cache-dir /absolute --username X"
+            "--slurm-user SOMETHING --username X"
         )
         debug(res.data)
         assert res.retcode == 0
@@ -178,7 +178,6 @@ def test_edit_as_superuser(
     user_id = res.data["id"]
     # Call fractal user edit
     NEW_EMAIL = f"{new_name()}@example.org"
-    NEW_CACHE_DIR = "/tmp/xxx"
     NEW_SLURM_USER = "new_slurm"
     NEW_USERNAME = "new_username"
     cmd = (
@@ -187,7 +186,6 @@ def test_edit_as_superuser(
         f"--new-password SOMETHING "
         f"--new-slurm-user {NEW_SLURM_USER} "
         f"--new-username {NEW_USERNAME} "
-        f"--new-cache-dir {NEW_CACHE_DIR}"
     )
     if new_is_superuser:
         cmd = f"{cmd} --make-superuser"
@@ -210,7 +208,6 @@ def test_edit_as_superuser(
             if new_is_verified
             else not res.data["is_verified"]
         )
-        assert res.data["settings"]["cache_dir"] == NEW_CACHE_DIR
         assert res.data["settings"]["slurm_user"] == NEW_SLURM_USER
     else:
         res = invoke_as_superuser(cmd)
@@ -220,11 +217,6 @@ def test_edit_as_superuser(
             "`--remove-verified`"
         )
 
-    BAD_CACHE_DIR = "not_absolute"
-    with pytest.raises(SystemExit):
-        cmd = f"user edit {user_id} --new-cache-dir {BAD_CACHE_DIR}"
-        invoke_as_superuser(cmd)
-
     # If the user was made a superuser, check that we can go back to normal
     # user
     if new_is_superuser:
@@ -257,7 +249,6 @@ def test_edit_user_settings(invoke_as_superuser, tmp_path, new_name):
         "ssh_jobs_dir": None,
         "slurm_user": None,
         "slurm_accounts": [],
-        "cache_dir": None,
         "project_dir": None,
     }
     SSH_HOST = "something.somewhere"
@@ -271,7 +262,6 @@ def test_edit_user_settings(invoke_as_superuser, tmp_path, new_name):
         "ssh_jobs_dir": None,
         "slurm_user": None,
         "slurm_accounts": [],
-        "cache_dir": None,
         "project_dir": NEW_PROJECT_DIR,
     }