Skip to content

Commit 607122d

Browse files
committed
Merge branch 'main' into GSK-1567-add-number-to-word-transformation
2 parents 19e7996 + 782f295 commit 607122d

130 files changed

Lines changed: 4465 additions & 2938 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build-python.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ jobs:
112112
restore-keys: ${{ matrix.os }}-${{ matrix.python-version }}-python-giskard-test-resources
113113

114114
- name: Install dependencies
115-
run: pdm install -G :all
115+
run: |
116+
pdm install -G :all
117+
pdm list
116118
117119
- name: Lint code
118120
run: pdm run lint
@@ -174,7 +176,8 @@ jobs:
174176
run: pdm build
175177

176178
- name: "Python client: archive built artifacts"
177-
if: ${{ github.event_name == 'push' && matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10' }}
179+
# Upload needs to be done only once by workflo run, so we need to select one only in the matrix
180+
if: ${{ github.event_name == 'push' && matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10' && !matrix.langchain_minimal && !matrix.pandas_v1 && !matrix.pydantic_v1 }}
178181
uses: actions/upload-artifact@v4
179182
with:
180183
path: dist/*whl

.github/workflows/pre-commit-checks.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
env:
1010
GSK_DISABLE_ANALYTICS: true
1111
SENTRY_ENABLED: false
12+
GITGUARDIAN_API_KEY: ${{ secrets.GITGUARDIAN_API_KEY }}
1213
defaults:
1314
run:
1415
shell: bash
@@ -20,3 +21,5 @@ jobs:
2021
- uses: actions/checkout@v4
2122
- uses: actions/setup-python@v5
2223
- uses: pre-commit/action@v3.0.0
24+
env:
25+
SKIP: ggshield

.pre-commit-config.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ repos:
99
- "pyproject.toml"
1010

1111
- repo: https://github.com/ambv/black
12-
rev: 23.11.0
12+
rev: 23.12.1
1313
hooks:
1414
- id: black
1515
files: '^.*\.py$'
1616
args:
1717
- "--config"
1818
- "pyproject.toml"
19-
19+
stages: [commit]
2020
- repo: https://github.com/astral-sh/ruff-pre-commit
2121
rev: v0.1.6
2222
hooks:
@@ -27,3 +27,10 @@ repos:
2727
- "pyproject.toml"
2828
- "--fix"
2929
- "--exit-non-zero-on-fix"
30+
31+
- repo: https://github.com/gitguardian/ggshield
32+
rev: v1.23.0
33+
hooks:
34+
- id: ggshield
35+
language_version: python3
36+
stages: [commit]
271 KB
Loading
161 KB
Loading

docs/giskard_hub/installation_hub/install_hfs/index.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,16 @@ The demo Giskard Space is read-only. To upload your own models, datasets and pro
3232

3333
Leverage the Hugging Face (HF) Space to easily test & debug your own ML models. This implies that you deploy a private HF space containing the Giskard Hub and upload your Python objects (such as ML models, test suites, datasets, slicing functions, or transformation functions) to your HF Space. To do so, follow these steps:
3434

35-
### 1. Duplicate the demo Space from Giskard
36-
Begin by visiting the [Giskard HF space](https://huggingface.co/spaces/giskardai/giskard) and duplicate the space (as depicted below).
35+
### 1. Create a new Space using the Giskard Docker template
36+
Begin by visiting [HuggingFace Spaces](https://huggingface.co/spaces) and click on "Create new Space" as depicted below.
37+
Alternatively, navigate directly [here](https://huggingface.co/new-space?template=giskardai%2Fgiskard) to create a new space
38+
from the Giskard template.
3739

38-
![Duplication image](../../../assets/integrations/hfs/duplicate_this_space.png)
40+
![New space](../../../assets/integrations/hfs/create_new_space.png)
3941

40-
During duplication, you're presented with options to modify the **owner**, the **visibility** and the **hardware**:
42+
You can then deploy Giskard on Spaces with just a few clicks. You need to define the **Owner** (your personal account or an organization), a **Space name**, and the **Visibility**.
4143

42-
![Space Duplication popup](../../../assets/integrations/hfs/paid_tier.png)
44+
![Space from template](../../../assets/integrations/hfs/create_from_template.png)
4345

4446
:::{hint}
4547
**Owner and visibility**:
@@ -48,7 +50,7 @@ If you don't want to publicly share your model, set your Space to **private** an
4850
We recommend to use paid hardware to get the best out of Giskard's HF Space. You can also incorporate [persistent storage](https://huggingface.co/docs/hub/spaces-storage) to retain your data even after the Space reboots. With free hardware that lacks persistent storage, any inactivity beyond 48 hours will result in the space being shut down. This will lead to a loss of all data within your Giskard Space.
4951
:::
5052

51-
Once you're ready, click on Duplicate Space. The building process will take several minutes.
53+
Once you're ready, click on "Create Space" to confirm the creation. The build process will take a few minutes.
5254

5355
### 2. Create a new Giskard project
5456

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ integrations/mlflow/index
6161
integrations/wandb/index
6262
integrations/dagshub/index
6363
integrations/huggingface/index
64+
integrations/pytest/index
6465
```
6566

6667
```{toctree}

docs/integrations/huggingface/index.md

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,16 @@ The demo Giskard Space is read-only. To upload your own models, datasets and pro
3030

3131
Leverage the Hugging Face (HF) Space to easily test & debug your own ML models. This implies that you deploy a private HF space containing the Giskard Hub and upload your Python objects (such as ML models, test suites, datasets, slicing functions, or transformation functions) to your HF Space. To do so, follow these steps:
3232

33-
### 1. Duplicate the demo Space from Giskard
34-
Begin by visiting the [Giskard HF space](https://huggingface.co/spaces/giskardai/giskard) and duplicate the space (as depicted below).
33+
### 1. Create a new Space using the Giskard Docker template
34+
Begin by visiting [HuggingFace Spaces](https://huggingface.co/spaces) and click on "Create new Space" as depicted below.
35+
Alternatively, navigate directly [here](https://huggingface.co/new-space?template=giskardai%2Fgiskard) to create a new space
36+
from the Giskard template.
3537

36-
![Duplication image](../../assets/integrations/hfs/duplicate_this_space.png)
38+
![New space](../../assets/integrations/hfs/create_new_space.png)
3739

38-
During duplication, you're presented with options to modify the **owner**, the **visibility** and the **hardware**:
40+
You can then deploy Giskard on Spaces with just a few clicks. You need to define the **Owner** (your personal account or an organization), a **Space name**, and the **Visibility**.
3941

40-
![Space Duplication popup](../../assets/integrations/hfs/paid_tier.png)
42+
![Space from template](../../assets/integrations/hfs/create_from_template.png)
4143

4244
:::{hint}
4345
**Owner and visibility**:
@@ -46,7 +48,7 @@ If you don't want to publicly share your model, set your Space to **private** an
4648
We recommend to use paid hardware to get the best out of Giskard's HF Space. You can also incorporate [persistent storage](https://huggingface.co/docs/hub/spaces-storage) to retain your data even after the Space reboots. With free hardware that lacks persistent storage, any inactivity beyond 48 hours will result in the space being shut down. This will lead to a loss of all data within your Giskard Space.
4749
:::
4850

49-
Once you're ready, click on Duplicate Space. The building process will take several minutes.
51+
Once you're ready, click on "Create Space" to confirm the creation. The build process will take a few minutes.
5052

5153
### 2. Create a new Giskard project
5254

@@ -85,6 +87,23 @@ client = GiskardClient(url, api_key, hf_token)
8587
client.upload(...)
8688
```
8789

90+
## Upgrade your Giskard Hub in HuggingFace Spaces
91+
92+
When installing the Hub in HuggingFace Spaces, the latest version will be fetched. The version will always remain the same unless you manually run an upgrade. Upgrades are recommended to get the latest features and bug fixes deployed by Giskard.
93+
94+
To do so, you can open the `Dockerfile` in your repository. The first line should be similar to this:
95+
96+
```
97+
FROM docker.io/giskardai/giskard:<version>
98+
```
99+
100+
Change `<version>` to the latest version and save the file. After the build and rebooting of the Space, you should be able to enjoy the latest features in the Giskard Hub.
101+
102+
:::{warn}
103+
If you have not activated persistent storage, you might loose the data in your current Giskard instance on Hugging Face Spaces.
104+
Make sure that your projects have backups in case.
105+
:::
106+
88107
## Feedback and support
89108

90109
If you have suggestions or need specialized support, please join us on the [Giskard Discord community](https://discord.gg/ABvfpbu69R) or reach out on [Giskard's GitHub repository](https://github.com/Giskard-AI/giskard).

docs/integrations/index.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ mlflow/index
99
wandb/index
1010
dagshub/index
1111
huggingface/index
12+
pytest/index
1213
```
1314

1415
::::::{grid} 1 1 2 2
@@ -38,3 +39,8 @@ huggingface/index
3839
:text-align: center
3940
:link: dagshub/index.html
4041
::::
42+
43+
::::{grid-item-card} <br/><h3>🧪 Pytest</h3>
44+
:text-align: center
45+
:link: pytest/index.html
46+
::::
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {
6+
"collapsed": false
7+
},
8+
"source": [
9+
"# Example script\n",
10+
"\n",
11+
"This example showcases how to wrap you test to integrate them with pytest."
12+
]
13+
},
14+
{
15+
"cell_type": "code",
16+
"execution_count": null,
17+
"metadata": {
18+
"collapsed": false
19+
},
20+
"outputs": [],
21+
"source": [
22+
"import pytest\n",
23+
"\n",
24+
"from giskard import Dataset, Model, Suite, demo\n",
25+
"from giskard.testing import test_accuracy, test_f1\n",
26+
"\n",
27+
"model_raw, df = demo.titanic()\n",
28+
"\n",
29+
"wrapped_dataset = Dataset(\n",
30+
" name=\"Test Data Set\",\n",
31+
" df=df,\n",
32+
" target=\"Survived\",\n",
33+
" cat_columns=[\"Pclass\", \"Sex\", \"SibSp\", \"Parch\", \"Embarked\"],\n",
34+
")\n",
35+
"\n",
36+
"wrapped_model = Model(model=model_raw, model_type=\"classification\", name=\"Classifier v1\")\n",
37+
"\n",
38+
"suite = (\n",
39+
" Suite(\n",
40+
" default_params={\n",
41+
" \"model\": wrapped_model,\n",
42+
" \"dataset\": wrapped_dataset,\n",
43+
" }\n",
44+
" )\n",
45+
" .add_test(test_f1(threshold=0.6))\n",
46+
" .add_test(test_accuracy(threshold=1)) # Certain to fail\n",
47+
")\n",
48+
"\n",
49+
"\n",
50+
"@pytest.fixture\n",
51+
"def dataset():\n",
52+
" return wrapped_dataset\n",
53+
"\n",
54+
"\n",
55+
"@pytest.fixture\n",
56+
"def model():\n",
57+
" return wrapped_model\n",
58+
"\n",
59+
"\n",
60+
"# Single wrapped test\n",
61+
"def test_only_accuracy(dataset, model):\n",
62+
" test_accuracy(model=model, dataset=dataset, threshold=1).assert_()\n",
63+
"\n",
64+
"\n",
65+
"# Parametrise tests from suite\n",
66+
"@pytest.mark.parametrize(\"test_partial\", suite.to_unittest(), ids=lambda t: t.fullname)\n",
67+
"def test_giskard(test_partial):\n",
68+
" test_partial.assert_()\n"
69+
]
70+
},
71+
{
72+
"cell_type": "markdown",
73+
"metadata": {
74+
"collapsed": false
75+
},
76+
"source": []
77+
}
78+
],
79+
"metadata": {
80+
"kernelspec": {
81+
"display_name": "Python 3",
82+
"language": "python",
83+
"name": "python3"
84+
},
85+
"language_info": {
86+
"codemirror_mode": {
87+
"name": "ipython",
88+
"version": 2
89+
},
90+
"file_extension": ".py",
91+
"mimetype": "text/x-python",
92+
"name": "python",
93+
"nbconvert_exporter": "python",
94+
"pygments_lexer": "ipython2",
95+
"version": "2.7.6"
96+
}
97+
},
98+
"nbformat": 4,
99+
"nbformat_minor": 0
100+
}

0 commit comments

Comments
 (0)