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

Address error when no gating veto argument was given #3513

Merged
merged 4 commits into from
Oct 22, 2020
Merged

Conversation

veronica-villa
Copy link
Contributor

When no --gating-veto-windows argument was given the following error arised:

Traceback (most recent call last): File "/cvmfs/oasis.opensciencegrid.org/ligo/sw/pycbc/x86_64_rhel_7/virtualenv/pycbc-v1.16.11/bin/pycbc_multiifo_coinc_findtrigs", line 113, in <module> args.gating_veto_windows) File "/cvmfs/oasis.opensciencegrid.org/ligo/sw/pycbc/x86_64_rhel_7/virtualenv/pycbc-v1.16.11/lib/python2.7/site-packages/pycbc/io/hdf.py", line 1012, in __init__ gating_veto = gating_veto_windows[self.ifo].split(',') AttributeError: 'NoneType' object has no attribute 'split'

This change should address the error

@tdent
Copy link
Contributor

tdent commented Oct 22, 2020

I am not sure if this is the correct fix, was this an error in the coinc findtrigs code if the option is not given?

If so what value is passed to the ReadByTemplate class? Can this not be fixed to be None?

@veronica-villa
Copy link
Contributor Author

No, this was an error in the hdf code because when the argument is not given the MultiDetOptionAction class returns a default value of {} (which is passed to the ReadByTemplate class) so the argument itself is never None

@tdent
Copy link
Contributor

tdent commented Oct 22, 2020

I.e. it would be good to 1) determine what exactly is currently passed from MultiDetOptionAction if there is no value set on the command line, and 2) determine if the option can be fixed to return None if nothing is given on command line.

@tdent
Copy link
Contributor

tdent commented Oct 22, 2020

OK, so the default is empty dict which is taken to be False (ie if {} returns False). But this is IMO somewhat sloppy since it is not clear from looking at the code that this is what is returned by the option.

@tdent
Copy link
Contributor

tdent commented Oct 22, 2020

Or we have the default initialization of gating_veto_windows in the class to be {} (empty dictionary) and then do a switch like if ifo in gating_veto_windows: (see eg https://stackoverflow.com/questions/1323410/should-i-use-has-key-or-in-on-python-dicts )

@veronica-villa
Copy link
Contributor Author

Would it be clearer adding

if not args.gating_veto_windows:
    args.gating_veto_windows = None

to the coinc findtrigs code?

@tdent
Copy link
Contributor

tdent commented Oct 22, 2020

OK, I changed my mind since it seems easier to consider gating_veto_windows as a dictionary since that is what is most directly returned by the option parsing.

Copy link
Contributor

@koustavchandra koustavchandra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @veronica-villa for addressing it in such a short time.

Copy link
Contributor

@tdent tdent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

recommendation : change the default __init__ method to set the variable to {} (empty dictionary) and change the switch to if self.ifo in gating_veto_windows.

@tdent
Copy link
Contributor

tdent commented Oct 22, 2020

hmm, I'm not sure if we should do anything about the codeclimate warning. Probably not since we are initializing exactly once and we don't use the gating_veto_windows kwarg value for anything else in the rest of the class.

tdent added 2 commits October 22, 2020 21:16

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@tdent tdent merged commit b270e6a into master Oct 22, 2020
@spxiwh spxiwh deleted the fixing_gating_veto branch October 26, 2020 11:10
ArthurTolley pushed a commit to ArthurTolley/pycbc that referenced this pull request Nov 14, 2022
* Address error when no gating veto argument was given

* Fix error when no gating veto argument is given

* add comment on default empty dict assignment

* shorten too long line

Co-authored-by: Thomas Dent <thomas.dent@usc.es>
OliverEdy pushed a commit to OliverEdy/pycbc that referenced this pull request Apr 3, 2023
* Address error when no gating veto argument was given

* Fix error when no gating veto argument is given

* add comment on default empty dict assignment

* shorten too long line

Co-authored-by: Thomas Dent <thomas.dent@usc.es>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants