Skip to content

Commit

Permalink
fix(gherkin-parser): fixed pydocstyle errors (reanahub#464)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajclyall committed Jul 22, 2024
1 parent 90b43bb commit 87b996a
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 21 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ recursive-include docs *.txt
recursive-include reana_commons *.json
recursive-include reana_commons *.py
recursive-include tests *.py
recursive-include tests *.feature
68 changes: 66 additions & 2 deletions reana_commons/gherkin_parser/data_fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,102 @@
# This file provides primitives required for gherkin_parser/functions.py, allowing for different
# implementations in both the client side (api calls) and server side (database access). This avoids
# circular dependencies between reana-commons and reana-client.

"""Interface for fetching data related to a workflow."""

from abc import ABC, abstractmethod


class DataFetcherInterface(ABC):
"""Interface for fetching date related to a workflow"""
"""Interface for fetching date related to a workflow."""

@abstractmethod
def list_files(
self, workflow, access_token, file_name=None, page=None, size=None, search=None
):
"""Return the list of files for a given workflow workspace.
:param workflow: name or id of the workflow.
:param access_token: access token of the current user.
:param file_name: file name(s) (glob) to list.
:param page: page number of returned file list.
:param size: page size of returned file list.
:param search: filter search results by parameters.
:returns: a list of dictionaries that have the ``name``, ``size`` and
``last-modified`` keys.
"""
pass

@abstractmethod
def get_workflow_disk_usage(self, workflow, parameters, access_token):
"""Display disk usage workflow.
:param workflow: name or id of the workflow.
:param parameters: a dictionary to customize the response. It has the following
(optional) keys:
- ``summarize``: a boolean value to indicate whether to summarize the response
to include only the total workspace disk usage
- ``search``: a string to filter the response by file name
:param access_token: access token of the current user.
:return: a dictionary containing the ``workflow_id``, ``workflow_name``, and the ``user`` ID, with
a ``disk_usage_info`` keys that contains a list of dictionaries, each of one corresponding
to a file, with the ``name`` and ``size`` keys.
"""
pass

@abstractmethod
def get_workflow_logs(
self, workflow, access_token, steps=None, page=None, size=None
):
"""Get logs from a workflow engine.
:param workflow: name or id of the workflow.
:param access_token: access token of the current user.
:param steps: list of step names to get logs for.
:param page: page number of returned log list.
:param size: page size of returned log list.
:return: a dictionary with a ``logs`` key containing a JSON string that
contains the requested logs.
"""
pass

@abstractmethod
def get_workflow_status(self, workflow, access_token):
"""Get status of previously created workflow.
:param workflow: name or id of the workflow.
:param access_token: access token of the current user.
:return: a dictionary with the information about the workflow status.
The dictionary has the following keys: ``id``, ``logs``, ``name``,
``progress``, ``status``, ``user``.
"""
pass

@abstractmethod
def get_workflow_specification(self, workflow, access_token):
"""Get specification of previously created workflow.
:param workflow: name or id of the workflow.
:param access_token: access token of the current user.
:returns: a dictionary that cointains two top-level keys: ``parameters``, and
``specification`` (which contains a dictionary created from the workflow specification).
"""
pass

@abstractmethod
def download_file(self, workflow, file_name, access_token):
"""Download the requested file if it exists.
:param workflow: name or id of the workflow.
:param file_name: file name or path to the file requested.
:param access_token: access token of the current user.
:return: a tuple containing file binary content, filename and whether
the returned file is a zip archive containing multiple files.
"""
pass
36 changes: 18 additions & 18 deletions reana_commons/gherkin_parser/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def _engine_logs_contain(workflow, access_token, content):
@when("the workflow execution completes")
def _check_workflow_finished(workflow, access_token):
"""
.. container:: testcase-title
.. container:: testcase-title.
Workflow execution completed
Expand All @@ -248,7 +248,7 @@ def _check_workflow_finished(workflow, access_token):
@when("the workflow status is {status_workflow}")
def _check_workflow_status(workflow, access_token, status_workflow):
"""
.. container:: testcase-title
.. container:: testcase-title.
Status of the workflow
Expand All @@ -270,7 +270,7 @@ def _check_workflow_status(workflow, access_token, status_workflow):
@then("the workflow status should be {status_workflow}")
def _test_workflow_status(workflow, access_token, status_workflow):
"""
.. container:: testcase-title
.. container:: testcase-title.
Status of the workflow
Expand All @@ -292,7 +292,7 @@ def _test_workflow_status(workflow, access_token, status_workflow):
@then("all the outputs should be included in the workspace")
def workspace_include_all_outputs(workflow, access_token):
"""
.. container:: testcase-title
.. container:: testcase-title.
Presence of all the outputs in the workspace
Expand All @@ -318,7 +318,7 @@ def workspace_include_all_outputs(workflow, access_token):
@then("{filename} should be in the workspace")
def workspace_include_specific_file(workflow, access_token, filename):
"""
.. container:: testcase-title
.. container:: testcase-title.
Presence of a specific file in the workspace
Expand All @@ -340,7 +340,7 @@ def workspace_include_specific_file(workflow, access_token, filename):
@then("{filename} should not be in the workspace")
def workspace_do_not_include_specific_file(workflow, access_token, filename):
"""
.. container:: testcase-title
.. container:: testcase-title.
Absence of a specific file in the workspace
Expand All @@ -360,7 +360,7 @@ def workspace_do_not_include_specific_file(workflow, access_token, filename):
@then('the logs should contain "{content}"')
def logs_contain(workflow, access_token, content):
"""
.. container:: testcase-title
.. container:: testcase-title.
Content of the logs of the workflow
Expand All @@ -379,7 +379,7 @@ def logs_contain(workflow, access_token, content):
@then('the engine logs should contain "{content}"')
def logs_engine_contain(workflow, access_token, content):
"""
.. container:: testcase-title
.. container:: testcase-title.
Content of the engine logs of the workflow
Expand All @@ -398,7 +398,7 @@ def logs_engine_contain(workflow, access_token, content):
@then('the job logs should contain "{content}"')
def logs_job_contain(workflow, access_token, content):
"""
.. container:: testcase-title
.. container:: testcase-title.
Content of the job logs of the workflow
Expand All @@ -418,7 +418,7 @@ def logs_job_contain(workflow, access_token, content):
@then('the job logs for the {step_name} step should contain "{content}"')
def logs_step_contain(workflow, access_token, step_name, content):
"""
.. container:: testcase-title
.. container:: testcase-title.
Content of the job logs for a particular step
Expand Down Expand Up @@ -451,7 +451,7 @@ def logs_step_contain(workflow, access_token, step_name, content):
@then('the file {filename} should contain "{content}"')
def file_content_contain(workflow, access_token, filename, content):
"""
.. container:: testcase-title
.. container:: testcase-title.
Content of a specific file in the workspace
Expand Down Expand Up @@ -481,7 +481,7 @@ def file_content_contain(workflow, access_token, filename, content):
@then("the {algorithm} checksum of the file {filename} should be {checksum}")
def file_checksum(workflow, access_token, algorithm, filename, checksum):
"""
.. container:: testcase-title
.. container:: testcase-title.
Checksum of a specific file in the workspace
Expand Down Expand Up @@ -522,7 +522,7 @@ def file_checksum(workflow, access_token, algorithm, filename, checksum):
@then("the workflow run duration should be less than {n_minutes} minutes")
def duration_minimum_workflow(workflow, access_token, n_minutes):
"""
.. container:: testcase-title
.. container:: testcase-title.
Minimum duration of the workflow
Expand All @@ -549,7 +549,7 @@ def duration_minimum_workflow(workflow, access_token, n_minutes):
@then("the duration of the step {step_name} should be less than {n_minutes} minutes")
def duration_minimum_step(workflow, access_token, step_name, n_minutes):
"""
.. container:: testcase-title
.. container:: testcase-title.
Minimum duration of each step of the workflow
Expand Down Expand Up @@ -590,7 +590,7 @@ def duration_minimum_step(workflow, access_token, step_name, n_minutes):
@then("the size of the file {filename} should be exactly {dim}")
def exact_file_size(workflow, access_token, filename, dim):
"""
.. container:: testcase-title
.. container:: testcase-title.
Exact size of a specific file in the workspace
Expand All @@ -613,7 +613,7 @@ def exact_file_size(workflow, access_token, filename, dim):
@then("the size of the file {filename} should be between {dim1} and {dim2}")
def approximate_file_size(workflow, access_token, filename, dim1, dim2):
"""
.. container:: testcase-title
.. container:: testcase-title.
Approximate size of a specific file in the workspace
Expand Down Expand Up @@ -642,7 +642,7 @@ def approximate_file_size(workflow, access_token, filename, dim1, dim2):
@then("the workspace size should be less than {dim}")
def workspace_size_maximum(workflow, access_token, dim):
"""
.. container:: testcase-title
.. container:: testcase-title.
Maximum workspace size
Expand All @@ -662,7 +662,7 @@ def workspace_size_maximum(workflow, access_token, dim):
@then("the workspace size should be more than {dim}")
def workspace_size_minimum(workflow, access_token, dim):
"""
.. container:: testcase-title
.. container:: testcase-title.
Minimum workspace size
Expand Down
1 change: 0 additions & 1 deletion reana_commons/gherkin_parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def parse_feature_file(feature_file_path: str) -> Tuple[str, List[Dict]]:
:raise IOError: If there is an error while reading the feature file.
:raise FeatureFileError: If there is an error while parsing or compiling the feature file.
"""

try:
with open(feature_file_path) as f:
file_content = f.read()
Expand Down

0 comments on commit 87b996a

Please sign in to comment.