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

Node does not exist for SceneGroupItemBlock: None #16

Closed
Azeirah opened this issue Aug 6, 2023 · 2 comments · Fixed by #37
Closed

Node does not exist for SceneGroupItemBlock: None #16

Azeirah opened this issue Aug 6, 2023 · 2 comments · Fixed by #37

Comments

@Azeirah
Copy link
Contributor

Azeirah commented Aug 6, 2023

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/app/remarks/__main__.py", line 151, in <module>
    main()
  File "/app/remarks/__main__.py", line 147, in main
    run_remarks(input_dir, output_dir, **args_dict)
  File "/app/remarks/remarks.py", line 96, in run_remarks
    process_document(metadata_path, out_path, doc_type, **kwargs)
  File "/app/remarks/remarks.py", line 271, in process_document
    (ann_data, has_ann_hl), version = parse_rm_file(ann_rm_file)
  File "/app/remarks/conversion/parsing.py", line 259, in parse_rm_file
    return parse_v6(file_path), "V6"
  File "/app/remarks/conversion/parsing.py", line 128, in parse_v6
    dims = determine_document_dimensions(file_path)
  File "/app/remarks/conversion/parsing.py", line 183, in determine_document_dimensions
    build_tree(tree, blocks)
  File "/app/.venv/lib/python3.10/site-packages/rmscene/scene_stream.py", line 773, in build_tree
    raise ValueError(
    ValueError: Node does not exist for SceneGroupItemBlock: None`
def build_tree(tree: SceneTree, blocks: Iterable[Block]):
    for b in block:
        if ...:
            ...
        elif isinstance(b, SceneGroupItemBlock):
            # Add this entry to children of parent_id
            node_id = b.item.value
            # if node_id == None:
                # continue
            if node_id not in tree:
                raise ValueError(
                    "Node does not exist for SceneGroupItemBlock: %s" % node_id
                )
            item = replace(b.item, value=tree[node_id])
            tree.add_item(item, b.parent_id)

Given that the value in the SceneGroupItemBlock is a tp.Optional[CrdtId] it's defined that it's ok to be None?

I added the commented continue if None code and there are no further errors in the document.

Am I correct in assuming it's ok to just skip it if it's None given that the value is optionally typed?

@Azeirah
Copy link
Contributor Author

Azeirah commented Aug 6, 2023

@ricklupton I'm learning 😄

@ricklupton
Copy link
Owner

I'd expect in this case that the b.item.deleted_length was nonzero, and this was a deleted group that is no longer part of the drawing? If so it makes sense that node_id could be None and your fix would be good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants