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

Allow Delegate parameter to change source and support a None source #2005

Merged

Conversation

jenshnielsen
Copy link
Collaborator

There are a few open questions. Especially around how we handle traits such as gettable/settable/snapshot_get being inherited from the source parameter or alternatively set specifically on the Delegated parameter

@codecov
Copy link

codecov bot commented May 15, 2020

Codecov Report

Merging #2005 into master will increase coverage by 0.04%.
The diff coverage is 84.61%.

@@            Coverage Diff             @@
##           master    #2005      +/-   ##
==========================================
+ Coverage   71.17%   71.21%   +0.04%     
==========================================
  Files         149      149              
  Lines       19541    19607      +66     
==========================================
+ Hits        13909    13964      +55     
- Misses       5632     5643      +11     

@jenshnielsen jenshnielsen force-pushed the delegate_parameter_change_source branch 4 times, most recently from 4bb6311 to 473dc85 Compare May 29, 2020 07:28
@jenshnielsen jenshnielsen force-pushed the delegate_parameter_change_source branch from 8eefca2 to 2893bda Compare May 29, 2020 13:56
@jenshnielsen jenshnielsen marked this pull request as ready for review June 2, 2020 14:31
@jenshnielsen jenshnielsen force-pushed the delegate_parameter_change_source branch from ce592c8 to 88e3f37 Compare June 4, 2020 07:43
if self._parameter.source is None:
raise TypeError("Cannot set the cache of a DelegateParameter "
"that delegates to None")
self._parameter.validate(value)
Copy link
Contributor

Choose a reason for hiding this comment

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

as per my memory, _set_from_raw_value was made with an assumtion that it will be used in a "get" context (as opposed to "set"). this is why in _BaseParameter, _set_from_raw_value
validates the value only if _validate_on_get is True. I don't think that this assumtion is a good one. So either the _validate_on_get condition needs to be gone but then we need to be careful about validation values in group parameter case, or add the _validate_on_get condition below for consistency just "for now":

if self._parameter._validate_on_get:
    self._parameter.validate(value)

what do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually this never matters. It calls set on the base parameter which will always do a validate. In anycase it should validate against the value and not the raw_value. So lets perhaps just remove this validator

@jenshnielsen jenshnielsen merged commit e9066e8 into microsoft:master Jun 4, 2020
@jenshnielsen jenshnielsen deleted the delegate_parameter_change_source branch June 4, 2020 10:52
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.

2 participants