phetsims / natural-selection

"Natural Selection" is an educational simulation in HTML5, by PhET Interactive Simulations
GNU General Public License v3.0
3 stars 7 forks source link

Migration rules for 1.5 release #324

Closed pixelzoom closed 1 year ago

pixelzoom commented 1 year ago

319 (add support for dynamic locale) is requiring a large number of API changes. According to the PhET-iO spreadsheet, this sim needs to provide migration support from 1.4 to 1.5. So migration rules will be needed.

pixelzoom commented 1 year ago

We need to discuss when this happens, who is doing the work, etc. Should it be before/done after PhET-iO design review, or iteratively? Am I doing this with support from the PhET-iO team, or is the PhET-iO team writing migration rules?

pixelzoom commented 1 year ago

319 (add support for dynamic locale) is completed. Design review #323 has not been done yet.

Ready to discuss with @samreid and @zepumph.

zepumph commented 1 year ago

@samreid and I ran out of time for this today, but will look into it soon. We will likely need to add a couple more migration rules due to recent changes (removing the options dialog, etc).

pixelzoom commented 1 year ago

At 9/1/2022 design meeting, @kathy-phet said:

samreid commented 1 year ago

I tried this with a copy/paste of the Gravity and Orbits rules but was blocked by a "schema expected something that it didn't receive".

samreid commented 1 year ago

I added a rough draft of rules in the commit. I attempted to factor out the shared rules between it and gravity and orbits, but ran into 2 problems:

Until we resolve these considerations, each sim can just have a copy-paste list of the common rules.

Next I'll try to relax some of the deletes.

samreid commented 1 year ago

I wrote up notes on the rules that are deleted. It's at a good point to discuss with @zepumph, possibly on Tuesday.

kathy-phet commented 1 year ago

I don't think its a bad idea to get a handle on what is involved here, but as Chris mentioned, please do not put too much effort into Natural Selection specific rules until after the design review is complete. @arouinfar and I need to take a good look at the changes that happened since the last published version and where the simulation is now. We may decide its worth uninstrumenting some things, despite the cost of that.

zepumph commented 1 year ago

Discussed with @samreid. On hold until we complete the natural selection design overhaul in https://github.com/phetsims/natural-selection/issues/323.

zepumph commented 1 year ago

Unassigning until we work on this sim

pixelzoom commented 1 year ago

Migration rules for Molecule Polarity https://github.com/phetsims/molecule-polarity/issues/141 was quite the project. @samreid suggested that, while it's still fresh in my mind, I should do this sim. @kathy-phet approved. So I'll proceed.

pixelzoom commented 1 year ago

Before starting this work, I tested in master with the Migration wrapper with URL: http://localhost:8080/phet-io-wrappers/version-migration/?sim=natural-selection&locales=*&keyboardLocaleSwitcher&phetioDebug=true&phetioWrapperDebug=true&oldVersion=1.4

There is 1 error reported in the console:

Model strings are not stateful, instead use ConvertToStringsStateForLocale: naturalSelection.general.model.strings.naturalSelection.naturalSelection.titleStringProperty

I also published a baseline version:

pixelzoom commented 1 year ago

In the above commits, I added all rules needed to stop the Migration wrapper from complaining to the console.

Now I'm getting this console output after pressing the "Migrate Now" button:

Building a MigrationEngine with 126 rules.
Assertion failed:  stateObject is not valid for range
PhetioStateEngine.ts:342 Uncaught Error: Assertion failed: stateObject is not valid for range
    at window.assertions.assertFunction (assert.js:28:13)
    at StateSchema.ts:147:35
    at Array.forEach (<anonymous>)
    at StateSchema.checkStateObjectValid (StateSchema.ts:140:29)
    at IOType.isStateObjectValid (IOType.ts:403:43)
    at IOType.validateStateObject (IOType.ts:436:10)
    at IOType.applyState (IOType.ts:298:41)
    at PhetioStateEngine.setStateForPhetioObject (PhetioStateEngine.ts:424:10)
    at PhetioStateEngine.ts:327:14
    at Array.forEach (<anonymous>)

I'm running the Migration wrapper from phetmarks with oldVersion=1.4, and this is the URL:

http://localhost:8080/phet-io-wrappers/version-migration/?sim=natural-selection&locales=*&keyboardLocaleSwitcher&phetioDebug=true&phetioWrapperDebug=true&oldVersion=1.4

@zepumph @samreid any idea what's going on here, and how to fix it?

pixelzoom commented 1 year ago

The above commit fixes the 'stateObject is not valid for range', which was related to NumberProperty's rangeProperty. It also fixes the problem that NumberProperty step no longer exists.

Now that we've cleared those hurdles, here's the next problem:

Assertion failed: _restTime in state schema but not in the state object

This is due to a change in how "private" fields (hidden from Studio) are now implemented in an IOType's state schema. In this case, the IOType is BunnyIO. WolfIO will also have this problem. @samreid said that we'll need to implement migration rule to "rewrite" the schema. Before doing that, we might want to address #327 and #330. Or we might want to write these rules now, to discover whether there are other problems that haven't been reported yet.

samreid commented 1 year ago

@samreid said that we'll need to implement migration rule to "rewrite" the schema.

Another way to phrase it would be: a migration rule to promote values that match the old schema to values that match the new schema.

pixelzoom commented 1 year ago

Completion is also blocked by:

zepumph commented 1 year ago

https://github.com/phetsims/phet-io-wrappers/issues/514 is no longer blocking this issue.

zepumph commented 1 year ago

Completion is also blocked by:

Further work on this issue is no longer blocked by https://github.com/phetsims/phet-io-wrappers/issues/513, but that issue is still out for review.

Here you can still continue review and testing. Likely you will need the same AboutDialog rules from MoleculePolarity.

pixelzoom commented 1 year ago

In the above commit, I added rules related to aboutDialog, copied from molecule-polarity-migration-rules.ts.

pixelzoom commented 1 year ago

The next steps for this will be to address IOType issues (#327 and #330), then revise migration rules.

Unassigning until this sim is added to the worklist.

pixelzoom commented 1 year ago

For https://github.com/phetsims/qa/issues/967 please test with the Migration wrapper. Then assign back to me.

The previous version is https://phet-io.colorado.edu/sims/natural-selection/1.4/

Nancy-Salpepi commented 1 year ago

The Migration wrapper was tested on multiple platforms in https://github.com/phetsims/qa/issues/967. Back to you.

pixelzoom commented 1 year ago

For https://github.com/phetsims/qa/issues/968, please test with the Migration wrapper. Then assign back to me.

KatieWoe commented 1 year ago

Things look ok in rc.1

pixelzoom commented 1 year ago

For https://github.com/phetsims/qa/issues/971, please test with the Migration wrapper. Then assign back to me.

KatieWoe commented 1 year ago

Migration wrapper looked ok in rc.2

pixelzoom commented 1 year ago

We're ready for production deploy of 1.5.0, so it's now safe to close this issue.