Skip to content

Commit eee3ae8

Browse files
committed
redirect stderr to stdout for better output comparison
1 parent 7e1fc39 commit eee3ae8

File tree

2 files changed

+32
-17
lines changed

2 files changed

+32
-17
lines changed

example/dataset_creation.ipynb

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,31 @@
1111
"cell_type": "markdown",
1212
"metadata": {},
1313
"source": [
14-
"## Create `DatasetDescr` object "
14+
"#### Setup"
1515
]
1616
},
1717
{
1818
"cell_type": "code",
1919
"execution_count": 1,
2020
"metadata": {},
21+
"outputs": [],
22+
"source": [
23+
"import sys\n",
24+
"# redirect stderr to stdout for better output comparison across runs with 'pytest --nbval'\n",
25+
"sys.stderr = sys.stdout"
26+
]
27+
},
28+
{
29+
"cell_type": "markdown",
30+
"metadata": {},
31+
"source": [
32+
"## Create `DatasetDescr` object "
33+
]
34+
},
35+
{
36+
"cell_type": "code",
37+
"execution_count": 2,
38+
"metadata": {},
2139
"outputs": [
2240
{
2341
"name": "stdout",
@@ -142,7 +160,7 @@
142160
},
143161
{
144162
"cell_type": "code",
145-
"execution_count": 2,
163+
"execution_count": 3,
146164
"metadata": {},
147165
"outputs": [
148166
{
@@ -173,7 +191,7 @@
173191
},
174192
{
175193
"cell_type": "code",
176-
"execution_count": 3,
194+
"execution_count": 4,
177195
"metadata": {},
178196
"outputs": [
179197
{
@@ -245,7 +263,7 @@
245263
},
246264
{
247265
"cell_type": "code",
248-
"execution_count": 4,
266+
"execution_count": 5,
249267
"metadata": {},
250268
"outputs": [
251269
{

example/load_model_and_create_your_own.ipynb

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@
8181
"\n",
8282
"from bioimageio.spec.utils import download\n",
8383
"\n",
84+
"# redirect stderr to stdout for better output comparison across runs with 'pytest --nbval'\n",
85+
"sys.stderr = sys.stdout\n",
86+
"\n",
8487
"# enable and configure loguru logging for bioimageio.spec and bioimageio.core\n",
8588
"logger.enable(\"bioimageio\")\n",
8689
"logger.remove()\n",
@@ -735,7 +738,7 @@
735738
},
736739
"outputs": [
737740
{
738-
"name": "stderr",
741+
"name": "stdout",
739742
"output_type": "stream",
740743
"text": [
741744
"Level 35\u001b[0m | \u001b[36mfield_warning\u001b[0m - description: Needs to be filled for FAIR compliance\u001b[0m\n",
@@ -753,7 +756,7 @@
753756
"traceback": [
754757
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
755758
"\u001b[1;31mValidationError\u001b[0m Traceback (most recent call last)",
756-
"Cell \u001b[1;32mIn[11], line 4\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21;01mpydantic\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m ValidationError\n\u001b[0;32m 2\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21;01mbioimageio\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mspec\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mmodel\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mv0_5\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m ModelDescr\n\u001b[1;32m----> 4\u001b[0m _ \u001b[38;5;241m=\u001b[39m \u001b[43mModelDescr\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m \u001b[38;5;66;03m# pyright: ignore[reportCallIssue]\u001b[39;00m\n",
759+
"Cell \u001b[1;32mIn[11], line 3\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21;01mbioimageio\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mspec\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mmodel\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mv0_5\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m ModelDescr\n\u001b[1;32m----> 3\u001b[0m _ \u001b[38;5;241m=\u001b[39m \u001b[43mModelDescr\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m \u001b[38;5;66;03m# pyright: ignore[reportCallIssue]\u001b[39;00m\n",
757760
"\u001b[1;31mValidationError\u001b[0m: 4 validation errors for ModelDescr:\nname\n Field required [input={'format_version': '0.5.5', 'type': 'model'}]\ninputs\n Field required [input={'format_version': '0.5.5', 'type': 'model'}]\noutputs\n Field required [input={'format_version': '0.5.5', 'type': 'model'}]\nweights\n Field required [input={'format_version': '0.5.5', 'type': 'model'}]"
758761
]
759762
}
@@ -796,7 +799,7 @@
796799
},
797800
"outputs": [
798801
{
799-
"name": "stderr",
802+
"name": "stdout",
800803
"output_type": "stream",
801804
"text": [
802805
"Level 35\u001b[0m | \u001b[36mfield_warning\u001b[0m - test_tensor: Needs to be filled for FAIR compliance\u001b[0m\n",
@@ -891,7 +894,7 @@
891894
},
892895
"outputs": [
893896
{
894-
"name": "stderr",
897+
"name": "stdout",
895898
"output_type": "stream",
896899
"text": [
897900
"Level 35\u001b[0m | \u001b[36mfield_warning\u001b[0m - test_tensor: Needs to be filled for FAIR compliance\u001b[0m\n",
@@ -1186,18 +1189,12 @@
11861189
}
11871190
},
11881191
"outputs": [
1189-
{
1190-
"name": "stderr",
1191-
"output_type": "stream",
1192-
"text": [
1193-
"Level 35\u001b[0m | \u001b[36mfield_warning\u001b[0m - tags: Needs to be filled for FAIR compliance\u001b[0m\n",
1194-
"Level 30\u001b[0m | \u001b[36mv0_5\u001b[0m - covers: Failed to generate cover image(s): Failed to construct cover image from shape (1, 2, 256, 256)\u001b[0m\n"
1195-
]
1196-
},
11971192
{
11981193
"name": "stdout",
11991194
"output_type": "stream",
12001195
"text": [
1196+
"Level 35\u001b[0m | \u001b[36mfield_warning\u001b[0m - tags: Needs to be filled for FAIR compliance\u001b[0m\n",
1197+
"Level 30\u001b[0m | \u001b[36mv0_5\u001b[0m - covers: Failed to generate cover image(s): Failed to construct cover image from shape (1, 2, 256, 256)\u001b[0m\n",
12011198
"created 'My cool Model'\n"
12021199
]
12031200
}
@@ -1344,7 +1341,7 @@
13441341
},
13451342
"outputs": [
13461343
{
1347-
"name": "stderr",
1344+
"name": "stdout",
13481345
"output_type": "stream",
13491346
"text": [
13501347
"\u001b[33m\u001b[1mWARNING \u001b[0m | \u001b[36m_get_conda_env\u001b[0m - \u001b[33m\u001b[1mUPDATE NEEDED: Leaving torchvision and torchaudio unpinned for pytorch==2.8.0\u001b[0m\n",

0 commit comments

Comments
 (0)