Currently, define_function is only implemented in the Spark backend, and it calls into the JVM to set a piece of state on a static object to define a function. I propose that in order to support the client/server execution model, we redesign define_function to record the function mapping only on the Python client, and change the format of the message communicated to the server to include registered functions.
Currently, the message sent to the server to execute is a single IR string. We can change this message to a JSON mapping with two fields (for now… reference genomes could be sent similarly, though):
ir will be a string, and
functions will be a list of mappings with the same fields as the Python function object: