squiggle icon indicating copy to clipboard operation
squiggle copied to clipboard

Design: Figure out how to add attributes/Tags for Models

Open OAGr opened this issue 2 years ago • 5 comments

Description of suggestion or shortcoming:

Similar to Tags for values, it would be useful to add metadata for models.

Some ideas: of things we'd want:

  1. defaultSampleCount
  2. name and doc(). Doc can then be shown in the viewer
  3. version for the version of the model
  4. squiggleVersion (Acts as the default/current version, though you can still preview in other versions)
  5. presentation -> Presentation page. Often used, instead of default. (Could also be called view or showAs or README or something.
  6. Maybe version, for the version of the current project.
  7. License/permissions? Especially if the license is short.

Some ideas for syntax:

  1. Maybe @@name(), and just add it anywhere.
  2. Maybe we have one variable for the "model as a whole". Like, model -> Tag.name("My Model Name). It's not clear what "value" this should have though.
  3. We could use markdown-style metadata, with --- name: "foobar" --- first.

One challenge is that we might want some of these attributes to be easy to be compared between different files that span many Squiggle versions. So for that, we might want to use some non-Squiggle syntax, like JSON or YAML or something simple. That said, this might be a small concern.

OAGr avatar Jan 01 '24 00:01 OAGr

I think I kind of like a different name than "export" to be used for this, like config.

config name = "My great model"
config doc = "This is a long description of my model..."
config recommendedSampleCount = 10000

config views = {"user": doc, "editor": [varA, varB]} // or config.view and config.editorView
config author = "Ozzie Gooen"

Instead of config, we could also use tag, meta, expose, model or other.

One downside is that these vars would still interact with regular vars, which is awkward. We could chose to only make them accessible via config.name..., which might make this simpler. But then it's complicated that you write this as config name = 4 but read with config.name.

OAGr avatar Jan 15 '24 20:01 OAGr

@berekuk I'd be curious to get your quick take on the above sometime.

OAGr avatar Jan 16 '24 02:01 OAGr

Why "@@" is weird:

@name()
myVar = 34

@@name = 30

OAGr avatar Jan 16 '24 22:01 OAGr

// node_version = 3.30

OAGr avatar Jan 16 '24 22:01 OAGr

I guess a different way this could work is something like:

@name("My great model")
@doc("Long doc")
__file__  //Refers to current file.
....

__file__ = __file__ -> Tag.showAs(Calculator)

OAGr avatar Jan 16 '24 22:01 OAGr