Skip to content

Conversation

@sverhoeven
Copy link
Collaborator

@sverhoeven sverhoeven commented Nov 11, 2024

Refs #61

TODO

  • store preset as JSON files in apps/class-solid/public/presets
  • Start button shows avalable presets, and on click its loaded
  • On experiment knows if it was made from a preset, by gray text in reference form
    • preset persist on save
    • preset persist on dowload configuration
    • preset persist on dowload configuration & output
  • http://localhost:3000/?preset=/presets/death-valley.json loads the preset.
  • load from url with preset and partial configs
  • experiment from preset should have reference.config be partial towards preset. Aka when preset has theta_0: 500, then in reference form 500 should be placeholder.
  • permutation from experiment from preset should have its config partial towards reference config and preset. For example if preset has theta_0:500 and reference theta_0: 333 then placeholder in permutation form should be 333.
  • pruneConfig
    • (permuation, reference)
    • (permuation, reference, preset)
  • mergeConfigs(permuation, mergeConfigs(reference, preset))
  • use presets/defaults.json for defaults instead of defaults in packages/class/src/config.ts,
  • make app/presets/defaults.json symlink from package/src/defaults.json , make sure its included in npm publish config.json not on npm.js #76
  • makes preset required, with default to presets/defaults.json
  • make sure partial configs are used, everywhere else use full config in
    • diff,
    • download and
    • form

@sverhoeven sverhoeven changed the base branch from 61-persist-app-state to main January 8, 2025 11:25
sverhoeven and others added 6 commits January 8, 2025 15:12
@Peter9192
Copy link
Member

Peter9192 commented Jan 9, 2025

  • Move preset.json to src (no hyperlinks needed; from async to sync); presets from urls to strings
  • Use full config and Config everywhere (store Experiment/Permutation) except where it must be partial (diff view, form, download, share link)
  • Dedupe ExperimentConfigForm and PermutationConfigForm

@sverhoeven
Copy link
Collaborator Author

sverhoeven commented Jan 13, 2025

Reduce types of config

  • Config
  • PartialConfig: Everything optional
  • NamedConfig: PartialConfig with name and description
  • ExperimentConfigSchema, nested with permutations and preset
  • Experiment: Extends ExperimentConfigSchema with output
  • AppState (anonymous type in apps/class-solid/src/lib/encode.ts) : used for share link, has partial configs to reduce size

TODO

  • Move name + description to Config
  • Make Experiment = ExperimentConfigSchema + ExperimentOutput (running, output: {reference, permutations})
  • replace title in NamedAndDescription with name, to make consistent

@sverhoeven
Copy link
Collaborator Author

Where to put the defaults in own file or in json schema?

  1. In JSON schema as default key/value pairs, then each preset needs own JSON schema, on upload need to check preset name to get correct schema.
  2. In json file, then form submit and upload need to use both JSON schema and default object of preset

TODO
- ts errors
- inline TODOs
@sverhoeven
Copy link
Collaborator Author

Where to put the defaults in own file or in json schema?

  1. In JSON schema as default key/value pairs, then each preset needs own JSON schema, on upload need to check preset name to get correct schema.
  2. In json file, then form submit and upload need to use both JSON schema and default object of preset

For now store in JSON schema, but for form validation of permutation need defaults from reference, which is tricky.

@sverhoeven sverhoeven marked this pull request as ready for review January 17, 2025 13:03
@sverhoeven sverhoeven requested a review from Peter9192 January 17, 2025 13:03
@Peter9192 Peter9192 mentioned this pull request Jan 20, 2025
Copy link
Member

@Peter9192 Peter9192 left a 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.

# 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
Copy link
Member

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`.
Copy link
Member

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

Copy link
Collaborator Author

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({});
Copy link
Member

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);
Copy link
Member

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

Comment on lines 80 to 81
name: config.name ?? `My experiment ${experiments.length}`,
description: config.description ?? "Standard experiment",
Copy link
Member

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.

reference: {
config: upload.reference,
config: {
preset: upload.preset ?? preset,
Copy link
Member

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?

Comment on lines +213 to +215
const refConfig = structuredClone(exp.config.reference);
const perm = exp.config.permutations[permutationIndex];
const permConfig = structuredClone(perm);
Copy link
Member

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?

Comment on lines +10 to +11
// biome-ignore lint/suspicious/noExplicitAny: recursion is hard to type
export function mergeConfigurations(first: any, second: any) {
Copy link
Member

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?

@Peter9192 Peter9192 mentioned this pull request Jan 20, 2025
@Peter9192
Copy link
Member

PS: I've pushed some commits to #103 while reviewing this PR

@sverhoeven sverhoeven mentioned this pull request Jan 21, 2025
It was used to show the preset, but has been replaced by text in the form.
@sverhoeven sverhoeven merged commit a868f09 into main Jan 21, 2025
4 checks passed
@sverhoeven sverhoeven deleted the presets branch January 21, 2025 14:18
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.

3 participants