-
Notifications
You must be signed in to change notification settings - Fork 1
Add presets #80
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
Add presets #80
Conversation
Refs #61
So it can be reused elsewhere. Also added method to find a preset in the presets resource
Do not use pruneDefaults as it is not preset aware
…nce a parameter that was untouched in the perm stays the same
|
|
Reduce types of config
TODO
|
|
Where to put the defaults in own file or in json schema?
|
TODO - ts errors - inline TODOs
For now store in JSON schema, but for form validation of permutation need defaults from reference, which is tricky. |
Modular forms does not like interface definitions generated by json-schema-to-typescript. So rewrite the interface definitions to type.
…onfig to module with same name
Peter9192
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR makes a lot of improvements to the overall code quality. It works well and can in principle be merged as is. There are some things that we could extend upon going forward:
- Make it possible to change the preset of an existing experiment
- Start from scratch is now the same as start from preset with default preset --> improve user journey (also as part of layout upgrade).
I'm not sure what we finally decided on whether the default config should be in a separate json file or not. I think that might be nice.
packages/class/README.md
Outdated
| # Generate default config file | ||
| pnpx @classmodel/class generate --output config.json | ||
| # Fetch default config file | ||
| curl https://classmodel.github.io/class-web/presets/default.v1.0.0.json | jq .reference > config.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had expected a corresponding file in apps/class-solid/public. Are these old changes that need to be reverted?
| If you add an preset the `src/lib/presets.ts` file needs to be updated. | ||
|
|
||
| An experiment from a preset can be opened from a url like `?preset=<preset-name>`. | ||
| For example to load <src/lib/presets/death-valley.json> use `http://localhost:3000/?preset=Death%20Valley`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's cool! But now we have a share URL that says /?experiments=... and the preset url that says /?preset=... which defaults to a single experiment. Makes me wonder if we shouldn't provide one consistent way to encode URLs. See #102
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, yep lets look at the different search params later
| const initialExperiment = () => { | ||
| const defaultPreset = findPresetByName(); | ||
| const initialExperimentConfig = createMemo(() => { | ||
| const config = defaultPreset.parse({}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The defaultPreset already has a .config stored in it, right? Why do we create it again here?
| return { config, schema, validate, parse }; | ||
| } | ||
|
|
||
| export const presets = presetConfigs.map(loadPreset); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my brains limited RAM it would help if presets was defined immediately after presetConfigs
apps/class-solid/src/lib/store.ts
Outdated
| name: config.name ?? `My experiment ${experiments.length}`, | ||
| description: config.description ?? "Standard experiment", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If name and description are set here, we could leave them blank elsewhere.
apps/class-solid/src/lib/store.ts
Outdated
| reference: { | ||
| config: upload.reference, | ||
| config: { | ||
| preset: upload.preset ?? preset, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
upload.preset is a string, but preset is a Preset, right?
| const refConfig = structuredClone(exp.config.reference); | ||
| const perm = exp.config.permutations[permutationIndex]; | ||
| const permConfig = structuredClone(perm); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The store is getting quite big for my complexity comfort level. Would it make sense to split it into dedicated modules for experiments, permutations, and analysis?
| // biome-ignore lint/suspicious/noExplicitAny: recursion is hard to type | ||
| export function mergeConfigurations(first: any, second: any) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better if we keep the config flat but add a 'group' parameter to generate the groups in the web form?
|
PS: I've pushed some commits to #103 while reviewing this PR |
Co-authored-by: Peter Kalverla <[email protected]>
Co-authored-by: Peter Kalverla <[email protected]>
Co-authored-by: Peter Kalverla <[email protected]>
It was used to show the preset, but has been replaced by text in the form.
Refs #61
TODO