Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow patching of StringIdx values #81

Open
gatecat opened this issue May 10, 2021 · 0 comments
Open

Allow patching of StringIdx values #81

gatecat opened this issue May 10, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@gatecat
Copy link
Contributor

gatecat commented May 10, 2021

At the moment, patching of StringIdx values fails. Consider the following example:

parameters.yaml:

cells:
  - cellType: FOO

running

python -mfpga_interchange.patch  --schema_dir ~/fpga-interchange-schema/interchange --patch_path parameterDefs --schema device --patch_format yaml LIFCL-17.device parameters.yaml LIFCL-17-patched.device

fails with

Traceback (most recent call last):
  File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/david/python-fpga-interchange/fpga_interchange/patch.py", line 72, in <module>
    main()
  File "/home/david/python-fpga-interchange/fpga_interchange/patch.py", line 65, in main
    patch_capnp(message, patch_path, args.patch_format, f)
  File "/home/david/python-fpga-interchange/fpga_interchange/patch.py", line 37, in patch_capnp
    read_format_to_message(message_to_populate, patch_format, in_f)
  File "/home/david/python-fpga-interchange/fpga_interchange/convert.py", line 83, in read_format_to_message
    from_rapidyaml(message, yaml_tree)
  File "/home/david/python-fpga-interchange/fpga_interchange/rapidyaml_support.py", line 393, in from_rapidyaml
    from_reader(message, data, RapidYamlReader)
  File "/home/david/python-fpga-interchange/fpga_interchange/converters.py", line 458, in from_reader
    from_reader(
  File "/home/david/python-fpga-interchange/fpga_interchange/converters.py", line 479, in from_reader
    value = reader.read_scalar(field_which, value)
  File "/home/david/python-fpga-interchange/fpga_interchange/rapidyaml_support.py", line 335, in read_scalar
    return int(field_data)
ValueError: invalid literal for int() with base 10: 'FOO'

As there is no special casing for indexed strings, it is expecting an index into the string pool rather than a string (which isn't feasibly human-writeable). These will need to be handled by looking into, and updating if needed, the list of strings. This is also a prerequisite to fixing chipsalliance/fpga-interchange-schema#46, hitherto this has been worked around in the schema by using Text instead of StringIdx where the patching tool needs to be used.

@issuelabeler issuelabeler bot added the invalid This doesn't seem right label May 10, 2021
@gatecat gatecat added enhancement New feature or request and removed invalid This doesn't seem right labels May 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant