Open pixelzoom opened 2 years ago
Note that the "Before touching any code" section says:
Design review: PhET-iO instrumentation provides an opportunity to review the condition of the sim, and make improvements to both the UX and code base. With a designer: ...
I'm skipping that for this sim, because I've been asked to proceed, and there are no outstanding GitHub issues that I think are relevant here. @amanda-phet if you feel otherwise, please let me know asap.
Good progress on "initial instrumentation" today in the above commits. I'll resume working on this the week of 10/17/2022.
Dynamic elements have been identified in https://github.com/phetsims/equality-explorer/issues/200. There are no plans to work on that until the initial instrumentation has been reviewed.
I've completed initial instrumentation.
Baseline versions:
Nexts steps are for designers @amanda-phet @catherinecarter - see https://github.com/phetsims/equality-explorer/issues/191#issuecomment-1306323892.
PhET-iO Instrumentation Process Checklist
Initial Steps
Gathering requirements
Before touching any code
Baseline versions:
https://phet-dev.colorado.edu/html/equality-explorer/1.2.0-dev.5/phet/equality-explorer_en_phet.html
https://phet-dev.colorado.edu/html/equality-explorer-basics/1.1.0-dev.2/phet/equality-explorer-basics_en_phet.html
https://phet-dev.colorado.edu/html/equality-explorer-two-variables/1.1.0-dev.2/phet/equality-explorer-two-variables_en_phet.html
[x] Developer to gather knowledge about the instrumentation process. These topics are crucial to understanding before attempting to outfit a simulation with PhET-iO:
[x] Design review: PhET-iO instrumentation provides an opportunity to review the condition of the sim, and make improvements to both the UX and code base. With a designer:
Initial meeting
Prior to initial meeting:
Tandem.REQUIRED
elements. See section below on development and instrumentation, but note that not all steps should be accomplished at this stage.Brief initial meeting (developer and designer):
For example, see how-to-design-phet-io-features-for-a-simulation.md. Think about how a researcher or 3rd party may wish to configure the simulation or collect data from it, and make sure that is supported by the instrumentation. For example, some simulations will need custom higher-level events (such as whether the user created a parallel circuit), for events that are useful, easy to compute in simulation code and difficult to compute in wrapper code. Or a simulation may need to be configurable in a way that is not already supported by the instrumentation you have already completed. These features should be determined in the PhET-iO design meeting. Sometimes it is preferred to have a skeleton, or developer's "best guess" before this meeting so that there is more to play with in Studio. Use your judgement!
Development
If a retrofit
Initial development
New Sim -- build out according to initial requirements.Getting started
supportedBrands
field in the sim'spackage.json
. Then run~/github/perennial$ grunt generate-data
to add the simulation to the list of PhET-iO simulations. This will make it possible to use phetmarks to launch wrappers for testing. This also will add it to continuous fuzz testing. More documentation is available inPERENNIAL/generateData.js
grunt update
in the sim repo. This will update the local files needed to run in phet-io brand.Tandem
tomain.js
, seefaradays-law-main.js
for an example. (If the sim was created using a recent version of simula-rasa, this was handled for you.)tandem
instances to each screen usingtandem.createTandem(...)
. (If the sim was created using a recent version of simula-rasa, this was handled for you.)?phetioValidation=false
query parameter or specify the package.json flagphet.phet-io.validation: false
to opt out of errors during initial instrumentation. Once the simulation has attained a basic level of instrumentation, validation can be turned on to discover remaining issues. Remember to rungrunt update
after changing package.json.perennial/data/phet-io-state-unsupported
.Instrumenting Objects by passing them Tandems
This step will take you through all objects in the simulation that should be instrumented, as well as some tips and tricks for finding them and testing as you go.
Consult the PhET-iO design issue to see what features the sim should support. See PhetioObject.js for the supported
PhetioObject
options. Not everyTandem
created needs to be passed to aPhetioObject
; sometimesTandem
s can be created to support organization. For example, in some sims, a collection of Properties associated with the visibility of Nodes in the view may all be instrumented under a phetioID like{{sim}}.{{screen}}.view.viewProperties
. This would be preferable than having all of these Properties (which have similar functionality) directly on theview
phetioID. HereviewProperties
is not a PhET-iO element, but is a phetioID that nests PhET-iO elements under it.Tandem
s and otherPhetioObject
options into objects that should be instrumented. Do not instrument objects that are "implementation details" and do not over-instrument. The goal is to design an API that balances the power of a broad feature set while still being maintainable.phetioFeatured
metadata. It will typically be specified by designers using Studio. See Customizing the API in Studio.AXON/Property
that are critical to the save state or operation of the sim. This does not necessarily include "implementation details" that should be hidden from the public API; again, a design meeting may be needed here. Note that some Property subclasses have options that are specific to PhET-iO (for exampleunits
inNumberProperty
) and should be added where appropriate.PhetioObject
when you need to add features not already covered by existing types. Be careful not to shadow pre-existing attributes inPhetioObject
such astandem
,isDisposed
, andlinkedElements
.phetioPrintMissingTandems
flag if you want to collect a list of all required, optional, and uninstrumented common-code classes instead of erroring out on the first missing tandem. Each occurrence is numbered to give a better idea of how many the sim has remaining."validation": true
so it will be tested with validation on your working copy and on CT (or omit, as this is the default).Feature Support
An instrumented object is not just a
Tandem
passed to aPhetioObject
. There is other structure that needs to be added for full PhET-iO support.PhetioObject
should be provided an IO Type with thephetioType
option. The IO Types Section can serve as a guide.phetioDocumentation
adheres to the the conventions.Property
instances to make it possible to get/set a value, so value changes will appear on the data stream and so the item can be stored and restored in save/load. This is preferred to creating a new IO Type and implementing get/set within that IO Type.IOType
has avalidator
static attribute that can be used to validate the type. When instrumenting aProperty
,Emitter
, or other type that validates parameters in which that instance providedvalueType
for validation, in most cases the IO Type'svalidator
will be redundant to thevalueType
field. If this is the case, thevalueType
can and should be removed to keep the code simpler and more maintainable.Property
.Property
viaPhetioObject.addLinkedElement
.Iteration during development
Post Instrumentation Review and Checks
onSimInitialized
callback, that the sim has actually been initialized. If there's any animation on startup which causes changed state, that is expected and okay. See https://github.com/phetsims/phet-io/issues/1555 for more discussion.http://localhost/phet-io-wrappers/index/?sim={{simulation-name}}
and test all the links. To further understand what each wrapper exemplifies, read the description for it in the Wrapper Index, and launch that wrapper with a sim already completely PhET-iO instrumented like Faraday's Law.grunt --brands=phet-io
and test the built version by launching the compiled Wrapper Index atbuild/phet-io/
, and testing all the links.brand=phet-io
instantiates different objects and wires up listeners that are not present in thebrand=phet
runtime. It needs to be tested separately for memory leaks. Use?ea&brand=phet-io&phetioStandalone&fuzz
to run with assertions, PhET-iO brand, and fuzzing.?phetioValidation=false
or specify the package.json flagphet.phet-io.validation: false
, time to turn validation back on (by removing the query parameter or package.json entry) and address any issues discovered.phetioFeatured
metadata should be in overrides file, and not in sim-specific code.phetioFeatured
can be declared in common code to factor out duplication. See overrides convention decision in https://github.com/phetsims/states-of-matter/issues/303#issuecomment-653139520phetioDesigned: true
to ensure that any changes to the API don't sneak in.Publication
Managing QA Bugs with PhET-iO publication
PhET-iO bugs that come from QA testing can effect multiple sims, especially if multiple phet-io sims are currently going through the QA pipeline. Below is a process to follow to make sure that bugs can be fixed and propagated to all effected sims.