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

Add better error message when someone makes a collection call that makes no sense #179

Open
gordonwatts opened this issue Sep 14, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@gordonwatts
Copy link
Member

Currently we end up with this:

/tests/cms/aod/test_aod_executor.py::test_metadata_collection Failed: [undefined]RuntimeError: Internal Error: Variable bogus-do-not-use does not have an assigned type, but needs one.
def test_metadata_collection():
        'This is integration testing - making sure the dict to root conversion works'
>       r = (cms_aod_dataset()
             .MetaData({
                'metadata_type': 'add_cms_event_collection_info',
                'name': 'Vertex',
                'include_files': ['DataFormats/VertexReco/interface/Vertex.h'],
                'container_type': 'reco::VertexCollection',
                'contains_collection': True,
                'element_type': 'reco::Vertex',
                'element_pointer': False,
             })
             .Select(lambda e: e.ForkInfo("EventInfo").runNumber())
             .Select(lambda e: {'run_number': e})
             .value())

tests\cms\aod\test_aod_executor.py:76: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.venv\lib\site-packages\make_it_sync\func_wrapper.py:63: in wrapped_call
    return _sync_version_of_function(fn, *args, **kwargs)
.venv\lib\site-packages\make_it_sync\func_wrapper.py:14: in _sync_version_of_function
    return loop.run_until_complete(r)
..\..\..\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py:642: in run_until_complete
    return future.result()
.venv\lib\site-packages\func_adl\object_stream.py:263: in value_async
    return await exe(self._q_ast, title)
tests\utils\base.py:193: in execute_result_async
    exe.evaluate(a)
tests\utils\base.py:152: in evaluate
    self.QueryVisitor.get_as_ROOT(a_transformed)
func_adl_xAOD\common\ast_to_cpp_translator.py:226: in get_as_ROOT
    r = self.get_rep(node)
func_adl_xAOD\common\ast_to_cpp_translator.py:184: in get_rep
    self.visit(node)
func_adl_xAOD\common\ast_to_cpp_translator.py:170: in visit
    FuncADLNodeVisitor.visit(self, node)
..\..\..\AppData\Local\Programs\Python\Python39\lib\ast.py:407: in visit
    return visitor(node)
func_adl_xAOD\common\ast_to_cpp_translator.py:611: in visit_Call
    r = FuncADLNodeVisitor.visit_Call(self, call_node)
.venv\lib\site-packages\func_adl\ast\func_adl_ast_utils.py:78: in visit_Call
    return visitor(node, args)
func_adl_xAOD\common\ast_to_cpp_translator.py:975: in call_Select
    new_sequence_value = cast(crep.cpp_value, self.get_rep(c))
func_adl_xAOD\common\ast_to_cpp_translator.py:184: in get_rep
    self.visit(node)
func_adl_xAOD\common\ast_to_cpp_translator.py:170: in visit
    FuncADLNodeVisitor.visit(self, node)
..\..\..\AppData\Local\Programs\Python\Python39\lib\ast.py:407: in visit
    return visitor(node)
func_adl_xAOD\common\ast_to_cpp_translator.py:602: in visit_Call
    self.visit_Call_Lambda(call_node)
func_adl_xAOD\common\ast_to_cpp_translator.py:349: in visit_Call_Lambda
    crep.set_rep(call_node, self.get_rep(call_node.func.body))
func_adl_xAOD\common\ast_to_cpp_translator.py:184: in get_rep
    self.visit(node)
func_adl_xAOD\common\ast_to_cpp_translator.py:170: in visit
    FuncADLNodeVisitor.visit(self, node)
..\..\..\AppData\Local\Programs\Python\Python39\lib\ast.py:407: in visit
    return visitor(node)
func_adl_xAOD\common\ast_to_cpp_translator.py:665: in visit_Dict
    values = {k: self.get_rep(v, retain_scope=True) for k, v in zip(node.keys, node.values)}
func_adl_xAOD\common\ast_to_cpp_translator.py:665: in <dictcomp>
    values = {k: self.get_rep(v, retain_scope=True) for k, v in zip(node.keys, node.values)}
func_adl_xAOD\common\ast_to_cpp_translator.py:184: in get_rep
    self.visit(node)
func_adl_xAOD\common\ast_to_cpp_translator.py:170: in visit
    FuncADLNodeVisitor.visit(self, node)
..\..\..\AppData\Local\Programs\Python\Python39\lib\ast.py:407: in visit
    return visitor(node)
func_adl_xAOD\common\ast_to_cpp_translator.py:604: in visit_Call
    self.visit_Call_Member(call_node)
func_adl_xAOD\common\ast_to_cpp_translator.py:562: in visit_Call_Member
    calling_against = self.get_rep(call_node.func.value)  # type: ignore
func_adl_xAOD\common\ast_to_cpp_translator.py:184: in get_rep
    self.visit(node)
func_adl_xAOD\common\ast_to_cpp_translator.py:170: in visit
    FuncADLNodeVisitor.visit(self, node)
..\..\..\AppData\Local\Programs\Python\Python39\lib\ast.py:407: in visit
    return visitor(node)
func_adl_xAOD\common\ast_to_cpp_translator.py:604: in visit_Call
    self.visit_Call_Member(call_node)
func_adl_xAOD\common\ast_to_cpp_translator.py:570: in visit_Call_Member
    c_stub = calling_against.as_cpp() + ("->" if calling_against.is_pointer() else ".")
func_adl_xAOD\common\cpp_representation.py:126: in is_pointer
    return self.cpp_type().is_pointer()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <func_adl_xAOD.common.cpp_representation.cpp_variable object at 0x00000246C8D662E0>

    def cpp_type(self) -> ctyp.terminal:
        if self._cpp_type is None:
>           raise RuntimeError(f'Internal Error: Variable {self._expression} does not have an assigned type, but needs one.')
E           RuntimeError: Internal Error: Variable bogus-do-not-use does not have an assigned type, but needs one.

func_adl_xAOD\common\cpp_representation.py:148: RuntimeError

This happened because of this query:

    r = (cms_aod_dataset()
         .MetaData({
            'metadata_type': 'add_cms_event_collection_info',
            'name': 'Vertex',
            'include_files': ['DataFormats/VertexReco/interface/Vertex.h'],
            'container_type': 'reco::VertexCollection',
            'contains_collection': True,
            'element_type': 'reco::Vertex',
            'element_pointer': False,
         })
         .Select(lambda e: e.ForkInfo("EventInfo").runNumber())
         .Select(lambda e: {'run_number': e})
         .value())

And you can see in there that ForkingInfo is not something that really exists!!

@gordonwatts gordonwatts added the bug Something isn't working label Sep 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant