Skip to content

Commit

Permalink
better_documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrembilla committed Jun 30, 2022
1 parent 73a82dc commit 6a0b797
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 24 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ These functions can take parameters as input, while the first unspecified parame
```

In addition, it is possible to run multiple functions sequentially by concatenating them with `"-->"` in the API specification document. In this case the output of the function `f_i` will becomes the input result table of the function `f_i+1`.

The postprocess function should output a tuple containing the result and whether the function needs to return the type of values in the result.

## Run RAMOSE

Expand Down Expand Up @@ -319,10 +321,10 @@ call_1 = "%s/%s/%s" % (api_base_1, operation_url_1, request)
call_2 = "%s/%s/%s" % (api_base_2, operation_url_2, request)
op1 = api_manager.get_op(call_1)
status1, result1 = op1.exec()
status1, result1, result_format1 = op1.exec()
op2 = api_manager.get_op(call_2)
status2, result2 = op2.exec()
status2, result2, result_format2 = op2.exec()
```

## Other functionalities and examples
Expand Down
34 changes: 32 additions & 2 deletions docs/source/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,39 @@ Example:

.. code-block:: none
#postprocess postprocess_oci(oci) --> another_process(oci)
#postprocess split_dois(dois)
or
#postprocess postprocess_metadata(doi)
#postprocess distinct()
The preprocess functions should return a tuple explain a tuple of values defining how the particular value passed in the dictionary must be changed.
The postprocess functions should return a tuple having as second element a boolean for whether the function should return the type of value specified.
Example of a preprocess and postprocess functions:

.. code-block:: python
#Preprocess
def split_dois(s):
return "\"%s\"" % "\" \"".join(s.split("__")),
#Postprocess
def distinct(res):
header = res[0]
doi_field = header.index("doi")
result = [header]
dois = set()
for row in res[1:]:
cur_doi = row[doi_field]
if cur_doi not in dois:
dois.add(cur_doi)
result.append(row)
return result, True
#method

Expand Down
34 changes: 17 additions & 17 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ itsdangerous="1.1.0"
Jinja2="2.11.3"
Markdown="3.1.1"
MarkupSafe="1.1.1"
python-dateutil="2.8.1"
python-dateutil="^2.8.2"
requests="^2.22.0"
six="1.13.0"
urllib3="1.26.5"
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ itsdangerous==1.1.0
Jinja2==2.11.3
Markdown==3.1.1
MarkupSafe==1.1.1
python-dateutil==2.8.1
python-dateutil==2.8.2
requests>=2.22.0, <3.0.0
six==1.13.0
urllib3==1.26.5
Expand Down
9 changes: 8 additions & 1 deletion test/ramose.py
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,10 @@ def postprocess(self, res, op_item, addon):
respectively. In addition, it is possible to run multiple functions sequentially by concatenating them
with "-->" in the API specification document. In this case the output of the function f_i will becomes
the input result table of the function f_i+1.
The postprocess function should output a tuple containing the result and whether the function needs to return the type of values in the result.
"""

result = res

if "postprocess" in op_item:
Expand Down Expand Up @@ -1388,7 +1391,7 @@ def remove_types(self, res):
def exec(self, method="get", content_type="application/json"):
"""
This method takes in input the the HTTP method to use for the call
and the content type to return, and execute the operation as indicated
and the content type to return, and executes the operation as indicated
in the specification file, by running (in the following order):
1. the methods to preprocess the query;
Expand Down Expand Up @@ -1471,7 +1474,9 @@ def exec(self, method="get", content_type="application/json"):


class APIManager(object):

# Fixing max size for CSV

@staticmethod
def __max_size_csv():
from sys import maxsize
Expand All @@ -1485,7 +1490,9 @@ def __max_size_csv():
maxInt = int(maxInt/10)

# Constructor: START

def __init__(self, conf_files):

"""
This is the constructor of the APIManager class. It takes in input a list of API configuration files, each
defined according to the Hash Format and following a particular structure, and stores all the operations
Expand Down

0 comments on commit 6a0b797

Please sign in to comment.