Skip to content

Commit

Permalink
global: upgrade black formatter version
Browse files Browse the repository at this point in the history
  • Loading branch information
reana-team authored and mdonadoni committed Mar 31, 2022
1 parent d602781 commit 41746c1
Show file tree
Hide file tree
Showing 18 changed files with 98 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
python-version: '3.8'

- name: Install Python dependencies
run: pip install black==19.10b0
run: pip install black

- name: Check Python code formatting
run: ./run-tests.sh --check-black
Expand Down
3 changes: 2 additions & 1 deletion reana_client/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,8 @@ def close_interactive_session(workflow, access_token):
"""
try:
(response, http_response) = current_rs_api_client.api.close_interactive_session(
workflow_id_or_name=workflow, access_token=access_token,
workflow_id_or_name=workflow,
access_token=access_token,
).result()
if http_response.status_code == 200:
return response
Expand Down
5 changes: 4 additions & 1 deletion reana_client/cli/cwl_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ def upload_files(files, basedir, workflow_id, access_token):
for next_path in files + dirs:
location = os.path.join(root, next_path).replace(basedir + "/", "")
upload_files(
[{"location": location}], basedir, workflow_id, access_token,
[{"location": location}],
basedir,
workflow_id,
access_token,
)
else:
with open(abs_file_path, "r") as f:
Expand Down
6 changes: 4 additions & 2 deletions reana_client/cli/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,8 @@ def move_files(ctx, source, target, workflow, access_token): # noqa: D301
current_status = get_workflow_status(workflow, access_token).get("status")
if current_status == "running":
display_message(
"File(s) could not be moved for running workflow", msg_type="error",
"File(s) could not be moved for running workflow",
msg_type="error",
)
sys.exit(1)
files = list_files(workflow, access_token)
Expand Down Expand Up @@ -560,6 +561,7 @@ def workflow_disk_usage(
logging.debug(traceback.format_exc())
logging.debug(str(e))
display_message(
"Disk usage could not be retrieved: \n{}".format(e), msg_type="error",
"Disk usage could not be retrieved: \n{}".format(e),
msg_type="error",
)
sys.exit(1)
3 changes: 2 additions & 1 deletion reana_client/cli/quotas.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ def quota_show(
display_message(
"Error: resource '{}' is not valid.\n"
"Available resources are: '{}'.".format(
resource, "', '".join(sorted(quota.keys())),
resource,
"', '".join(sorted(quota.keys())),
),
msg_type="error",
)
Expand Down
9 changes: 6 additions & 3 deletions reana_client/cli/secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ def secrets_add(env, file, overwrite, access_token): # noqa: D301
except Exception as e:
logging.debug(str(e), exc_info=True)
display_message(
"Something went wrong while uploading secrets", msg_type="error",
"Something went wrong while uploading secrets",
msg_type="error",
)
sys.exit(1)
else:
Expand Down Expand Up @@ -122,7 +123,8 @@ def secrets_delete(secrets, access_token): # noqa: D301
except Exception as e:
logging.debug(str(e), exc_info=True)
display_message(
"Something went wrong while deleting secrets", msg_type="error",
"Something went wrong while deleting secrets",
msg_type="error",
)
sys.exit(1)
else:
Expand Down Expand Up @@ -154,6 +156,7 @@ def secrets_list(access_token): # noqa: D301
except Exception as e:
logging.debug(str(e), exc_info=True)
display_message(
"Something went wrong while listing secrets", msg_type="error",
"Something went wrong while listing secrets",
msg_type="error",
)
sys.exit(1)
19 changes: 13 additions & 6 deletions reana_client/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ def wrapper(*args, **kwargs):
api_url = get_api_url()
if not api_url:
display_message(
"REANA client is not connected to any REANA cluster.", msg_type="error",
"REANA client is not connected to any REANA cluster.",
msg_type="error",
)
sys.exit(1)
return func(*args, **kwargs)
Expand Down Expand Up @@ -131,7 +132,9 @@ def add_pagination_options(func):
help="Results page number (to be used with --size).",
)
@click.option(
"--size", type=int, help="Size of results per page (to be used with --page).",
"--size",
type=int,
help="Size of results per page (to be used with --page).",
)
@functools.wraps(func)
def wrapper(*args, **kwargs):
Expand All @@ -157,7 +160,8 @@ def parse_format_parameters(_format):
return parsed_filters
except ValueError as e:
display_message(
"Wrong filter format \n{0}".format(e.message), msg_type="error",
"Wrong filter format \n{0}".format(e.message),
msg_type="error",
)


Expand Down Expand Up @@ -187,7 +191,8 @@ def parse_filter_parameters(filters, filter_names):
search_filters[filter_name] = [filter_value]
else:
display_message(
"Filter {} is not valid.".format(filter_name), msg_type="error",
"Filter {} is not valid.".format(filter_name),
msg_type="error",
),
sys.exit(1)
else:
Expand All @@ -201,7 +206,8 @@ def parse_filter_parameters(filters, filter_names):
return status_filters, search_filters
except ValueError as e:
display_message(
"Wrong filter format \n{0}".format(e.message), msg_type="error",
"Wrong filter format \n{0}".format(e.message),
msg_type="error",
)


Expand Down Expand Up @@ -366,5 +372,6 @@ def output_user_friendly_logs(workflow_logs, steps):
click.secho(logs_output)
else:
display_message(
f"Step {job_name_or_id} emitted no logs.", msg_type="info",
f"Step {job_name_or_id} emitted no logs.",
msg_type="info",
)
14 changes: 10 additions & 4 deletions reana_client/cli/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ def workflow_execution_group(ctx):

@workflow_management_group.command("list")
@click.option(
"-w", "--workflow", default=None, help="List all runs of the given workflow.",
"-w",
"--workflow",
default=None,
help="List all runs of the given workflow.",
)
@click.option(
"-s", "--sessions", is_flag=True, help="List all open interactive sessions."
Expand Down Expand Up @@ -462,7 +465,8 @@ def workflow_start(
if current_status == "finished":
if follow:
display_message(
"Listing workflow output files...", msg_type="info",
"Listing workflow output files...",
msg_type="info",
)
ctx.invoke(
get_files,
Expand Down Expand Up @@ -816,7 +820,8 @@ def workflow_logs(
display_message(
"Filter '{}' is not valid.\n"
"Available filters are '{}'.".format(
key, "' '".join(sorted(available_filters.keys())),
key,
"' '".join(sorted(available_filters.keys())),
),
msg_type="error",
)
Expand Down Expand Up @@ -1009,7 +1014,8 @@ def workflow_stop(ctx, workflow, force_stop, access_token): # noqa: D301
logging.info("Sending a request to stop workflow {}".format(workflow))
stop_workflow(workflow, force_stop, access_token)
display_message(
get_workflow_status_change_msg(workflow, "stopped"), msg_type="success",
get_workflow_status_change_msg(workflow, "stopped"),
msg_type="success",
)
except Exception as e:
logging.debug(traceback.format_exc())
Expand Down
5 changes: 4 additions & 1 deletion reana_client/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ def display_message(msg, msg_type=None, indented=False):
if msg_type == "info":
if indented:
click.secho(
" -> {}: ".format(msg_type.upper()), bold=True, nl=False, fg=msg_color,
" -> {}: ".format(msg_type.upper()),
bold=True,
nl=False,
fg=msg_color,
)
click.secho("{}".format(msg), nl=True)
else:
Expand Down
4 changes: 3 additions & 1 deletion reana_client/validation/compute_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ def validate_compute_backends(
validator.validate()
except REANAValidationError as e:
display_message(
str(e), msg_type="error", indented=True,
str(e),
msg_type="error",
indented=True,
)
sys.exit(1)
display_message(
Expand Down
8 changes: 6 additions & 2 deletions reana_client/validation/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ def display_messages(self):
"""Display messages in console."""
for msg in self.messages:
display_message(
msg["message"], msg_type=msg["type"], indented=True,
msg["message"],
msg_type=msg["type"],
indented=True,
)

def _validate_environment_image(self, image, kubernetes_uid=None):
Expand Down Expand Up @@ -339,7 +341,9 @@ def _image_exists_in_dockerhub(self, image, tag):
{
"type": "warning",
"message": "==> WARNING: Existence of environment image {} in Docker Hub could not be verified. Status code: {} {}".format(
full_image, response.status_code, response.reason,
full_image,
response.status_code,
response.reason,
),
}
)
Expand Down
4 changes: 3 additions & 1 deletion reana_client/validation/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ def validate_parameters(reana_yaml: Dict) -> None:
except REANAValidationError as e:
display_messages(validator)
display_message(
str(e), msg_type="error", indented=True,
str(e),
msg_type="error",
indented=True,
)
sys.exit(1)

Expand Down
13 changes: 9 additions & 4 deletions reana_client/validation/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,14 @@ def validate_reana_spec(

if not skip_validation:
display_message(
f"Verifying REANA specification file... {filepath}", msg_type="info",
f"Verifying REANA specification file... {filepath}",
msg_type="info",
)
validate_reana_yaml(reana_yaml)
display_message(
"Valid REANA specification file.", msg_type="success", indented=True,
"Valid REANA specification file.",
msg_type="success",
indented=True,
)

validate_parameters(reana_yaml)
Expand All @@ -62,7 +65,8 @@ def validate_reana_spec(

if not skip_validate_environments:
display_message(
"Verifying environments in REANA specification file...", msg_type="info",
"Verifying environments in REANA specification file...",
msg_type="info",
)
validate_environment(reana_yaml, pull=pull_environment_image)

Expand All @@ -78,7 +82,8 @@ def _validate_server_capabilities(reana_yaml: Dict, access_token: str) -> None:
info_response = info(access_token)

display_message(
"Verifying compute backends in REANA specification file...", msg_type="info",
"Verifying compute backends in REANA specification file...",
msg_type="info",
)
supported_backends = info_response.get("compute_backends", {}).get("value")
validate_compute_backends(reana_yaml, supported_backends)
Expand Down
7 changes: 5 additions & 2 deletions reana_client/validation/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@ def _validate_workspace(
"""
if root_path:
display_message(
"Verifying workspace in REANA specification file...", msg_type="info",
"Verifying workspace in REANA specification file...",
msg_type="info",
)
try:
validate_workspace(root_path, available_workspaces)
display_message(
"Workflow workspace appears valid.", msg_type="success", indented=True,
"Workflow workspace appears valid.",
msg_type="success",
indented=True,
)
except REANAValidationError as e:
display_message(e.message, msg_type="error")
Expand Down
14 changes: 10 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@
history = open("CHANGES.rst").read()

tests_require = [
"pytest-reana>=0.9.0a2,<0.10.0",
"pytest-reana>=0.9.0a4,<0.10.0",
]

extras_require = {
"docs": ["Sphinx>=1.5.1", "sphinx-rtd-theme>=0.1.9", "sphinx-click>=1.0.4",],
"docs": [
"Sphinx>=1.5.1",
"sphinx-rtd-theme>=0.1.9",
"sphinx-click>=1.0.4",
],
"tests": tests_require,
}

Expand All @@ -40,7 +44,7 @@
install_requires = [
"click>=7",
"jsonpointer>=2.0",
"reana-commons[yadage,snakemake,cwl]>=0.9.0a5,<0.10.0",
"reana-commons[yadage,snakemake,cwl]>=0.9.0a6,<0.10.0",
"tablib>=0.12.1,<0.13",
"werkzeug>=0.14.1 ; python_version<'3.10'",
"werkzeug>=0.15.0 ; python_version>='3.10'",
Expand All @@ -63,7 +67,9 @@
author="REANA",
author_email="[email protected]",
url="https://github.com/reanahub/reana-client",
packages=["reana_client",],
packages=[
"reana_client",
],
zip_safe=False,
include_package_data=True,
entry_points={
Expand Down
9 changes: 6 additions & 3 deletions tests/test_cli_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,8 @@ def test_workflows_filter():
make_mock_api_client("reana-server")(mock_response, mock_http_response),
):
result = runner.invoke(
cli, ["list", "-t", reana_token, "--json", "--filter", filter],
cli,
["list", "-t", reana_token, "--json", "--filter", filter],
)
json_response = json.loads(result.output)
assert result.exit_code == 0
Expand Down Expand Up @@ -627,7 +628,8 @@ def test_workflows_validate(create_yaml_workflow_schema):
with open("reana.yaml", "w") as f:
f.write(create_yaml_workflow_schema)
result = runner.invoke(
cli, ["validate", "-t", reana_token, "--file", "reana.yaml"],
cli,
["validate", "-t", reana_token, "--file", "reana.yaml"],
)
assert result.exit_code == 0
assert message in result.output
Expand Down Expand Up @@ -693,7 +695,8 @@ def test_run(
with open(reana_workflow_schema, "w") as f:
f.write(create_yaml_workflow_schema)
runner.invoke(
cli, ["run", "-t", reana_token, "-f", reana_workflow_schema],
cli,
["run", "-t", reana_token, "-f", reana_workflow_schema],
)
assert workflow_create_mock.called is True
assert upload_file_mock.called is True
Expand Down
6 changes: 5 additions & 1 deletion tests/test_validate_compute_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ def test_validate_compute_backends_snakemake(
],
)
def test_validate_compute_backends_cwl(
compute_backend, supported_backends, valid, cwl_workflow_spec_loaded, capsys,
compute_backend,
supported_backends,
valid,
cwl_workflow_spec_loaded,
capsys,
):
"""Validate compute backends for CWL workflows."""
reana_yaml = cwl_workflow_spec_loaded
Expand Down
6 changes: 5 additions & 1 deletion tests/test_validate_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,11 @@ def test_validate_parameters_yadage(yadage_workflow_spec_loaded, capsys):
"installation",
'"cd /" found in step "installation" might be dangerous.',
),
(["sudo npm install"], None, '"sudo" might be dangerous.',),
(
["sudo npm install"],
None,
'"sudo" might be dangerous.',
),
],
)
def test_validate_dangerous_operations(commands, step, warning, capsys):
Expand Down

0 comments on commit 41746c1

Please sign in to comment.