Update validation for graphml parser + tests#151
Open
Brqndon1 wants to merge 2 commits into
Open
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Added input validation to
parse_graph_attributesinGraphmlParser, mirroring the validation style offact_parser.pybut emittingwarnings.warn(...)and skipping the offending attribute (or whole node/edge) instead of raising.Validation rules implemented
_COMPONENT_RE. One warning per bad node/edge, all attributes on it skipped (not one warning per attribute)._PREDICATE_RE.int(...)→float(...)bug in the comma-separated interval string parser. Added range and order checks (0 <= lower <= 1,0 <= upper <= 1,lower <= upper)."1.5") now warn-and-skip instead of silently falling through to a categorical label.key-valuelabels are validated against_PREDICATE_RE— values containing spaces, commas, parens etc. now warn-and-skip rather than producing malformed labels.Tests
New file
tests/unit/dont_disable_jit/test_graphml_parser.pymirroring the structure oftest_fact_parser.py:TestValidGraphmlParsing(10 tests) — numeric in range, single-string numeric, interval string (regression), edge with numeric, edge with interval, categorical labels, boundary values 0 / 1 / 0.0 / 1.0, multiple valid attributes,static_facts=Truepropagation.TestInvalidGraphmlParsing(12 tests) — every bullet from the task spec's "Invalid" list: bad keys, empty keys, out-of-range numerics (string and type), bad node/edge IDs, all four interval-string failure modes, composed-label regex failures, whitespace values.TestEdgeCasesConditions(4 tests) — empty graph, node with no attributes, label accumulation across multiple nodes, mixed-case keys preserved.