-
Notifications
You must be signed in to change notification settings - Fork 5
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
Tandem.REQUIRED is no longer checked #192
Comments
Is this a problem in the ph-scale 1.4 release branch? If so, is it something that should be patched, so that we don't make PhET-iO mistakes in 1.4 maintenance releases? |
Yes I think that this has been a bug since a commit on June 5th where this was added: // The presence of `tandem` indicates if this PhetioObject can be intiialized. If not yet initialized, perhaps
// it will be initialized later on, as in Node.mutate().
if ( !( config.tandem && config.tandem.supplied ) ) {
assert && !config.tandem && assert( !specifiesNonTandemPhetioObjectKey( config ), 'only specify metadata when providing a Tandem' );
if ( config.tandem ) {
this.tandem = config.tandem;
}
return;
} In this commit: 85f4515 This performance improvement exits early if the tandem is not supplied. We could change this to be only for unrequired Tandems. Another option would be to move up some validation about Tandem.REQUIRED/OPTIONAL to this block. There is a balance to maintain. The most performant thing to do would be to detect and exit as early as possible, which is where this block is now at the top of Probably the way to go would be to move these assertions up, and continue to opt out of as much logic as possible for types that don't need to use it. @samreid, please review and discuss.
I understand the potential desire to add this into the branch for completeness and maintainability. That said, ph-scale was instrumented before that was broken, and so most likely this isn't effecting that sim. I recommend to fix this on master, see if there are any issues with ph-scale, and then likely decide from there. It could be an easy patch, with just an addition of a single assertion to support erroring for |
The concern is with ongoing maintenance of the 1.4 branch. There's no telling how long that branch will be the production branch for ph-scale. And if that branch doesn't correctly detect Tandem.REQUIRED, then it would be possible to accidentally remove a required tandem in a maintenance release. So once the fix is identified, please investigate patching the ph-scale 1.4 branch. |
@zepumph are you recommending a check like this? It appears to test OK. If we do this, what should we do with the code in Tandem.js that used to do this part? Index: js/PhetioObject.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- js/PhetioObject.js (revision 6fddb61195a44ba31c825191f0fb2addd768d6df)
+++ js/PhetioObject.js (date 1595258592175)
@@ -232,6 +232,10 @@
initializePhetioObject: function( baseOptions, config ) {
assert && assert( config, 'initializePhetioObject must be called with config' );
+ if ( config.tandem && config.tandem.required ) {
+ assert && assert( config.tandem.supplied, 'required tandems must be supplied' );
+ }
+
// The presence of `tandem` indicates if this PhetioObject can be intiialized. If not yet initialized, perhaps
// it will be initialized later on, as in Node.mutate().
if ( !( config.tandem && config.tandem.supplied ) ) { |
@samreid, could we please pair on this on Friday. I think that would be the "work-around" sort of solution—quick-and-dirty. I think the best way to proceed is to look at how and why initializePhetioObject is being called. Note that quite a bit of logic is being called even when |
Adding blocking publication since it is holding up ph-scale |
Let me know when this is fixed, so that I can cherry-pick for phetsims/ph-scale#183. |
I implemented the above workaround. This is now ready for cherry-picking into RC branches. @samreid I still don't know how to remedy this with the validation that is currently in |
fba18d1 has been cherry-picked to ph-scale and ph-scale-basics 1.4 branches for phetsims/ph-scale#183. |
I marked this for collaboration to discuss Tandem assertions that don't run often now because of the PhetioObject early exit. |
@samreid and I think that having the Tandem.REQUIRED check in Tandem.addPhetioObject and at the beginning of PhetioObject.initializePhetiObject is OK. That is really the only assertion in Tandem.addPhetioObject, so there isn't much duplication. Closing |
Discovered in #191
The text was updated successfully, but these errors were encountered: