-
Notifications
You must be signed in to change notification settings - Fork 2
datastore
The yaml datastore, is actually just a merge, of all the yaml's defined by the various modules, and by the core.yaml.
The idea of it is, Configure everything, give everyone a place to put their data as needed.
Define your data, whatever your process needs. proceed to make steps which fill in and transform that data and use it to do things.
The datastore is what passes for a stack, scoping and variables in a more usual programming language. We throw stuff into it, we use it. it stays organized, and the state of things is easy to reason about.
Think of it as a big structure of folders with things in them. The commands ls and show allow you to look around within the datastore using paths. Set, push, pop, with and ' give ways to move around and manipulate the data store in other ways.
The entire system is held in this data tree. Lots of folders in a big tree. Path names are used to get things and put things and look at things.
Paths are just like filesystem paths in Unix/Linux. The namespaces can be thought of as one tree, built from imported python code, and the yaml datastore as another tree that is built from YAML.
* foo - look/set for foo in current with stack.
* /foo - look/set for foo at an absolute path.
* .foo - look/set for foo specifically and only in the current _with_.
-
lsnavigates both trees using paths. -
setuses paths like variable names. getting and putting values in them. -
showuses paths to find what to show. -
withpushes a path onto a stack so everyone knows where to look for data.
SPR:> set foo/bar 10
SPR:> show foo
bar: 10
SPR:> set foo/baz /foo/bar
SPR:> show foo
bar: 10
baz: 10
SPR:> ls /foo
bar
baz
It is also possible to embed the yaml in the the spr file with a ' on a line by itself just before the YAML. The YAML should be followed by two blank lines, that tells the SPR parser to stop parsing YAML and go back to normal. Inline yaml within spr code is indicated by a ' on a line by itself. The Yaml will be parsed until 2 consecutive blank lines are encountered. It will be merged at the location of the current with.
Yaml inlined in spr code.
'
foo:
bar: 10
baz: 20
or like this with a with.
with /foo
'
bar: 10
baz: 20
Anything from a config file goes into /config, Other stuff goes elsewhere, extensions can have their own space within the datastore. It is recommended to use the same names as the module name.
The default behavior for inline yaml is to merge into the current with location.
Truthfully it's probably a waste of time writing this,
The easiest way to see what is there is to go look.
Just go into the REPL and have a look around.
Use ls /<path> and show <path>.
It is a data structure that was originally the configuration loaded
from a YAML file. It still is. But it's also where processes and extensions
can put stateful data that they are keeping track of or using.
The config folder, is for stuff you want to define in a file, and you mostly don't change.
and next to config, you can see them with ls / is lots of other stuff,
including the core of SPR.
You can save this config and change it, and load it to change the ways that different modules behave, or even how SPR behaves. It's prompt was one of the first options to go into the config section.
You only actually need to keep the parts you change.
The yaml datastore is first built from the core of SPR, and then with each import that SPR makes. If you import mymodule.foo, spr will also merge _mymodule.foo.yaml. into the yaml datastore, and will then execute foo.spr
A complete configuration file can be generated at any time by saving it with save-config. Note that this is only the config section of the data tree.
The configuration file should be named SPRConfig.yaml and will automatically loaded
from the runtime directory if it exists. A different name can be specified with
the -c option. Or the name can be changed in the default section of the configuration.
There are other things in the yaml datastore, each SPR extension can also add a structure to the root of the tree to hold the information that it cares about. This is the state part of the structure. The yaml datastore is defined by collecting all of the extension modules yaml file and merging them together as they are imported.
Yaml files can also be merged directly into the yaml datastore config with load-config.
`load-config foo.yaml`
Yaml files can be merged directly into the Root of the yaml datastore. with load-yaml.
`load-yaml foo.yaml`