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

Zip lookup for function types is causing a type tracing failure #148

Closed
gordonwatts opened this issue Sep 11, 2024 · 1 comment · Fixed by #149
Closed

Zip lookup for function types is causing a type tracing failure #148

gordonwatts opened this issue Sep 11, 2024 · 1 comment · Fixed by #149
Assignees
Labels
bug Something isn't working

Comments

@gordonwatts
Copy link
Member

This is from @ponyisi.

You get this error:

  File "/home/onyisi/servicex/analysis-grand-challenge/analyses/cms-open-data-ttbar/venv/lib64/python3.9/site-packages/func_adl/type_based_replacement.py", line 971, in visit_Attribute
    raise ValueError(f"Key {key} not found in dict expression!!")
ValueError: Key Zip not found in dict expression!!

When running this AGC code:

    cuts = source.Where(lambda e: {"pt": e.Electron_pt,
                               "eta": e.Electron_eta,
                               "cutBased": e.Electron_cutBased,
                               "sip3d": e.Electron_sip3d,}.Zip()\
                        .Where(lambda electron: (electron.pt > 30
                                                 and abs(electron.eta) < 2.1
                                                 and electron.cutBased == 4
                                                 and electron.sip3d < 4)).Count()
                        + {"pt": e.Muon_pt,
                           "eta": e.Muon_eta,
                           "tightId": e.Muon_tightId,
                           "sip3d": e.Muon_sip3d,
                           "pfRelIso04_all": e.Muon_pfRelIso04_all}.Zip()\
                        .Where(lambda muon: (muon.pt > 30
                                             and abs(muon.eta) < 2.1
                                             and muon.tightId
                                             and muon.pfRelIso04_all < 0.15)).Count()== 1)\
                        .Where(lambda f: {"pt": f.Jet_pt,
                                          "eta": f.Jet_eta,
                                          "jetId": f.Jet_jetId}.Zip()\
                               .Where(lambda jet: (jet.pt > 25
                                                   and abs(jet.eta) < 2.4
                                                   and jet.jetId == 6)).Count() >= 4)\
                        .Where(lambda g: {"pt": g.Jet_pt,
                                          "eta": g.Jet_eta,
                                          "btagCSVV2": g.Jet_btagCSVV2,
                                          "jetId": g.Jet_jetId}.Zip()\
                        .Where(lambda jet: (jet.btagCSVV2 > 0.5
                                            and jet.pt > 25
                                            and abs(jet.eta) < 2.4)
                                            and jet.jetId == 6).Count() >= 1)

Likely the problem is the function lookup should trigger an Any type return, not a total failure like this. And, further, it should work if the system has some type information (to catch mispellings).

@gordonwatts gordonwatts added the bug Something isn't working label Sep 11, 2024
@gordonwatts gordonwatts self-assigned this Sep 11, 2024
@gordonwatts
Copy link
Member Author

The error isn't what I thought it was. The problem is that <object>.name is a name lookup in <object>. So that is what is failing.

Here this is a function call. So we'll have to special case this, if Zip does not exist in a dictionary.

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

Successfully merging a pull request may close this issue.

1 participant