messense / messense/rjsonnet-py

How do we use ext-code-file with rjsonnet

Open
#28 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
12
Forks
3
PR merge metrics
No merged PRs in 30d

Description

`python -c 'import rjsonnet as j; f = j.evaluate_file("test.jsonnet", ext_codes={"data": "file.jsonnet"}); print(f);'`

fails with
```
Traceback (most recent call last):
File "", line 1, in
RuntimeError: variable is not defined: file
```

from the code, `ext_codes` maps to `context_initializer.add_ext_code` which is supposed to handle both variable names and file paths

here test.jsonnet is something like

```
local i = std.extVar("data");
[i]
```

and file.jsonnet is
```
local data = {
a: "foo",
};

data
```

This works perfectly fine with jrsonnet
`./jrsonnet --ext-code-file "data=new.jsonnet" test.jsonnet`
with output
```
[
{
"a": "foo"
}
]
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the Python invocation using rjsonnet.evaluate_file and trace how ext_codes reaches context_initializer.add_ext_code. Compare the test.jsonnet and file.jsonnet examples with jrsonnet's --ext-code-file behavior. Done means the reported invocation handles the file-backed external code without the undefined-variable error and produces the expected object output.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.