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

ENH: Include questionnaire objects in the user object #84

Merged
merged 3 commits into from
Mar 16, 2018

Conversation

ZLLentz
Copy link
Member

@ZLLentz ZLLentz commented Mar 15, 2018

Description

  • After loading User(), add the questionnaire objects to it
  • Load SimpleNamespace() as a fallback for a missing or malformed experiment file
  • alias x to user

Motivation and Context

This is a feature of the old python that is very helpful. The x or user object becomes the object that the users are allowed to call methods from during their experiment.

closes #82

How Has This Been Tested?

I added a check to make sure that the experiment object contained a reference to a questionnaire object.

Where Has This Been Documented?

I've added to the docs as appropriate on the startup routine page and on the experiments page. I have built the docs in my environment and they look as intended.

@ZLLentz ZLLentz requested a review from teddyrendahl March 15, 2018 22:07
@codecov-io
Copy link

codecov-io commented Mar 15, 2018

Codecov Report

Merging #84 into master will increase coverage by <.01%.
The diff coverage is 87.5%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #84      +/-   ##
==========================================
+ Coverage   98.72%   98.72%   +<.01%     
==========================================
  Files          14       14              
  Lines         548      551       +3     
==========================================
+ Hits          541      544       +3     
  Misses          7        7
Impacted Files Coverage Δ
hutch_python/load_conf.py 98.48% <100%> (+0.02%) ⬆️
hutch_python/exp_load.py 94.11% <75%> (+0.36%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3f927e5...3d59793. Read the comment docs.

cache(**exp_objs)
user = get_exp_objs(proposal, run)
for name, obj in qs_objs.items():
setattr(user, name, obj)
Copy link
Contributor

@teddyrendahl teddyrendahl Mar 15, 2018

Choose a reason for hiding this comment

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

Should we at all be concerned about us getting a User object we can't set attributes on? Or I'm just being paranoid?

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't consider this. How would this happen?

Copy link
Contributor

Choose a reason for hiding this comment

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

If someone made object inherit from some strange object. Probably not worth worrying about.

Copy link
Member Author

Choose a reason for hiding this comment

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

I suppose I can imagine something a little less malicious, like:

@property
def inj_x(self):
    return something

But I think for these instances we simply say... don't do that!

@ZLLentz ZLLentz merged commit b1ea286 into pcdshub:master Mar 16, 2018
@ZLLentz ZLLentz deleted the qs-exp-objs branch April 12, 2018 23:38
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 this pull request may close these issues.

Add Questionnaire Motors to Experiment Object
3 participants