entangled / entangled.py

Python port of Entangled
Apache License 2.0
33 stars 7 forks source link

entangled watch gives KeyError on an old or damaged filedb #42

Closed HannoSpreeuw closed 2 months ago

HannoSpreeuw commented 5 months ago

This is Entangled 2.0.2. Running entangled watch from a conda py311 env in a Julia repo. This gives

ERROR    'src/model.jl'
           ERROR    This error is due to an internal bug in Entangled. Please file an issue including the above stack
                    trace and example content to reproduce the exception at https://github.com/entangled/entangled.py/.
Traceback (most recent call last):
  File "/.../.../anaconda3/envs/py311/lib/python3.11/site-packages/entangled/main.py", line 33, in cli
    argh.dispatch(parser)
  File "/.../.../anaconda3/envs/py311/lib/python3.11/site-packages/argh/dispatching.py", line 179, in dispatch
    return run_endpoint_function(
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/.../.../anaconda3/envs/py311/lib/python3.11/site-packages/argh/dispatching.py", line 237, in run_endpoint_function
    return _process_command_output(lines, output_file, raw_output)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../.../anaconda3/envs/py311/lib/python3.11/site-packages/argh/dispatching.py", line 254, in _process_command_output
    for line in lines:
  File "/.../.../anaconda3/envs/py311/lib/python3.11/site-packages/argh/dispatching.py", line 362, in _execute_command
    for line in result:
  File "/.../.../anaconda3/envs/py311/lib/python3.11/site-packages/argh/dispatching.py", line 342, in _call
    result = function(*positional, **keywords)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../.../anaconda3/envs/py311/lib/python3.11/site-packages/entangled/commands/watch.py", line 64, in watch
    _watch()
  File "/.../.../anaconda3/envs/py311/lib/python3.11/site-packages/entangled/commands/watch.py", line 43, in _watch
    sync()
  File "/.../.../anaconda3/envs/py311/lib/python3.11/site-packages/entangled/commands/sync.py", line 56, in sync
    action()
  File "/.../.../anaconda3/envs/py311/lib/python3.11/site-packages/entangled/commands/tangle.py", line 66, in tangle
    result, deps = tangle_ref(refs, tgt, annotation_method)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../.../anaconda3/envs/py311/lib/python3.11/site-packages/entangled/tangle.py", line 123, in tangle_ref
    raise KeyError(ref_name)
KeyError: 'src/model.jl'
Traceback (most recent call last):
  File "/.../.../anaconda3/envs/py311/bin/entangled", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/.../.../anaconda3/envs/py311/lib/python3.11/site-packages/entangled/main.py", line 48, in cli
    raise e
  File "/.../.../anaconda3/envs/py311/lib/python3.11/site-packages/entangled/main.py", line 33, in cli
    argh.dispatch(parser)
  File "/.../.../anaconda3/envs/py311/lib/python3.11/site-packages/argh/dispatching.py", line 179, in dispatch
    return run_endpoint_function(
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/.../.../anaconda3/envs/py311/lib/python3.11/site-packages/argh/dispatching.py", line 237, in run_endpoint_function
    return _process_command_output(lines, output_file, raw_output)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../.../anaconda3/envs/py311/lib/python3.11/site-packages/argh/dispatching.py", line 254, in _process_command_output
    for line in lines:
  File "/.../.../anaconda3/envs/py311/lib/python3.11/site-packages/argh/dispatching.py", line 362, in _execute_command
    for line in result:
  File "/.../.../anaconda3/envs/py311/lib/python3.11/site-packages/argh/dispatching.py", line 342, in _call
    result = function(*positional, **keywords)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../.../anaconda3/envs/py311/lib/python3.11/site-packages/entangled/commands/watch.py", line 64, in watch
    _watch()
  File "/.../.../anaconda3/envs/py311/lib/python3.11/site-packages/entangled/commands/watch.py", line 43, in _watch
    sync()
  File "/.../.../anaconda3/envs/py311/lib/python3.11/site-packages/entangled/commands/sync.py", line 56, in sync
    action()
  File "/.../.../anaconda3/envs/py311/lib/python3.11/site-packages/entangled/commands/tangle.py", line 66, in tangle
    result, deps = tangle_ref(refs, tgt, annotation_method)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../.../anaconda3/envs/py311/lib/python3.11/site-packages/entangled/tangle.py", line 123, in tangle_ref
    raise KeyError(ref_name)
KeyError: 'src/model.jl'
RaFortunat commented 2 months ago

I have the same issue, running Entangled 2.0.3. The error only occurs on code blocks with a block identifier. However there is no problem when the filename is already used in another block without blockid.

This causes an error

``` {.rust #blockid file=world.rust}
...

but this works
...

and this also works
...

some text

...
jhidding commented 2 months ago

These are two unrelated issues. @HannoSpreeuw: this happens when you're running entangled when there is a filedb from an older version. This is still an issue, but not a very pressing one.

Make sure that there are no dangling changes in the tangled source files before running:

rm .entangled/filedb.json
entangled tangle --force

Still, entangled shouldn't crash this ugly when the filedb is damaged.

@RaFortunat Thanks. I created a new issue for this.

jhidding commented 2 months ago

I'm completely mistaken: this is the same issue. But it is fixed now. Closing