Open tsmeele opened 1 month ago
I believe only strings can be passed across REP boundaries. We recently added documentation which demonstrates how to pass values between the NREP and PREP. See https://github.com/irods/irods_rule_engine_plugin_python?tab=readme-ov-file#how-do-i-pass-values-back-to-the-caller-across-rule-engine-plugin-boundaries.
What happens if intfunction
sets *output
to "42"
?
I'm very happy that both the example AND the documentation use 42.
Well spotted Terrell! Now what was the question? This number seemed most appropriate for Python.
It turns out that the Python exception in the server log only shows up when the remote block is used. Nevertheless the exception is a good indication of what actually seems to happen.
Without the remote block, the interpretation issue remains, and is influenced by the type of the variable passed by caller as shown by the following snippets:
Updated intfunction:
intfunction(*output1, *output2, *output3, *output4) {
*output1 = 42;
*output2 = 42;
*output3 = "42";
*output4 = "42";
}
Updated myrule and irule output:
irods@irods:/etc/irods$ cat myrule.r
#!/usr/bin/irule -r irods_rule_engine_plugin-python-instance -F
def main(rule_args, callback, rei):
output1 = 10
output2 = '11'
output3 = 12
output4 = '13'
ret = callback.intfunction(output1, output2, output3, output4)
callback.writeLine("stdout", "Answer is ={}=".format(ret))
input null
output ruleExecOut
irods@irods:/etc/irods$ irule -r irods_rule_engine_plugin-python-instance -F myrule.r
Answer is ={'code': 0, 'status': True, 'arguments': [10, '*', 12, '42']}=
irods@irods:/etc/irods$
Where caller variable is an int, the variable is not updated with output from intfunction. Where caller variable is string, its content is updated by intfunction yet int values returned by intfunction get mangled (probably interpreted as a char).
Server: iRODS 4.3.2
Preconditions: We execute a Python rule "myrule" via irule, and the rule does a callback to an iRods rule language rule "intfunction". The rule intfunction returns an integer value calculated within a remote block.
Expected: No errors in server log, integer value returned from intfunction to myrule.
Actual: The integer value is misinterpreted, and the server log shows an exception "no to_python (by value) converter found for C++ type: int"
Issue can be reproduced using below iRODS rule intfunction:
Example client rule myrule (executed via irule and Python rule engine) that shows issue:
iRule output: (note the asterisk as output instead of value 42)
RodsLog entry in syslog: