-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BAC-9152: add customer-results entity to SDK
Merge in BAC/icometrix-sdk from feature/customer-results to master Squashed commit of the following: commit 156e8df02234061e10175f27fa3e9b8e0950427f Author: Jeroen Pinxten <jeroen.pinxten@icometrix.com> Date: Thu Feb 15 10:40:47 2024 +0100 BAC-9152: add customer-results entity to SDK
- Loading branch information
Showing
15 changed files
with
166 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ Developer Guide | |
.. toctree:: | ||
|
||
paginators | ||
session | ||
session | ||
models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Models | ||
====== | ||
|
||
Some API operations may return incomplete results that require multiple requests to retrieve the entire | ||
dataset. This process of fetching subsequent pages is known as pagination. Pagination is a crucial aspect when dealing | ||
with large datasets to ensure efficient data retrieval. | ||
|
||
Base model | ||
---------- | ||
|
||
All entities that are returned by the icometrix API extend the :class:`~icometrix_sdk.models.base.BackendEntity` entity. | ||
The BaseEntity always has the following properties: | ||
|
||
- :attr:`~icometrix_sdk.models.base.BackendEntity.id`: The unique identifier (uuid) | ||
- :attr:`~icometrix_sdk.models.base.BackendEntity.update_timestamp`: The timestamp of the last update | ||
- :attr:`~icometrix_sdk.models.base.BackendEntity.creation_timestamp`: The creation timestamp | ||
- :attr:`~icometrix_sdk.models.base.BackendEntity.uri`: The uri to point to the location of the object | ||
|
||
Collections | ||
----------- | ||
|
||
When fetching a collection of models from the API; you will always get a subset of that collection in combination with | ||
some extra meta data. See: :doc:`paginators` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Customer Report | ||
=============== | ||
|
||
.. automodule:: icometrix_sdk.models.customer_result_entity | ||
:members: | ||
:undoc-members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Customer Results | ||
================ | ||
|
||
.. automodule:: icometrix_sdk.resources.customer_results | ||
|
||
|
||
.. autoclass:: icometrix_sdk.resources.customer_results.CustomerResults | ||
:members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,5 @@ Resources | |
projects | ||
patients | ||
uploads | ||
customer_results | ||
customer_reports |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from pydantic import BaseModel | ||
from icometrix_sdk.models.base import BackendEntity | ||
|
||
|
||
class CustomerResultPipelineResults(BaseModel): | ||
pipeline_results_id: str | ||
|
||
|
||
class CustomerResultEntity(BackendEntity): | ||
uri: str | ||
job_id: str | ||
study_id: str | ||
patient_id: str | ||
project_id: str | ||
qc_result_id: str | ||
pipeline_results: CustomerResultPipelineResults |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import logging | ||
|
||
from icometrix_sdk.models.base import PaginatedResponse | ||
from icometrix_sdk.models.customer_result_entity import CustomerResultEntity | ||
from icometrix_sdk.utils.requests_api_client import ApiClient | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class CustomerResults: | ||
def __init__(self, api: ApiClient): | ||
self._api = api | ||
|
||
def get_all_for_study(self, study_uri: str, **kwargs) -> PaginatedResponse[CustomerResultEntity]: | ||
""" | ||
Get al customer reports for a project | ||
:param study_uri: The uri of a study | ||
:return: A Paginated response containing customer-results | ||
""" | ||
|
||
page = self._api.get(f"{study_uri}/customer-results", **kwargs) | ||
return PaginatedResponse[CustomerResultEntity](**page) | ||
|
||
def get_all_for_pipeline_result(self, pipeline_result_uri: str, **kwargs) -> \ | ||
PaginatedResponse[CustomerResultEntity]: | ||
""" | ||
Get al customer reports for a pipeline-result | ||
:param pipeline_result_uri: The uri of a pipeline-result | ||
:return: A Paginated response containing customer-results | ||
""" | ||
|
||
page = self._api.get(f"{pipeline_result_uri}/customer-results", **kwargs) | ||
return PaginatedResponse[CustomerResultEntity](**page) | ||
|
||
def get_one(self, customer_result_uri: str) -> CustomerResultEntity: | ||
""" | ||
Get a single customer-result based on the customer-result uri | ||
:param customer_result_uri: the uri of the customer-result | ||
:return: A single customer-result or 404 | ||
""" | ||
resp = self._api.get(customer_result_uri) | ||
return CustomerResultEntity(**resp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters