Repository navigation
Python functions in SQL and openCypher, record events, Document.save()/delete() errors (#19) - #29
Merged
Merged
Conversation
…allbacks (#19) Ported from humemai/arcadedb-embedded-python #391, with the later fixes to the same files (#438 JPype race with Ctrl-C is a KeyboardInterrupt, #454 proxy classes defined once under a lock): - Database.register_function() / unregister_function(), callable from SQL and as py.<name> from openCypher - Database.on() / off() record event callbacks (before_* may veto a write) - Document.save() and delete() raise ArcadeDBError instead of the raw Java exception - new Java glue: PythonFunctions.java and PythonRecordEvents.java (compiled into the existing arcadedb-python-bridge.jar by the build that already compiles src/java) - example 28 Based on port/runtime-fixes (#27). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 24, 2026
The only conflict was examples/README.md: this branch adds the entry for example 28 and main (through runtime-fixes) the entry for example 29 at the same spot. Kept both, in numeric order. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
# Conflicts: # examples/README.md
tae898
added a commit
that referenced
this pull request
Oct 25, 2026
Bridge: float vectors cross as one binary buffer, not as JSON text or one JPype call per element (stacked on #29)
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.
Part of #19 (Features group, 1 of 2). Ported by hand from humemai/arcadedb-embedded-python#391 (Python functions in SQL and openCypher, record events) with the later fixes to the same files: humemai#438 (a Ctrl-C that makes JPype fail with "Fatal error occurred" is a KeyboardInterrupt) and humemai#454 (the JPype proxy classes are defined once, under a lock). Formatted with black 26.10.1 and isort 9.0.2
--profile black, Bandit clean with the CI invocation from CLAUDE.md.Depends on #27. This branch is based on
port/runtime-fixes, so the diff shows only this PR. It needs #27 for the read-only open and the serializedstart_jvm()(the proxy lock builds on it); GitHub retargets the PR tomainonce #27 merges. It does not need #26:test_python_function_interrupt.pypasses with and without it (checked below).What is in it
Database.register_function()/unregister_function(): a Python callable usable from SQL (SELECT and WHERE) and, aspy.<name>, from openCypher; an exception in the function is a query error, and a Ctrl-C during the statement is aKeyboardInterrupt. New modulecallbacks.py.Database.on()/off(): record event callbacks (before_create,after_create,before_update,after_update,before_delete,after_delete); abefore_*callback that returnsFalsevetoes the write.Document.save()andDocument.delete()(graph.py) raiseArcadeDBErrorinstead of the raw Java exception (a read-only database, a duplicate key, a vetoed write). The Python runtime fixes in src: serialized start_jvm(), heap default, log directory, XML limits, read-only open, async docs #27 testtest_read_only_begin_is_not_refused_the_write_and_the_commit_arechanges to expect that.28_python_functions_and_record_events.pyand its entry inexamples/README.md.test_python_callbacks.py,test_python_function_interrupt.py(not collected on Windows, inconftest.py).Java glue and what the wheel must contain
Two new classes,
src/java/com/arcadedb/python/PythonFunctions.javaandPythonRecordEvents.java. No build change is needed:scripts/Dockerfile.buildandscripts/build-native.shalready compile every.javafile undersrc/javaintoarcadedb-python-bridge.jar. The wheel must therefore containPythonFunctions,PythonFunctions$Callback,PythonRecordEventsandPythonRecordEvents$Callbackinarcadedb_embedded/jars/arcadedb-python-bridge.jar(the overlay below has 17 classes in that jar, 11 before). The existingtest_jar_provenance.pyand payload tests need no change.Tests run
The tests ran on the Python and Java sources of this branch overlaid on an unpacked linux/amd64 wheel (engine 26.11.1-SNAPSHOT), with the bridge jar recompiled from
src/java(javac 21) and put in place of the wheel's; a full wheel build was not needed. Python 3.12, JPype latest.Example 28 also ran to completion against the overlay. CI of this PR has not been looked at yet when this was written.
Not included
docs/api/database.md, the guides, the example page): the docs move to the Antora component in docs: Antora component arcadedb-python with the first slice of pages #23, they are not ported here.ArcadeDBErrorwrapping is only forDocument.save()/delete();VertexandEdgeinherit it.🤖 Generated with Claude Code