data_sources = []
start_device_id = 10000
for (data_source_name, metric_name) in [child1, child2]:
    sim_parameters['start_entity_id'] = start_device_id

    entity = EntityType(
        data_source_name, db, Column(metric_name, Float()),
        bif.EntityDataGenerator(parameters=sim_parameters,
                                data_item='is_generated'), **{
                                    '_timestamp': 'evt_timestamp',
                                    '_db_schema': db_schema
                                })
    dim = '%s_dim' % data_source_name
    entity.drop_tables([dim])
    entity.make_dimension(
        dim,  # build name automatically
        Column('work_area', String(50)))

    entity.exec_local_pipeline()
    data_sources.append(entity)

    start_device_id += 10000
'''

This is what the generated data looks like: Time series data for temperature:

DEVICEID	EVT_TIMESTAMP	            DEVICETYPE	    LOGICALINTERFACE_ID	EVENTTYPE	FORMAT	UPDATED_UTC	TEMPERATURE
10001	    2019-08-22-21.18.10.884128	temp_data		                    ep                  			21.602888736326957
10017	    2019-08-22-21.23.10.884128	temp_data		                    ye			                    23.517696994037884

derived data items. The EntityDataGenerator doesn't have an incoming entity data to
work with, so it builds its own. It loads this data directly into the entity's time
series input data where is can be read by transform functions.

To test the execution of kpi calculations defined for the entity type locally
use 'test_local_pipeline'.
'''

entity.exec_local_pipeline()

'''
So far we have only looked at the ability to create numerical and categorical time
series data. You can also automatically generate dimensional attributes. 
'''

entity.make_dimension('sim_test_dimension', Column('manufacturer', String(50)), )

entity.register(raise_error=True)
entity.generate_data(days=0.5, drop_existing=True, **sim_parameters)

'''

Look at the data that was loaded into sim_test_dimension.

You should see something like this.

device_id   manufacturer
73004	    GHI Industries
73000	    GHI Industries
73003	    Rentech
73002	    GHI Industries
entity = EntityType(
    entity_name, db, Column('TURBINE_ID', String(50)),
    Column('TEMPERATURE', Float()), Column('PRESSURE', Float()),
    Column('STEP', Float()), Column('PRESS_X', Float()),
    Column('PRESS_Y', Float()), Column('TEMP_X', Float()),
    Column('TEMP_Y', Float()),
    Issue455HTTPPreload(
        request='GET',
        url="https://turbine-simulator.mybluemix.net/v1/api/reading",
        output_item='http_preload_done'), **{
            '_timestamp': 'evt_timestamp',
            '_db_schema': db_schema
        })
entity.make_dimension(entity_dimension_upper, Column('CLIENT', String(50)),
                      Column('ORGANIZATION', String(50)),
                      Column('FUNCTION', String(50)), **{'schema': db_schema})

entity_dimension = entity.get_attributes_dict()['_dimension_table_name']
'''
When creating an EntityType object you will need to specify the name of the entity, the database
object that will contain entity data

After creating an EntityType you will need to register it so that it visible in the Add Data to Entity Function UI.
To also register the functions and constants associated with the entity type, specify
'publish_kpis' = True.
'''
entity.register(raise_error=False)
# When creating a custom preload function you can register it by uncommenting the following lines
# You must unregister_functions if you change the method signature or required inputs.
db.unregister_functions(['Issue455HTTPPreload'])