Skip to Main Content

page_parts

binubuoTemplate Module

The template module helps you build the different JSON templates that are used by Binubuo, such as dataset templates, superset templates and the column type infer function.

Reference

class BinubuoTemplate
This is the main class and you need to instantiate it and assign to it's own object.

from binubuo.BinubuoTemplate import BinubuoTemplate
myBinuTempl = BinubuoTemplate()
BinubuoTemplate.init_template
Create a new empty template.

myBinuTempl.init_template()
BinubuoTemplate.init_column(column_name, column_type="generated", column_datatype="string")
Add a new column to the dataset template. "column_name" is the name of the column.
"column_type" is the type of the column. It can be any of the supported custom dataset types.
"column_datatype" can be any of the following supported datatypes [string|text|number|int|date|time]

myBinuTempl.init_column("MyColA", "generated", "number")
BinubuoTemplate.set_column_attribute(self, column_name, attr_name, attr_val)
Add or change an attribute on a column.

myBinuTempl.set_column_attribute("MyColA", "generator", "first_name")
BinubuoTemplate.replace_column_from_json(column_name, json_str)
Replace the complete json structure for a column. Use this with the response you get when you run the infer function in the binubuo module.

newjson = '{"column_name": "hello", "column_datatype": "string", "column_type": "fixed", "generator": "world"}'
myBinuTempl.replace_column_from_json("MyColA", newjson)
BinubuoTemplate.show_missing_attributes(column_name=None)
Show all the attributes that are missing for the template, or if you specify a column name, show only attributes missing from that column.

myBinuTempl.show_missing_attributes("MyColA")
BinubuoTemplate.validate_template
Validate all elements of your template before completing it. This will ensure that a complete and correct JSON template will be created.

myBinuTempl.validate_template()
BinubuoTemplate.complete_template(accept_errors=0)
Complete and create the final JSON document from the template elements. If "accept_errors" is set to any value higher than 0, the template will be created even though it has validation errors. Once the complete_template is run, the full json will be available as part of the object in the "template_JSON" variable.

myBinuTempl.complete_template()
completed_template_document = myBinuTempl.template_JSON

Anchor Points

On this page

  • Reference