diff --git a/fractal_client/cmd/__init__.py b/fractal_client/cmd/__init__.py index bee4cf2f..1c26f17b 100644 --- a/fractal_client/cmd/__init__.py +++ b/fractal_client/cmd/__init__.py @@ -307,7 +307,9 @@ def version(client: Client, **kwargs) -> Interface: try: res = client.get(f"{settings.FRACTAL_SERVER}/api/alive/") data = res.json() - server_str = f"\turl: {settings.FRACTAL_SERVER}\tversion: {data['version']}" + server_str = ( + f"\turl: {settings.FRACTAL_SERVER}\tversion: {data['version']}" + ) except ConnectError: server_str = f"\tConnection to '{settings.FRACTAL_SERVER}' refused" @@ -320,7 +322,9 @@ def version(client: Client, **kwargs) -> Interface: ) -def user(client: AuthClient, subcmd: str, batch: bool = False, **kwargs) -> Interface: +def user( + client: AuthClient, subcmd: str, batch: bool = False, **kwargs +) -> Interface: if subcmd == "register": parameters = [ "new_email", @@ -372,7 +376,9 @@ def user(client: AuthClient, subcmd: str, batch: bool = False, **kwargs) -> Inte return iface -def group(client: AuthClient, subcmd: str, batch: bool = False, **kwargs) -> Interface: +def group( + client: AuthClient, subcmd: str, batch: bool = False, **kwargs +) -> Interface: if subcmd == "list": parameters = ["user_ids"] function_kwargs = get_kwargs(parameters, kwargs) diff --git a/fractal_client/cmd/_task_collection.py b/fractal_client/cmd/_task_collection.py index 35d6683d..49ab7508 100644 --- a/fractal_client/cmd/_task_collection.py +++ b/fractal_client/cmd/_task_collection.py @@ -1,8 +1,8 @@ import json import logging import sys - from pathlib import Path + from fractal_client.authclient import AuthClient from fractal_client.config import settings from fractal_client.interface import Interface @@ -47,7 +47,11 @@ def task_collect_pip( if wheel_path is None: with open(wheel_path, "rb") as wheel_buffer: file = { - "file": (Path(wheel_path).name, wheel_buffer.read(), "application/zip") + "file": ( + Path(wheel_path).name, + wheel_buffer.read(), + "application/zip", + ) } res = client.post( f"{settings.BASE_URL}/task/collect/pip/{is_private}", @@ -107,7 +111,9 @@ def task_collect_custom( data=task_collect, ) - task_list = check_response(res, expected_status_code=201, redact_long_payload=True) + task_list = check_response( + res, expected_status_code=201, redact_long_payload=True + ) if batch: task_ids = [str(task["id"]) for task in task_list] diff --git a/fractal_client/parser.py b/fractal_client/parser.py index 15063511..6685f468 100644 --- a/fractal_client/parser.py +++ b/fractal_client/parser.py @@ -13,7 +13,6 @@ Institute for Biomedical Research and Pelkmans Lab from the University of Zurich. """ - import argparse as ap @@ -80,7 +79,9 @@ description="Show details of single project.", allow_abbrev=False, ) -project_show_parser.add_argument("project_id", type=int, help="ID of project to show.") +project_show_parser.add_argument( + "project_id", type=int, help="ID of project to show." +) # project delete project_delete_parser = project_subparsers.add_parser( @@ -127,7 +128,9 @@ project_edit_parser.add_argument( "project_id", type=int, help="ID of the project to edit." ) -project_edit_parser.add_argument("--new-name", help="New project name.", required=False) +project_edit_parser.add_argument( + "--new-name", help="New project name.", required=False +) # DATASET GROUP @@ -197,7 +200,9 @@ # task collect task_collect_parser = task_subparsers.add_parser( "collect", - description=("Install and collect all tasks from a pip-installable package."), + description=( + "Install and collect all tasks from a pip-installable package." + ), allow_abbrev=False, ) task_collect_parser.add_argument( @@ -254,7 +259,9 @@ ) task_collect_custom_parser.add_argument( "python_interpreter", - help=("Absolute path to the Python interpreter to be used for running tasks."), + help=( + "Absolute path to the Python interpreter to be used for running tasks." + ), ) task_collect_custom_parser.add_argument( "manifest", help="Local path of the Manifest of the Fractal task package." @@ -313,7 +320,9 @@ argument_default=ap.SUPPRESS, allow_abbrev=False, ) -task_new_parser.add_argument("name", help="A human readable name for the task.") +task_new_parser.add_argument( + "name", help="A human readable name for the task." +) task_new_parser.add_argument( "--command-non-parallel", help="The non parallel command that executes the task.", @@ -369,12 +378,15 @@ task_edit_id_or_name_group.add_argument( "--id", help="ID of the task to edit.", type=int ) -task_edit_id_or_name_group.add_argument("--name", help="Name of the task to edit.") +task_edit_id_or_name_group.add_argument( + "--name", help="Name of the task to edit." +) task_edit_parser.add_argument( "--version", help=( - "Version of the task to edit " "(only accepted in combination with `--name`)." + "Version of the task to edit " + "(only accepted in combination with `--name`)." ), ) task_edit_parser.add_argument("--new-version", help="New task version.") @@ -456,7 +468,9 @@ allow_abbrev=False, ) workflow_delete_parser.add_argument("project_id", type=int, help="Project ID.") -workflow_delete_parser.add_argument("workflow_id", type=int, help="Workflow ID.") +workflow_delete_parser.add_argument( + "workflow_id", type=int, help="Workflow ID." +) # workflow add task @@ -465,7 +479,9 @@ description="Add new task to specific workflow.", allow_abbrev=False, ) -workflow_add_task_parser.add_argument("project_id", type=int, help="Project ID.") +workflow_add_task_parser.add_argument( + "project_id", type=int, help="Project ID." +) workflow_add_task_parser.add_argument( "workflow_id", type=int, @@ -483,7 +499,10 @@ ) workflow_add_task_parser.add_argument( "--task-version", - help=("Version of task to add " "(only accepted in combination with --task-name)."), + help=( + "Version of task to add " + "(only accepted in combination with --task-name)." + ), ) workflow_add_task_parser.add_argument( "--order", help="Order of this task within the workflow's task list." @@ -493,7 +512,9 @@ "--args-non-parallel", help="Args for non parallel tasks" ) -workflow_add_task_parser.add_argument("--args-parallel", help="Args for parallel tasks") +workflow_add_task_parser.add_argument( + "--args-parallel", help="Args for parallel tasks" +) workflow_add_task_parser.add_argument( "--meta-non-parallel", help="Metadata file fornon parallel tasks" @@ -515,7 +536,9 @@ description="Edit task within specific workflow.", allow_abbrev=False, ) -workflow_edit_task_parser.add_argument("project_id", type=int, help="Project ID.") +workflow_edit_task_parser.add_argument( + "project_id", type=int, help="Project ID." +) workflow_edit_task_parser.add_argument( "workflow_id", type=int, @@ -556,7 +579,9 @@ description="Remove task from a specific workflow.", allow_abbrev=False, ) -workflow_remove_task_parser.add_argument("project_id", type=int, help="Project ID.") +workflow_remove_task_parser.add_argument( + "project_id", type=int, help="Project ID." +) workflow_remove_task_parser.add_argument( "workflow_id", type=int, @@ -655,7 +680,9 @@ description="Download full folder of workflow-execution job.", allow_abbrev=False, ) -job_download_logs_parser.add_argument("project_id", type=int, help="Project ID.") +job_download_logs_parser.add_argument( + "project_id", type=int, help="Project ID." +) job_download_logs_parser.add_argument("job_id", type=int, help="Job ID.") job_download_logs_parser.add_argument( "--output", @@ -689,14 +716,20 @@ "--start", dest="first_task_index", type=int, - help=("Positional index of the first task to be executed" " (starting from 0)."), + help=( + "Positional index of the first task to be executed" + " (starting from 0)." + ), required=False, ) job_submit_parser.add_argument( "--end", dest="last_task_index", type=int, - help=("Positional index of the last task to be executed" " (starting from 0)."), + help=( + "Positional index of the last task to be executed" + " (starting from 0)." + ), required=False, ) job_submit_parser.add_argument( @@ -747,8 +780,12 @@ ), allow_abbrev=False, ) -user_register_parser.add_argument("new_email", help="Email to be used as username.") -user_register_parser.add_argument("new_password", help="Password for the new user.") +user_register_parser.add_argument( + "new_email", help="Email to be used as username." +) +user_register_parser.add_argument( + "new_password", help="Password for the new user." +) user_register_parser.add_argument( "--project-dir", help="User-writeable base folder, used e.g. for default `zarr_dir` paths.", @@ -806,8 +843,12 @@ allow_abbrev=False, ) user_edit_parser.add_argument("user_id", help="ID of the user.", type=int) -user_edit_parser.add_argument("--new-email", help="New email address.", required=False) -user_edit_parser.add_argument("--new-password", help="New password.", required=False) +user_edit_parser.add_argument( + "--new-email", help="New email address.", required=False +) +user_edit_parser.add_argument( + "--new-password", help="New password.", required=False +) user_edit_parser.add_argument( "--new-username", help="New user username.", required=False ) @@ -864,7 +905,9 @@ description=("Reset user-group membership for an existing user."), allow_abbrev=False, ) -user_set_groups_parser.add_argument("user_id", help="ID of the user.", type=int) +user_set_groups_parser.add_argument( + "user_id", help="ID of the user.", type=int +) user_set_groups_parser.add_argument( "group_ids", help=( @@ -903,7 +946,9 @@ group_get_parser = group_subparsers.add_parser( "get", description="Get single group.", allow_abbrev=False ) -group_get_parser.add_argument("group_id", help="ID of the group to get.", type=int) +group_get_parser.add_argument( + "group_id", help="ID of the group to get.", type=int +) # group new group_new_parser = group_subparsers.add_parser( @@ -912,7 +957,10 @@ group_new_parser.add_argument("name", help="Name of the new group.", type=str) group_new_parser.add_argument( "--viewer-paths", - help=("List of group's `viewer_paths` (e.g " "`--viewer-paths /something /else`)",), + help=( + "List of group's `viewer_paths` (e.g " + "`--viewer-paths /something /else`)", + ), required=False, type=str, nargs="+", @@ -945,7 +993,9 @@ group_add_user_parser.add_argument( "group_id", help="ID of the group to which to add the user.", type=int ) -group_add_user_parser.add_argument("user_id", help="ID of the user to add.", type=int) +group_add_user_parser.add_argument( + "user_id", help="ID of the user to add.", type=int +) # group remove-user group_remove_user_parser = group_subparsers.add_parser( diff --git a/tests/test_task_collection.py b/tests/test_task_collection.py index c0c30385..fcd3c708 100644 --- a/tests/test_task_collection.py +++ b/tests/test_task_collection.py @@ -1,9 +1,10 @@ import json +import logging import sys import time from urllib.request import urlopen from urllib.request import urlretrieve -import logging + import pytest from devtools import debug @@ -52,7 +53,13 @@ def test_task_collection_invalid_pinned_dependency(invoke, caplog): """ PACKAGE = "devtools" with pytest.raises(SystemExit): - invoke(("task collect " f"{PACKAGE} " "--pinned-dependency invalid-string")) + invoke( + ( + "task collect " + f"{PACKAGE} " + "--pinned-dependency invalid-string" + ) + ) # Check that payload was prepared correctly log_lines = [record.message for record in caplog.records] debug(log_lines) @@ -84,7 +91,8 @@ def test_task_collection(invoke_as_custom_user, user_factory, new_name): initial_task_list = len(res.data) res0 = invoke_as_custom_user( - f"task collect --private {PACKAGE_PATH} --wheel-path {PACKAGE_PATH}", **new_user + f"task collect --private {PACKAGE_PATH} --wheel-path {PACKAGE_PATH}", + **new_user, ) debug(res0.data) activity_id = res0.data["id"] @@ -92,7 +100,9 @@ def test_task_collection(invoke_as_custom_user, user_factory, new_name): # Wait until collection is complete starting_time = time.perf_counter() while True: - res1 = invoke_as_custom_user(f"task check-collection {activity_id}", **new_user) + res1 = invoke_as_custom_user( + f"task check-collection {activity_id}", **new_user + ) assert res1.retcode == 0 time.sleep(0.1) if res1.data["status"] == "OK": @@ -101,7 +111,9 @@ def test_task_collection(invoke_as_custom_user, user_factory, new_name): assert time.perf_counter() - starting_time < COLLECTION_TIMEOUT # Check successful status and no logs - res2 = invoke_as_custom_user(f"task check-collection {activity_id}", **new_user) + res2 = invoke_as_custom_user( + f"task check-collection {activity_id}", **new_user + ) assert res2.retcode == 0 assert res2.data["status"] == "OK" assert res2.data["log"] is None