Skip to content

Commit 81330fc

Browse files
authored
Adding DataHealthClient & changelog update [2.1.22] (#114)
* Adding `DataHealthClient` & changelog update * fmt * comments * params
1 parent e09e4ff commit 81330fc

File tree

4 files changed

+76
-0
lines changed

4 files changed

+76
-0
lines changed

docs/changelog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog],
66
and this project adheres to [Semantic Versioning].
77

8+
## [2.1.22] - 2025-12-15
9+
10+
## Added
11+
- add DataHealthClient with two functions for obtaining Foundry Checks and Check Runs (#114)
12+
813
## [2.1.21] - 2025-10-28
914

1015
## Added
@@ -370,6 +375,8 @@ and this project adheres to [Semantic Versioning].
370375
[Keep a Changelog]: https://keepachangelog.com/en/1.0.0/
371376
[Semantic Versioning]: https://semver.org/spec/v2.0.0.html
372377

378+
[2.1.22]: https://github.com/emdgroup/foundry-dev-tools/compare/v2.1.21...v2.1.22
379+
[2.1.21]: https://github.com/emdgroup/foundry-dev-tools/compare/v2.1.20...v2.1.21
373380
[2.1.20]: https://github.com/emdgroup/foundry-dev-tools/compare/v2.1.19...v2.1.20
374381
[2.1.19]: https://github.com/emdgroup/foundry-dev-tools/compare/v2.1.18...v2.1.19
375382
[2.1.18]: https://github.com/emdgroup/foundry-dev-tools/compare/v2.1.17...v2.1.18
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
"""Implementation of the data-health API."""
2+
3+
from __future__ import annotations
4+
5+
from typing import TYPE_CHECKING
6+
7+
from foundry_dev_tools.clients.api_client import APIClient
8+
9+
if TYPE_CHECKING:
10+
import requests
11+
12+
from foundry_dev_tools.utils.api_types import (
13+
CheckRid,
14+
DatasetRid,
15+
)
16+
17+
18+
class DataHealthClient(APIClient):
19+
"""DataHealthClient class that implements methods from the 'foundry-data-health' API."""
20+
21+
api_name = "data-health"
22+
23+
def api_get_checks_for_dataset(
24+
self,
25+
dataset_rid: DatasetRid,
26+
branch: str = "master",
27+
**kwargs,
28+
) -> requests.Response:
29+
"""Gets all the Check RIDs available for the given Dataset RID and branch name.
30+
31+
Args:
32+
dataset_rid: The RID of the dataset
33+
branch: The name of the branch
34+
**kwargs: gets passed to :py:meth:`APIClient.api_request`
35+
"""
36+
return self.api_request(
37+
"GET",
38+
api_path=f"checks/v2/{dataset_rid}/{branch}",
39+
**kwargs,
40+
)
41+
42+
def api_get_latest_checks_history(
43+
self, check_rids: list[CheckRid] | CheckRid, limit: int = 5, **kwargs
44+
) -> requests.Response:
45+
"""Returns CheckRun metadata for the last `limit` number of check runs for the given list of Check RIDs.
46+
47+
Args:
48+
check_rids: a list of CheckRIDs or a single string value.
49+
limit: number of last check runs to go for for each Check RID. Defaults to 5.
50+
**kwargs: gets passed to :py:meth:`APIClient.api_request`
51+
"""
52+
check_rids = check_rids if isinstance(check_rids, list) else [check_rids]
53+
params = {"limit": limit}
54+
return self.api_request(
55+
"POST",
56+
api_path="checks/reports/v2/latest",
57+
json=check_rids,
58+
params=params,
59+
**kwargs,
60+
)

libs/foundry-dev-tools/src/foundry_dev_tools/config/context.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
catalog,
1414
compass,
1515
context_client,
16+
data_health,
1617
data_proxy,
1718
foundry_sql_server,
1819
foundry_stats,
@@ -126,6 +127,11 @@ def metadata(self) -> metadata.MetadataClient:
126127
"""Returns :py:class:`foundry_dev_tools.clients.metadata.MetadataClient`."""
127128
return metadata.MetadataClient(self)
128129

130+
@cached_property
131+
def data_health(self) -> data_health.DataHealthClient:
132+
"""Returns :py:class:`foundry_dev_tools.clients.data_health.DataHealthClient`."""
133+
return data_health.DataHealthClient(self)
134+
129135
@cached_property
130136
def data_proxy(self) -> data_proxy.DataProxyClient:
131137
"""Returns :py:class:`foundry_dev_tools.clients.data_proxy.DataProxyClient`."""

libs/foundry-dev-tools/src/foundry_dev_tools/utils/api_types.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ def assert_in_literal(option, literal, variable_name) -> None: # noqa: ANN001
5959
FolderRid = str
6060
"""A compass folder resource identifier."""
6161

62+
CheckRid = str
63+
"""A foundry data check resource identifier."""
64+
6265
JobSpecRid = str
6366
"""A jobspec resource identifier."""
6467

0 commit comments

Comments
 (0)