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

Issue:
Remove references of users setting their slurm user account
With the new fractal register command (i.e. https://github.com/fractal-analytics-platform/fractal/issues/395), slurm account association is done by the admin. Is it correct that the user can't control this anymore, i.e. a user can't overwrite that slurm submissions are made in the name of another user (see https://github.com/fractal-analytics-platform/fractal-server/issues/129)?

If yes, we should remove the references to users setting their slurm user from here https://fractal-analytics-platform.github.io/fractal/install.html and here https://fractal-analytics-platform.github.io/fractal/cli.html
And we should clean up the fractal help message:

fractal --help gives
```
(fractal-client-1.0.1) bash-4.4$ fractal --help
usage: fractal [-h] [-u USER] [-p PASSWORD] [-s SLURM_USER] [--verbose] [--batch] [-j]
               {project,dataset,task,workflow,job,version,user} ...

Command-line interface for Fractal Client

optional arguments:
  -h, --help            show this help message and exit
  -u USER, --user USER  User email address for login (overrides configuration file)
  -p PASSWORD, --password PASSWORD
                        User password (overrides configuration file)
  -s SLURM_USER, --slurm-user SLURM_USER
                        SLURM user
  --verbose, -v         Change minimal logging level from default to DEBUG
  --batch               Return output suitable for scripting, e.g., only the ID of items created instead of the full
                        object.
  -j, --json            Output raw json

Commands::
  {project,dataset,task,workflow,job,version,user}
```

But the user shouldn't be setting the SLURM_USER anymore.

If it's still possible for a user to overwrite this via the client, we should remove this ability.
Remove references of users setting their slurm user account
With the new fractal register command (i.e. https://github.com/fractal-analytics-platform/fractal/issues/395), slurm account association is done by the admin. Is it correct that the user can't control this anymore, i.e. a user can't overwrite that slurm submissions are made in the name of another user (see https://github.com/fractal-analytics-platform/fractal-server/issues/129)?

If yes, we should remove the references to users setting their slurm user from here https://fractal-analytics-platform.github.io/fractal/install.html and here https://fractal-analytics-platform.github.io/fractal/cli.html
And we should clean up the fractal help message:

fractal --help gives
```
(fractal-client-1.0.1) bash-4.4$ fractal --help
usage: fractal [-h] [-u USER] [-p PASSWORD] [-s SLURM_USER] [--verbose] [--batch] [-j]
               {project,dataset,task,workflow,job,version,user} ...

Command-line interface for Fractal Client

optional arguments:
  -h, --help            show this help message and exit
  -u USER, --user USER  User email address for login (overrides configuration file)
  -p PASSWORD, --password PASSWORD
                        User password (overrides configuration file)
  -s SLURM_USER, --slurm-user SLURM_USER
                        SLURM user
  --verbose, -v         Change minimal logging level from default to DEBUG
  --batch               Return output suitable for scripting, e.g., only the ID of items created instead of the full
                        object.
  -j, --json            Output raw json

Commands::
  {project,dataset,task,workflow,job,version,user}
```

But the user shouldn't be setting the SLURM_USER anymore.

If it's still possible for a user to overwrite this via the client, we should remove this ability.
Remove references of users setting their slurm user account
With the new fractal register command (i.e. https://github.com/fractal-analytics-platform/fractal/issues/395), slurm account association is done by the admin. Is it correct that the user can't control this anymore, i.e. a user can't overwrite that slurm submissions are made in the name of another user (see https://github.com/fractal-analytics-platform/fractal-server/issues/129)?

If yes, we should remove the references to users setting their slurm user from here https://fractal-analytics-platform.github.io/fractal/install.html and here https://fractal-analytics-platform.github.io/fractal/cli.html
And we should clean up the fractal help message:

fractal --help gives
```
(fractal-client-1.0.1) bash-4.4$ fractal --help
usage: fractal [-h] [-u USER] [-p PASSWORD] [-s SLURM_USER] [--verbose] [--batch] [-j]
               {project,dataset,task,workflow,job,version,user} ...

Command-line interface for Fractal Client

optional arguments:
  -h, --help            show this help message and exit
  -u USER, --user USER  User email address for login (overrides configuration file)
  -p PASSWORD, --password PASSWORD
                        User password (overrides configuration file)
  -s SLURM_USER, --slurm-user SLURM_USER
                        SLURM user
  --verbose, -v         Change minimal logging level from default to DEBUG
  --batch               Return output suitable for scripting, e.g., only the ID of items created instead of the full
                        object.
  -j, --json            Output raw json

Commands::
  {project,dataset,task,workflow,job,version,user}
```

But the user shouldn't be setting the SLURM_USER anymore.

If it's still possible for a user to overwrite this via the client, we should remove this ability.


Discussion / hints:
> Is it correct that the user can't control this anymore, i.e. a user can't overwrite that slurm submissions are made in the name of another user (see https://github.com/fractal-analytics-platform/fractal-server/issues/129)?

It is correct, indeed.

> If yes, we should remove the references to users setting their slurm user from here https://fractal-analytics-platform.github.io/fractal/install.html and here https://fractal-analytics-platform.github.io/fractal/cli.html

Agreed.

To do:
- [ ] Fix "install" page in docs 
- [ ] Fix arguments of fractal cli command (cli docs are fixed automatically)
- [ ] Update changelog.

> If it's still possible for a user to overwrite this via the client, we should remove this ability.

It is not, unless you are a superuser. In that case, the fractal user register and fractal user edit commands already have the right arguments/docs:
* https://fractal-analytics-platform.github.io/fractal/cli_files/user.html#register
* https://fractal-analytics-platform.github.io/fractal/cli_files/user.html#edit
> Is it correct that the user can't control this anymore, i.e. a user can't overwrite that slurm submissions are made in the name of another user (see https://github.com/fractal-analytics-platform/fractal-server/issues/129)?

It is correct, indeed.

> If yes, we should remove the references to users setting their slurm user from here https://fractal-analytics-platform.github.io/fractal/install.html and here https://fractal-analytics-platform.github.io/fractal/cli.html

Agreed.

To do:
- [ ] Fix "install" page in docs 
- [ ] Fix arguments of fractal cli command (cli docs are fixed automatically)
- [ ] Update changelog.

> If it's still possible for a user to overwrite this via the client, we should remove this ability.

It is not, unless you are a superuser. In that case, the fractal user register and fractal user edit commands already have the right arguments/docs:
* https://fractal-analytics-platform.github.io/fractal/cli_files/user.html#register
* https://fractal-analytics-platform.github.io/fractal/cli_files/user.html#edit
> Is it correct that the user can't control this anymore, i.e. a user can't overwrite that slurm submissions are made in the name of another user (see https://github.com/fractal-analytics-platform/fractal-server/issues/129)?

It is correct, indeed.

> If yes, we should remove the references to users setting their slurm user from here https://fractal-analytics-platform.github.io/fractal/install.html and here https://fractal-analytics-platform.github.io/fractal/cli.html

Agreed.

To do:
- [ ] Fix "install" page in docs 
- [ ] Fix arguments of fractal cli command (cli docs are fixed automatically)
- [ ] Update changelog.

> If it's still possible for a user to overwrite this via the client, we should remove this ability.

It is not, unless you are a superuser. In that case, the fractal user register and fractal user edit commands already have the right arguments/docs:
* https://fractal-analytics-platform.github.io/fractal/cli_files/user.html#register
* https://fractal-analytics-platform.github.io/fractal/cli_files/user.html#edit

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6de753bca..6abc82f58 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+# 1.0.2
+
+* Remove obsolete references to SLURM user, either as a CLI argument or an environment variable (\#419).
+
 # 1.0.1
 
 * Make `FRACTAL_USER/FRACTAL_PASSWORD` env variables optional (\#416).
diff --git a/docs/source/contribute.md b/docs/source/contribute.md
index 985a905f3..378714fee 100644
--- a/docs/source/contribute.md
+++ b/docs/source/contribute.md
@@ -46,14 +46,6 @@ its dependencies, including development dependencies.
 Note that to run commands from within this environment you should prepend them
 with `poetry run`, as in `poetry run fractalctl start`.
 
-To install Fractal Server with some additional extras, use the [`-E`
-option](https://python-poetry.org/docs/pyproject/#extras), as in
-```
-poetry install -E slurm
-poetry install -E slurm -E postgres
-poetry install --all-extras
-```
-
 It may sometimes be useful to use a different Python interpreter from the one
 installed in your system. To this end we suggest using
 [pyenv](https://github.com/pyenv/pyenv). In the project folder, invoking
diff --git a/docs/source/install.md b/docs/source/install.md
index 933d2ca29..2e95d6589 100644
--- a/docs/source/install.md
+++ b/docs/source/install.md
@@ -17,8 +17,6 @@ the following environment variables:
 * `FRACTAL_SERVER`: fully qualified URL to the Fractal server installation
 * `FRACTAL_USER`, `FRACTAL_PASSWORD`: email and password used to log-in to the
    Fractal server.
-* `SLURM_USER`: name of the user on the SLURM cluster (only for when the
-  Fractal Server is running with a SLURM backend).
 
 By default, `fractal` caches some information in `~/.cache/fractal`. This destination
 can be customized by setting `FRACTAL_CACHE_PATH`.
@@ -29,6 +27,5 @@ variables.  An example of such file is
 ```
 FRACTAL_USER=user@something.com
 FRACTAL_PASSWORD=myuser
-SLURM_USER=myslurmuser
 FRACTAL_SERVER=http://localhost:8010
 ```
diff --git a/fractal/config.py b/fractal/config.py
index 3383b1ee1..819186836 100644
--- a/fractal/config.py
+++ b/fractal/config.py
@@ -39,7 +39,6 @@ class Settings(BaseSettings):
 
     FRACTAL_USER: Optional[str] = getenv("FRACTAL_USER")
     FRACTAL_PASSWORD: Optional[str] = getenv("FRACTAL_PASSWORD")
-    SLURM_USER: Optional[str] = getenv("SLURM_USER")
 
     FRACTAL_SERVER: str = getenv("FRACTAL_SERVER", "http://localhost:8000")
 
diff --git a/fractal/parser.py b/fractal/parser.py
index b88080378..d6cb976f9 100644
--- a/fractal/parser.py
+++ b/fractal/parser.py
@@ -28,7 +28,6 @@
 parser_main.add_argument(
     "-p", "--password", help="User password (overrides configuration file)"
 )
-parser_main.add_argument("-s", "--slurm-user", help="SLURM user")
 parser_main.add_argument(
     "--verbose",
     "-v",


Test patch:
diff --git a/tests/conftest.py b/tests/conftest.py
index 2a4c77e06..f8de6c8fb 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -11,7 +11,6 @@
 environ["FRACTAL_PASSWORD"] = "password"
 environ["FRACTAL_SERVER"] = "http://127.0.0.1:10080"
 environ["DB_ECHO"] = "0"
-environ["SLURM_USER"] = "slurm_user"
 
 # set_start_method("fork") necessary to run tests on MacOS
 # https://github.com/pytest-dev/pytest-flask/issues/104#issuecomment-577908228
diff --git a/tests/fixtures_testserver.py b/tests/fixtures_testserver.py
index 596fcb224..d7c71f007 100644
--- a/tests/fixtures_testserver.py
+++ b/tests/fixtures_testserver.py
@@ -1,6 +1,7 @@
 import asyncio
 import logging
 from os import environ
+from typing import Optional
 
 import pytest
 
@@ -178,10 +179,15 @@ async def _job_factory(**job_args_override):
 
 @pytest.fixture
 async def user_factory(client_superuser, testserver):
-    async def __register_user(email: str, password: str, slurm_user: str):
+    async def __register_user(
+        email: str, password: str, slurm_user: Optional[str] = None
+    ):
+        payload = dict(email=email, password=password)
+        if slurm_user:
+            payload["slurm_user"] = slurm_user
         res = await client_superuser.post(
             f"{testserver}/auth/register",
-            json=dict(email=email, password=password, slurm_user=slurm_user),
+            json=payload,
         )
         assert res.status_code == 201
         return res.json()
@@ -194,5 +200,4 @@ async def register_user(user_factory):
     return await user_factory(
         email=environ["FRACTAL_USER"],
         password=environ["FRACTAL_PASSWORD"],
-        slurm_user=environ["SLURM_USER"],
     )
diff --git a/tests/test_client.py b/tests/test_client.py
index 16d1bcca3..28f6fb75c 100644
--- a/tests/test_client.py
+++ b/tests/test_client.py
@@ -43,8 +43,7 @@ async def test_user_override(user_factory, invoke):
     """
     EMAIL = "other_user@exact-lab.it"
     PASSWORD = "other_password"
-    SLURM_USER = "slurm_user"
-    await user_factory(email=EMAIL, password=PASSWORD, slurm_user=SLURM_USER)
+    await user_factory(email=EMAIL, password=PASSWORD)
 
     res = await invoke(f"-u {EMAIL} -p {PASSWORD} project list")
     assert res.retcode == 0