# pip install --upgrade domolibraryTutorial - Generate your Features list from the Bootstrap API
Instance Configuration
Domo Features
⚙️ Configuration
⚙️ Auth Object
Configure a DomoAuth object that will be used to interact with DomoDatasets
For this project we must use DomoFullAuth because the bootstrap API will not accept token auth
import os
import domolibrary.client.DomoAuth as dmda
auth = dmda.DomoFullAuth(
domo_instance=os.environ['DOMO_INSTANCE'],
domo_password=os.environ["DOMO_PASSWORD"],
domo_username=os.environ["DOMO_USERNAME"],
)
FEATURES_DATASET_ID = "44c5af30-ea04-49e4-9d7a-529afd223590"⚙️ Dataset Object
Configure a DomoDataset that will receive the Bootstrap dataframe from DomoBootstrap
Note, the schema of the dataset must match the schema of the dataframe being uploaded or the dataset won’t index. You can alter schema using the “Schema Management” tool from the Domo Governance Toolkit or java cli.
import domolibrary.classes.DomoDataset as dmds
async def generate_dataset(dataset_id: str, auth: dmda.DomoAuth):
"""generates a DomoDataset class object from a dataset_id"""
return await dmds.DomoDataset.get_by_id(dataset_id=dataset_id, auth=auth)
# test
await generate_dataset(dataset_id=FEATURES_DATASET_ID, auth=auth)DomoDataset(id='44c5af30-ea04-49e4-9d7a-529afd223590', display_type='api', data_provider_type=None, name='demo_instance_features', description=None, row_count=1729, column_count=7, stream_id=911, owner={'id': '1893952720', 'name': 'Jae Wilson1', 'type': 'USER', 'group': False}, formula={}, Schema=DomoDataset_Schema(dataset_id='44c5af30-ea04-49e4-9d7a-529afd223590', columns=[]), Stream=DomoStream(id=911, dataset_id='44c5af30-ea04-49e4-9d7a-529afd223590', transport_description=None, transport_version=None, update_method=None, data_provider_name=None, data_provider_key=None, account_id=None, account_display_name=None, account_userid=None, has_mapping=False, configuration=[], configuration_tables=[], configuration_query=None), Tags=DomoTags(tag_ls=[]), PDP=<domolibrary.classes.DomoPDP.Dataset_PDP_Policies object>, Certification=None)
💾 Bootstrap Data
Retrieve your feature list using DomoBootstrap.get_features() and format it as a dataframe
import pandas as pd
import domolibrary.classes.DomoBootstrap as dmbsr
async def get_bootstrap(auth, debug_api: bool = False) -> pd.DataFrame:
"""generates a dataframe of bootstrap_features"""
domo_bsr = dmbsr.DomoBootstrap(auth=auth)
bsr_features = await domo_bsr.get_features(debug_api=debug_api)
bsr_features_df = pd.DataFrame(bsr_features)
bsr_features_df["instance"] = auth.domo_instance
return bsr_features_df
# test
upload_df = await get_bootstrap(auth)
upload_df[0:5]| id | name | label | type | purchased | enabled | instance | |
|---|---|---|---|---|---|---|---|
| 0 | 4 | search | STANDARD | False | True | domo-community | |
| 1 | 5 | launcher | PREMIUM | True | True | domo-community | |
| 2 | 9 | profile-reminder | STANDARD | False | True | domo-community | |
| 3 | 17 | enableSwapDatasource | STANDARD | False | True | domo-community | |
| 4 | 19 | up | STANDARD | True | True | domo-community |
🚀 Execute Main 🚀
import pandas as pd
import time
async def main(auth, debug_api: bool = False):
script_start = time.time()
upload_df = await get_bootstrap(auth=auth, debug_api=debug_api)
feature_ds = await generate_dataset(
dataset_id=FEATURES_DATASET_ID, auth=auth
)
print(
f"🥫 {len(upload_df)} rows to upload to {feature_ds.name} - {feature_ds.display_url()}"
)
await feature_ds.upload_data(
upload_df=upload_df,
partition_key=auth.domo_instance,
is_index=True,
)
script_end = time.time()
print(f"🥫 done! Took {script_end - script_start} seconds")
return True
await main(auth = auth , debug_api=False)
upload_df[0:10]🥫 492 rows to upload to demo_instance_features - https://domo-community.domo.com/datasources/44c5af30-ea04-49e4-9d7a-529afd223590/details/overview
🥫 done! Took 10.667160511016846 seconds
| id | name | label | type | purchased | enabled | instance | |
|---|---|---|---|---|---|---|---|
| 0 | 4 | search | STANDARD | False | True | domo-community | |
| 1 | 5 | launcher | PREMIUM | True | True | domo-community | |
| 2 | 9 | profile-reminder | STANDARD | False | True | domo-community | |
| 3 | 17 | enableSwapDatasource | STANDARD | False | True | domo-community | |
| 4 | 19 | up | STANDARD | True | True | domo-community | |
| 5 | 25 | account-management | STANDARD | False | True | domo-community | |
| 6 | 66 | advanced-scheduling | STANDARD | False | True | domo-community | |
| 7 | 67 | 2factor | STANDARD | False | True | domo-community | |
| 8 | 69 | saasaas | STANDARD | False | True | domo-community | |
| 9 | 1466 | access-token | STANDARD | False | True | domo-community |