Skip to content

Commit

Permalink
fix(IASOClient): remove columns (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarfil authored Jul 19, 2024
1 parent 0227c6c commit 8ce0a6d
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions openhexa/toolbox/iaso/iaso.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ def get_form_instances(
page: int = 1,
limit: int = 10,
as_dataframe: bool = False,
dataframe_columns: typing.List[str] = None,
**kwargs,
) -> typing.Union[dict, pl.DataFrame]:
"""
Expand All @@ -77,22 +76,20 @@ def get_form_instances(
:param page: The page number of the form instance.
:param limit: The maximum number of form instances.
:param as_dataframe: If true, will return a DataFrame containing form instances.
:param dataframe_columns: The column names of the form instances.
:param kwargs: additonal arguments passed to the /forms endpoint as URL parameters.
Examples:
>>> from openhexa.toolbox.iaso import IASO
>>> iaso = IASO(url="http://iaso-staging.bluesquare.org", username="user", password="pass")
>>> form_dataframes = iaso.get_form_instances(page=1, limit=1, as_dataframe=True,
>>> dataframe_columns=["Date de création","Date de modification","Org unit"], ids=276)
>>> form_dataframes = iaso.get_form_instances(page=1, limit=1, as_dataframe=True, ids=276)
"""

params = kwargs
params.update({"page": page, "limit": limit})
if as_dataframe:
params.update({"csv": "true"})
response = self.api_client.get("/api/instances", params=params)
forms = pl.read_csv(io.StringIO(response.content.decode("utf-8")))[dataframe_columns]
forms = pl.read_csv(io.StringIO(response.content.decode("utf-8")))
return forms
response = self.api_client.get("/api/instances/", params=kwargs)
forms = response.json().get("instances")
Expand Down

0 comments on commit 8ce0a6d

Please sign in to comment.