Open
Description
I have tried to come up with the simplest example I can to demonstrate this bug:
import textwrap
import _gojsonnet
file_dict = {
"file1.libsonnet": textwrap.dedent(
"""
local funcImport = import "file2.libsonnet";
{
my_key: funcImport.sampleFunc()
}
"""
),
"file2.libsonnet": textwrap.dedent(
"""
local sampleFunc = function() (
3
);
{
sampleFunc:: sampleFunc
}
"""
),
}
def import_callback(from_dir, import_str):
print(f"Importing {import_str}")
return from_dir, file_dict[import_str]
def main():
snippet = textwrap.dedent(
"""
local data = import "file1.libsonnet";
data
"""
)
data = _gojsonnet.evaluate_snippet(
"test_file",
snippet,
import_callback=import_callback,
)
print(data)
if __name__ == "__main__":
main()
Output:
$ python3 py_binding.py
Importing file1.libsonnet
Importing file2.libsonnet
Traceback (most recent call last):
File "/Users/cayoub/Desktop/reproducer/py_binding.py", line 49, in <module>
main()
File "/Users/cayoub/Desktop/reproducer/py_binding.py", line 40, in main
data = _gojsonnet.evaluate_snippet(
RuntimeError: RUNTIME ERROR: Field does not exist: sampleFunc
4:13-34 object <anonymous>
During manifestation
I am running Python 3.9.4
with gojsonnet==0.17.0
.
This problem seems to be unique to the Python bindings from what I can tell. When I create these 3 files normally and run with the jsonnet
CLI command, it works without issue:
$ jsonnet fileMain.libsonnet
{
"my_key": 3
}
Let me know if there is further information I should provide for this. This is the only thing preventing us from migrating from the C++ version (where our Python code works without issue).