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

Bug: snapshot fails when instantiating InstrumentBase #1209

Merged

Conversation

astafan8
Copy link
Contributor

@astafan8 astafan8 commented Jul 26, 2018

The problem occurs when one wants to subclass from InstrumentBase (or instantiate it). The reason to do so is to create a "virtual" instrument, and to avoid the overhead of Instrument class related to the register of instances.

The problem is that the snapshot functionality of InstrumentBase raises an exception saying "the object does not have attribute _meta_attrs". This is because snapshot_base uses it, but for some reason _meta_attrs is only defined in the Instrument class. This is not correct, hence this PR.

Changes:

  • declare _meta_attrs in InstrumentBase instead of Instrument
  • add tests for snapshotting InstrumentBase
  • modify Instrument test to ensure snapshotting still works for it

@codecov
Copy link

codecov bot commented Jul 26, 2018

Codecov Report

Merging #1209 into master will decrease coverage by <.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #1209      +/-   ##
==========================================
- Coverage   80.16%   80.16%   -0.01%     
==========================================
  Files          49       49              
  Lines        6762     6761       -1     
==========================================
- Hits         5421     5420       -1     
  Misses       1341     1341

@WilliamHPNielsen
Copy link
Contributor

It's not so clear to me what is gained by instantiating InstrumentBase directly, but irrespective of that, this refactor seems sensible to me.

Copy link
Contributor

@WilliamHPNielsen WilliamHPNielsen left a comment

Choose a reason for hiding this comment

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

A-OK from me.

@astafan8
Copy link
Contributor Author

yeah, it is more for subclassing InstrumentBase.

@astafan8 astafan8 merged commit c0c4c82 into microsoft:master Jul 30, 2018
@astafan8 astafan8 deleted the bugfix/meta-attr-name-instrument-base branch July 30, 2018 16:46
giulioungaretti pushed a commit that referenced this pull request Jul 30, 2018
Merge: 897ffbc 5ea8e0d
Author: Mikhail Astafev <astafan8@gmail.com>

    Merge pull request #1209 from astafan8/bugfix/meta-attr-name-instrument-base
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

2 participants