mountetna / magma

Data server with friendly data loaders
GNU General Public License v2.0
5 stars 2 forks source link

Add load_project command #150

Closed graft closed 4 years ago

graft commented 4 years ago

In #148 we gained the ability to load attributes from the attributes table. How is the attributes table populated? In the specs, the example labors project is being loaded from a YAML fixture.

However, we already have a document format that attempts to describe the attributes for a project model completely: Magma::Model#json_template and the associated Magma::Attribute#json_template; These are usually returned by the Magma /retrieve endpoint, and are a standard tool for describing magma models (used, for example, by the ModelMap or the AttributeViewer in Timur). We ought to be able to load attributes directly from these templates into a Magma instance's attributes (and models?) table.

This would create a nice loop, where we can dump templates from one project or instance and load them into another. These project templates can be paired with associated migrations to allow easier deploy of new models. (Eventually we ought to be able to load + inflate the data graph, i.e., auto-migrate, this way.)

The command would simply take a template.json as might be output by the /retrieve endpoint as an argument, and would make entries into the attributes table using each model/attribute's JSON definition.

alimi commented 4 years ago

This was completed as described in https://github.com/mountetna/magma/pull/157. Now that we can define models in the database (https://github.com/mountetna/magma/pull/162), we can update the load_project command so it also loads models.