Repository navigation
Docs: Python functions and record events, with tests that pin each statement first (refs #267) - #284
Merged
Merged
Conversation
…each statement first (refs #267) Row 8 of the docs audit: register_function and db.on were only in example 28. The existing tests already pin the basics (names, argument counts, return types, a failing function, each event, the veto), so the new behavior tests pin what the page adds: what a function receives from a stored value (datetime, date, Decimal, vertex, edge, document), that a raising function or callback undoes its statement and leaves the transaction going (26.11.1), that a function belongs to the process and an event to one database, which thread runs a function or an event (caller, engine thread for async writes), that a waiting function blocks only its own statement, when an after event fires relative to the commit, and what a callback may do (read, write into the same transaction, fire further events, change the record). A docs-page test runs every Python block in order and checks the printed output. The tests were written from the sources without a local run (the guard hook blocks pytest); CI is the first run on both backends. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…onverts it with str() (refs #267) The JVM run of the docs-page test failed in the Journal block: record.get_type_name() returns the Java string on arcadedb-jvm (graph.py returns getTypeName() as is), and "created " + java_string raises TypeError, while the native wrapper returns a str. record.get(...), to_dict() values and get_rid() are Python str on both builds. New behavior test pins the type per backend, inside a callback and outside one; the page says once, in the callback section, to write str(record.get_type_name()), and the block does. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
tae898
force-pushed
the
docs/functions-events
branch
from
November 6, 2026 07:05
ca2c583 to
e11394a
Compare
tae898
marked this pull request as ready for review
November 6, 2026 07:08
This was referenced Nov 6, 2026
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.
Refs #267 (row 8). Adds the page
how-to/functions-and-events.adoc(Python functions in SQL and openCypher, anddb.onrecord events), one nav line, and links from the quickstart, installation, databases-and-queries and transactions pages (one added anchor,failed-statement, on the transactions page).The existing tests (
test_python_callbacks.py,test_native_udf.py,test_python_function_interrupt.py) already pin the basics, so the page header links to them andtests/test_functions_and_events_behavior.pypins only what the page adds: the Python types a function receives from a stored value (datetime,date,Decimal, list, map, and a vertex, edge or document as its wrapper), openCypher arguments and results, that a function runs once per row, that a raising function or callback undoes its statement and leaves the transaction going (26.11.1), that a function belongs to the process and an event to one database (and what closing a database drops), which thread runs a function or an event, that a waiting function blocks only its own statement, when anafter_*event fires relative to the commit, onlyFalsevetoes, the exact-type filter, and what a callback may do (read, write into the same transaction, fire further events, change the record).tests/test_docs_functions_page.pyruns every Python block of the page in order and checks the printed output.CI: the first JVM run found one wrong page statement (
get_type_name()is a Java string onarcadedb-jvm; see the surprises); it is fixed, and the JVM test workflow on that head passed (24 of 24 jobs). The head was then rebased onto main after #282 and its run is in progress; the native parity legs run now that the PR is ready. I could not run pytest on the laptop (a guard blocks it), so the native-side expectations are first observed by CI. Issue #286 tracks theget_type_name()inconsistency; a fix PR follows after this one merges.Surprises, none filed:
before_createcallback that callsrecord.set(...)changes what is stored onarcadedb-jvm(the callback holds the engine's mutable record) and has no effect onarcadedb(it holds a snapshot dict built inNativeExtras.appendRecord, and only the veto flag goes back). The test pins both and the page says not to rely on it.arcadedb, abefore_updatecallback gets a record with an RID, which the native wrapper treats as read-only, sorecord.set(...)there raises instead of being ignored (read from_native/records.py, not tested).register_functionsays the GIL serializes the calls andfndoes not run in parallel. That holds only whilefnholds the GIL: a function that waits (sleep,Event, I/O) lets other statements run, and a free-threaded build has no GIL. The page says to writefnas if two threads could call it at once.record.get_type_name()returns a Java string onarcadedb-jvm(graph.pyreturnsgetTypeName()unconverted) and a Pythonstronarcadedb. It compares equal to astr, but"created " + record.get_type_name()raisesTypeErroron the JVM build only; the first JVM run caught it in a page block.record.get(...),to_dict()values andget_rid()arestron both. The page says to usestr(record.get_type_name()), and a test pins the type per backend, inside a callback and outside one.What remains of #267 after this: rows 4 and 5 (PR #282), row 7, rows 10 and 11 (another agent), and 1, 6, 13 and the stale items under #264.
🤖 Generated with Claude Code