-
Notifications
You must be signed in to change notification settings - Fork 3
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
Kiara stores, and the export feature #28
Comments
To put the export feature into context, first a quick introduction to kiara stores. kiaras central context management happens via several registries, each of them responsible for other aspects of kiaras internal workings. For our purposes, the relevant ones are:
Common to all of them that internally, the manage pluggable so-called archives & stores. I'll be calling those mostly 'archive' from here on out, but might mean 'store' on occasion. The (only) difference between those two is that archives are read-only, and stores can be written to. Also, you can create a store, write to it, and from then on treat it as a read-only archive if you want to make sure it doesn't change anymore. For example for, well ...archiving... purposes. A store can be an archive, but not the other way round. Each registry has a default store, that is used to store any instances of the items a registry handles, unless otherwise specified. Each archive has an ID (uuid), and is registered with a human-readable alias into the currently active context, which is used to specify them explicitly if necessary. The default stores alias is Data registryThe data registry is responsible for managing the actual data (bytes) of the all input and output values. It assigns them (value-)IDs, validates their types, manages metadata, serializes and deserializes them, etc. Those last bits (serializing/deserializing) are the most important bits, because that allows kiara to persist values across user sessions (if users use the 'store' method of on values). Storing must happen into a store, and as mentioned above, usually that uses the 'default' data store. Currently there exists two different implementation of the DataArchive class that defines the interface such an archive/store has: The main difference is how the stored data is written to disk, the filesystem archive has it layed out across a folder in the filesystem, the sqlite one inside a sqlite database file. Both have advantages and disadvantages, the filesystem is better for random access to the stored bytes, sqlite is better to share, since it's just a single file. Up until now, only the filesystem archive type existed, and thus was the default type that was created automatically for a new kiara context. I will probably change that in the future, but for now I'll keep that default. If you want to change the default type that gets created for new contexts, you can change the Alias registryMost things that I described for the Data registry are similar for the Alias registry. We have the same two types: filesystem & sqlite, most importantly, with filesystem being the default (for now). The alias registry is basically a key value store, that lets users assign human readable, (to them) meaningful aliases to value IDs (of type uuid). Its similar to how filenames map to inodes on a filesystem, just much simpler. |
I don't know if the following questions belong here (please let me know if not and I will reproduce this comment where it belongs): Does the former data store (https://dharpa.org/kiara.documentation/latest/usage/getting_started/#checking-the-data-store) still behave the same way, i.e.: are the recommended ways to access data from the CLI still: I am trying to find out the date and time at which a data item was added to the "store" (or archive), how should I do it? |
Yeah, as long as there is a (sub-) command in the cli that works it's a supported way to do things. You can also do (Sidenote: the 'develop' plugin also adds some sub-commands, those are not really that thought through, but the usual suspects At the moment kiara does not record any time/date related to values. That is a good example of stuff you'd add to your list of requirements (independent of whether it already exists or not). |
Ok, following some documentation about the initial version of the export feature. This was a big change, and lots of code, and there are bits and pieces I'm not sure yet I got right in terms of design/interface, so consider this as an initial version for testing and feedback. I don't expect the actual archives that get exported to work in later versions yet, their internal structure is very likely to change a bit, and its not feasible to keep them compatible for now. This will of course change before we hit production. Overall, I also expect there to be quite a few little things and issues I missed, as the surface of the feature is surprisingly large. I intend to squash those with the help of your bug-reports and still-to-be-written tests. I'll release a release-candidate version of kiara soonish, so people can try it all out, but wanted to make sure there's some docs first. I'll let you know when that is the case. kiara archivesAs usual, naming things was really hard, because a lot of concepts that would be good names were already taken and mean something within kiara already. I think (hope) it will be safe and minimally confusing to use 'archive' in general, even though internally the meaning of it is slightly different. But those inner workings should not really be exposed to intermediate or even advanced API users knocking on wood. So, in our context here, a 'kiara archive' means a file (usually with the extension (as a reminder, the current context is just a sort of workspace containing the stuff you are currently working on. Whether we want users to be able to change between/manage those is a question we haven't answered yet, and that will hopefully come from some frontend requirements) archive exportAssuming you have data in your current kiara context (as well as maybe some aliases), and you want to export those into an archive file, you can use the cli as follows:
This will create a file If you want to append the data to an existing archive, you need to use the the Via the API you can use the An example would be:
The result here will tell you details about how the storing went, and if there were any errors. The result type is of type archive importThis works very similarly to export, except you use an existing external archive to import its data into your current kiara context:
The only option here is the API usage:
Again, check the API endpoint docs for more info. Archive infoTo see some details about an archive, you can use:
Or:
( The result type would be |
Exporting one or several valuesIn order to export one or several values into a new (or existing) archive, you can now use this via the cli:
This command has a few additional options, so check out its help for more info:
Via the API, you would use the
Instead of aliases (strings) you can also use
The alias map here is a bool and tells kiara to also store the alias as they are into the new archive (in case of a dict it uses the keys). This will automatically also store all values that are somehow related to the ones you specify (inputs in its lineage tree, properties, etc.). |
Importing only a subset of values an existing archiveIn order to import one or several values from an external archive into the default kiara store, you can use the cli like:
So, for example, importing the alias
Via Python, the same thing could be done via the
|
Archive registrationThis is a quick description how an implementation detail for the import/export features works, but keep in mind that this could be changed in the future, it's just a high level overview so the reader can get an idea how this is done internally. In order to copy values to/from an archive, kiara internally 'mounts'/'registers' the archive as both a new data and alias store. While doing that, it gives it a temporary, internal name (an alias, really, but I don't want to create confusion with the other meaning of 'alias' here). This name is used in In the case of a new alias_archive being registered into the kiara context, you can now try the Currently, all the new API endpoints expect the external archive to not be registered yet (except for To manually register a new archive, you can use the As I said, this is an implementation detail, so it's not 100% necessary to understand exactly how this works. But if you think this is something you need to understand, ping me and I'll expand on what I wrote here. |
Placeholder issue for documentation about the upcoming export feature, incl. a writeup about kiara stores.
The text was updated successfully, but these errors were encountered: