Skip to Main Content

page_parts

Binubuo Module

The main module of Binubuo gives you all the core abilities and integration points with the Binubuo web services to help you create the data you need.

Configuration

There are a number of configuration parameters that impact the way that the Binubuo client works. The client will automatically look for the configuration file binubuo.conf in the following places and in this order:

  • Current directory where you started the script or console.
  • Your home directory as defined by the env variable HOME
  • Lastly, if you have set BINUBUO_HOME env variable it will look there.

Reference

The reference points to all the supported functions in the core Binubuo module.

class binubuo
This is the main class and you need to instantiate it to your own copy, to use the client. If you init the class without a key, you will be assigned a temporary key.
Initiate with a key:

from binubuo import binubuo
myBinu = binubuo('MY_KEY_HERE')
Initiate without a key:

from binubuo import binubuo
myBinu = binubuo()
binubuo.create_account(account_name, account_email)
If you have not yet created an account with Binubuo you can use this command to create the account. Just supply the account name and your email and follow the process on screen.

>>> from binubuo import binubuo
>>> myBinu = binubuo()
>>> myBinu.create_account('create_account_demo', 'your_email@example.com')
Choose a password for your account: c6uuUnUNMrF3qdFZA6NJ
Re-enter password to validate: c6uuUnUNMrF3qdFZA6NJ
Please got to this url in your browser: https://binubuo.com/ords/r/binubuo_ui/binubuo/challenge-response?p_sha=A3053D485B02ED8B936CA2918609E8192B92D825
Please input the code displayed in the above URL: 308825
Your API key for Binubuo is (please save it.): FD58E9F31D54A5C1591D46A27DD59F2EDF1634D3
binubuo.key(key=None)
Set the application key to use. If you want to use a different key then the one used for the initial load, you can use this function to change it.

myBinu.key('FD58E9F31D54A5C1591D46A27DD59F2EDF1634D3')
binubuo.tz(tz)
Set the time zone for the current call session. It takes the timezone in the format in ISO-8601 format. Call with None to unset. So if you want to set the timezone for GMT plus 8 hours:

myBinu.tz('+08:00')
binubuo.session_id(session_id)
If you want to use session id to ensure proper recursive calls to dependent datasets you use this function to set the id. Call it with None to unset.

myBinu.session_id('MY_SESSION_ID_HERE')
binubuo.locale(locale)
Setting the locale used when generating data. Input is the iso two letter code of the country. Call with None to go back to your default locale.

myBinu.locale('JP')
binubuo.tag(tag)
Using tags to create repeatable random data, set it with the tag method. Unset the tag, call it with None as input.

myBinu.tag('FUNC_TEST_12_A')
binubuo.csv(csv)
Call this method with any value, to generate output as CSV instead of JSON. Call with None as input to unset CSV generation.

myBinu.csv(1)
binubuo.grows(rows=1)
Set the default number of rows returned when calling a generator. The default is 1.

myBinu.grows(5)
binubuo.drows(rows=10)
Set the default number of rows returned when calling a dataset. The default is 10.

myBinu.drows(40)
binubuo.dataset_sample(dataset_name, dataset_type="custom", dataset_category=None)
Create a sample output of 3 rows of a dataset. If you are just getting a sample from one of your own dataset, you do not need to supply a dataset_type or dataset_category. If you want to see a sample from one of the predefined sample datasets you need to set the dataset_type to 'standard' and the dataset_category that the dataset is in.

myBinu.dataset_sample('user_list', 'standard', 'computer')
binubuo.dataset_exists(dataset)
Check if a specific custom dataset exists. This is only for custom datasets.

>>> myBinu.dataset_exists('DOES_NOT_EXIST')
False
binubuo.standard_dataset_exists(dataset, category=None)
Check if a specific standard dataset exists. This is only for Binubuo predefined datasets. If you do not set a category, it will try and read your configuration and see if you have a default category set for predefined datasets. If the dataset exists it will return the dataset name, and if it does exists it will return False

>>> myBinu.standard_dataset_exists('actor', 'pagila')
'Pagila'
binubuo.list_generators
Call this method to see a list of all available generators from Binubuo.

myBinu.list_generators()
binubuo.list_datasets
Call this method to see a list of all available datasets from Binubuo.

myBinu.list_datasets()
binubuo.generate(category, function)
Call this method to generate data from one of the many random data generators from Binubuo. You need to supply the category of the generator and the name of the generator. See here for a full list of generators.

myBinu.generate('person', 'first_name')
binubuo.dataset(dataset_name, dataset_type="custom", dataset_category=None, response_type="list", **webargs)
Call this method to generate data from a synthetic dataset. If you are just calling one of your own datasets, you should not supply anything for dataset_type or dataset_category.
If you are calling a standard dataset, your dataset_type should be set to 'standard' and the dataset_category to whatever category the dataset is in. See here for a full list of predefined datasets and their categories.
response_type can be set to one of three values. The default value is "list", where the data is returned in a standard python list. Another value is "tuple" where the data is returned in tuples ready to integrate with databases. The last type is "json" where the output is in json format.
**webargs is for dataset specific parameters. You can simply add them as named parameters to the call.
Calling custom dataset:

myBinu.dataset('Myowndataset')
Calling standard dataset:

myBinu.dataset('actor', 'standard', 'pagila')
binubuo.dataset_to_file(dataset_name, file_name="same", dataset_type="custom", dataset_category=None)
Call a dataset and write the output directly to a file. The parameters are the same as calling the normal binubuo.dataset method.

myBinu.dataset_to_file('actor', 'actor_data.json', 'standard', 'pagila')
binubuo.quick_fetch(columns="first_name,last_name,address,city", response_type="list)
Call the quick fetch endpoint, where you can quickly get more generic data very quickly. The "columns" parameter is the comma separated list of generators to use.
"response_type" can be set to one of three values. The default value is "list", where the data is returned in a standard python list. Another value is "tuple" where the data is returned in tuples ready to integrate with databases. The last type is "json" where the output is in json format.

myBinu.quick_fetch('first_name,address,last_name')
binubuo.quick_fetch_to_file(columns="first_name,last_name,address,city", file_name="same")
Call quick fetch and write the results directly to a file. The parameters are the same as calling the normal binubuo.quick_fetch method.

myBinu.quick_fetch_to_file('first_name,address,last_name')
binubuo.infer_generator(column_meta)
Supply a json document describing your data requirements, and we will return with a full json column configuration that you can use when you create your own synthetic datasets.
binubuo.create_dataset(dataset_name, dataset_meta)
Create a custom dataset. You need to supply a name and the full json formatted meta document describing your dataset. For details about the json format, please read the Custom Datasets section of the documentation.
binubuo.create_superset(superset_meta)
Create a custom superset, which is a set of datasets in specific order and relational attributes and dependencies.
binubuo.get_superset(superset_name, scale=1)
Get the superset definition, with list of datasets, order and size. The size is dependent on the scale you supply. If a dataset is normally 1000 rows, and you supply a scale of 0.1, the new size will be 100 rows.
binubuo.create_session
Create a session id to use with the binubuo.session_id method. Sessions are created on Binubuo server side, so it is important to call this to get a valid session id. Creating sessions ensures data relations and dependencies are consistent across calls to binubou.dataset. This is especially important if you are creating data from binubuo.get_superset data.
binubuo.remove_session
Remove a registered session, to revert to the default functionality of data generation. Remember to call binubuo.session_id method with None, to remove on your side as well.

Anchor Points

On this page

  • Configuration
  • Reference