Skip to content

How do we use ext-code-file with rjsonnet #28

@srijansanket

Description

@srijansanket

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 "<string>", line 1, in <module>
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"
   }
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions