Skip to content

Commit 527cd0f

Browse files
committed
Clean up marshmallow warnings + count pytest tests in perf report
Three layered cleanups on the now-green perf-test workflow: 1. vfb_queries.py: migrate marshmallow 3→4 deprecations in our own code so RemovedInMarshmallow4Warning / ChangedInMarshmallow4Warning stop firing for lines 138, 308, 309. - `missing=` → `load_default=` on four schema fields at preview_columns, preview_results, output_format, count (136-139). - `fields.Field()` → `fields.Raw()` on Publications and Synonyms (308-309). No behavioural change; both renames are marshmallow's recommended migration path. 2. pyproject.toml [tool.pytest.ini_options]: filterwarnings to silence the marshmallow library-internal deprecation warnings (marshmallow/fields.py:582,776,986,1218) that bubble up from transitive deps (vfb_connect, dataclasses-json) using legacy patterns. Our own code's warnings remain visible because they live in our source tree, not marshmallow's. 3. performance-test.yml step #9: report counts now sum both unittest- and pytest-format test lines. Was previously showing "Total Tests: 1" — only the legacy term_info_performance unittest line — because grep "^test_" doesn't match pytest's `src/test/...::TestX::test_y PASSED`. Parser now sums: unittest: ^test_ AND ^(FAIL|ERROR): pytest: " (PASSED|FAILED|ERROR)( |$)" Totals reflect every test the workflow actually ran across all three test steps.
1 parent 4fecde7 commit 527cd0f

3 files changed

Lines changed: 40 additions & 20 deletions

File tree

.github/workflows/performance-test.yml

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -264,20 +264,28 @@ jobs:
264264
fi
265265
echo "" >> performance.md
266266
267-
# Count successes and failures. `grep -c` already prints `0` and
268-
# exits 1 on no-match, so combining it with `|| echo "0"` gave
269-
# variables containing literal `"0\n0"` and broke the arithmetic
270-
# below ("syntax error in expression (error token is "0")").
271-
# Swallow the exit code with `|| true` and let grep's own output
272-
# stand; default to 0 only if the variable is empty (file
273-
# missing).
274-
TOTAL_TESTS=$(grep -c "^test_" performance_test_output.log 2>/dev/null || true)
275-
FAILED_TESTS=$(grep -c "FAIL:" performance_test_output.log 2>/dev/null || true)
276-
ERROR_TESTS=$(grep -c "ERROR:" performance_test_output.log 2>/dev/null || true)
277-
TOTAL_TESTS=${TOTAL_TESTS:-0}
278-
FAILED_TESTS=${FAILED_TESTS:-0}
279-
ERROR_TESTS=${ERROR_TESTS:-0}
280-
PASSED_TESTS=$((TOTAL_TESTS - FAILED_TESTS - ERROR_TESTS))
267+
# Count successes and failures. The log mixes both unittest
268+
# (`test_xxx ... ok`/`FAIL:`/`ERROR:`) and pytest
269+
# (`... PASSED`/`FAILED`/`ERROR` lines) outputs depending on
270+
# which step wrote it. Sum both formats so the report shows a
271+
# meaningful total instead of "Total: 1" (which is what we got
272+
# when only the unittest-format legacy step matched).
273+
#
274+
# `grep -c` already prints `0` and exits 1 on no-match, so
275+
# `|| true` is needed to swallow the exit code (otherwise
276+
# set -e aborts the step). Default empty captures to 0.
277+
UNITTEST_TESTS=$(grep -cE "^test_" performance_test_output.log 2>/dev/null || true)
278+
PYTEST_TESTS=$(grep -cE " (PASSED|FAILED|ERROR)( |$)" performance_test_output.log 2>/dev/null || true)
279+
UNITTEST_FAIL=$(grep -cE "^(FAIL|ERROR):" performance_test_output.log 2>/dev/null || true)
280+
PYTEST_FAIL=$(grep -cE " (FAILED|ERROR)( |$)" performance_test_output.log 2>/dev/null || true)
281+
UNITTEST_TESTS=${UNITTEST_TESTS:-0}
282+
PYTEST_TESTS=${PYTEST_TESTS:-0}
283+
UNITTEST_FAIL=${UNITTEST_FAIL:-0}
284+
PYTEST_FAIL=${PYTEST_FAIL:-0}
285+
TOTAL_TESTS=$((UNITTEST_TESTS + PYTEST_TESTS))
286+
FAILED_TESTS=$((UNITTEST_FAIL + PYTEST_FAIL))
287+
ERROR_TESTS=0 # ERROR counts already folded into FAILED above
288+
PASSED_TESTS=$((TOTAL_TESTS - FAILED_TESTS))
281289
282290
echo "### Test Statistics" >> performance.md
283291
echo "" >> performance.md

pyproject.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,16 @@ build-backend = "setuptools.build_meta"
1212
# blocks in performance.md — pure noise.
1313
markers = [
1414
"integration: integration tests that exercise the live VFB upstream (Neo4j, SOLR, owlery). Skip via -m 'not integration'.",
15+
]
16+
17+
# Silence the marshmallow deprecation warnings that bubble up from inside
18+
# the library itself (marshmallow/fields.py:582,776,986,1218). Our own
19+
# code calls to `missing=`/`fields.Field()` have been migrated to
20+
# `load_default=`/`fields.Raw()`, but transitive deps (e.g. via
21+
# vfb_connect / dataclasses-json) still trigger them. Hiding the
22+
# library-internal noise — but NOT user-code DeprecationWarnings —
23+
# keeps performance.md readable.
24+
filterwarnings = [
25+
"ignore::marshmallow.warnings.RemovedInMarshmallow4Warning",
26+
"ignore::marshmallow.warnings.ChangedInMarshmallow4Warning",
1527
]

src/vfbquery/vfb_queries.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@ class QuerySchema(Schema):
133133
function = fields.String(required=True)
134134
takes = fields.Nested(TakesSchema(), required=False, missing={})
135135
preview = fields.Integer(required=False, missing=0)
136-
preview_columns = fields.List(fields.String(), required=False, missing=[])
137-
preview_results = fields.List(fields.Dict(), required=False, missing=[])
138-
output_format = fields.String(required=False, missing='table')
139-
count = fields.Integer(required=False, missing=-1)
136+
preview_columns = fields.List(fields.String(), required=False, load_default=[])
137+
preview_results = fields.List(fields.Dict(), required=False, load_default=[])
138+
output_format = fields.String(required=False, load_default='table')
139+
count = fields.Integer(required=False, load_default=-1)
140140

141141
class License:
142142
def __init__(self, iri, short_form, label, icon, source, source_iri):
@@ -305,8 +305,8 @@ class TermInfoOutputSchema(Schema):
305305
IsPaintedDomain = fields.Bool(missing=False, required=False)
306306
Domains = fields.Dict(keys=fields.Integer(), values=fields.Nested(ImageSchema()), required=False, allow_none=True)
307307
Licenses = fields.Dict(keys=fields.Integer(), values=fields.Nested(LicenseSchema()), required=False, allow_none=True)
308-
Publications = fields.List(fields.Dict(keys=fields.String(), values=fields.Field()), required=False)
309-
Synonyms = fields.List(fields.Dict(keys=fields.String(), values=fields.Field()), required=False, allow_none=True)
308+
Publications = fields.List(fields.Dict(keys=fields.String(), values=fields.Raw()), required=False)
309+
Synonyms = fields.List(fields.Dict(keys=fields.String(), values=fields.Raw()), required=False, allow_none=True)
310310
Technique = fields.List(fields.String(), required=False, allow_none=True)
311311

312312
@post_load

0 commit comments

Comments
 (0)