Skip to content

Commit

Permalink
Update client API.
Browse files Browse the repository at this point in the history
Add a method to retrieve the dictionary with 'angles' and 'internodes' data using the `Sequence` resource.
  • Loading branch information
jlegrand62 committed Aug 20, 2024
1 parent ca098b4 commit bb25d29
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/plantdb/rest_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,3 +585,29 @@ def get_task_data(dataset_name, task, filename=None, api_data=None, **api_kwargs
url = base_url(**api_kwargs)
data = requests.get(url + file_uri).content
return parse_task_requests_data(task, data, ext)


def get_angles_and_internodes_data(dataset_name, **api_kwargs):
"""Return a dictionary with 'angles' and 'internodes' data for selected dataset.
Parameters
----------
dataset_name : str
The name of the dataset.
Other Parameters
----------------
host : str
The IP address of the PlantDB REST API. Defaults to ``"127.0.0.1"``.
port : str or int
The port of the PlantDB REST API. Defaults to ``5000``.
Returns
-------
dict
A dictionary with 'angles' and 'internodes' data.
"""
url = base_url(**api_kwargs)
res = requests.get(url + f"/sequence/{dataset_name}")
data = json.loads(res.content.decode('utf-8'))
return {seq: data[seq] for seq in ['angles', 'internodes']}

0 comments on commit bb25d29

Please sign in to comment.