td-ml-datamodel-create
Introduction
This Python Library allows you to define the main JSON params of a Treasure Insights Datamodel in a config.json file inside a Treasure Workflow Project and build datamodel automatically via API.
Inputs
config.json: the file that contains the needed params for Python code to read from and build the TI Datamodel. See below:
{
## -- (name of datamodel)
"model_name": "datamodel_automated"
,
## -- (list of tables to be added to datamodel)
"model_tables": [
{"db":"sink_database","name":"table_1"},
{"db":"sink_database","name":"table_2"}
]
,
## -- (list of users to share datamodel with)
"shared_user_list": ["ENTER EMAIL HERE","ENTER EMAIL HERE"]
,
## -- (list of columns you want to change datatype from raw table to datamodel. Ex. in "date" you provide column names that will be converted to `datetime`)
"change_schema_cols": {"date": ["ENTER_NAME"], "text": ["ENTER_NAME"], "float": ["ENTER NAME"], "bigint": ["ENTER NAME"]}
,
## -- (if any joins were required you can add a list of table_name:join_key pairs)
"join_relations": {"pairs":
[
{"db1": "sink_database", "tb1":"table_1","join_key1":"user_id","db2": "sink_database","tb2":"table_2","join_key2":"user_id"},
{"db1": "sink_database", "tb1":"table_1","join_key1":"date","db2": "sink_database","tb2":"table_2","join_key2":"date"}
]
}
}
input_params.yml: Thecreate_datamodel.pyfile requires also the four params below, which are being defined in the main workflowYAMLfile and imported into Custom Scripting as_env variables.
Declare ENV Variables from YML file
- apikey = os.environ['TD_API_KEY']
- tdserver = os.environ['TD_API_SERVER']
- sink_database = os.environ['SINK_DB']
- output_table = os.environ['OUTPUT_TABLE']
Copyright © 2022 Treasure Data, Inc. (or its affiliates). All rights reserved
Metadata
Release files for td-ml-datamodel-create 0.1.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| td_ml_datamodel_create-0.1.9.tar.gz | 3.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| td_ml_datamodel_create-0.1.9-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.1 kB
Release files / td_ml_datamodel_create-0.1.9.tar.gz
| Download URL | td_ml_datamodel_create-0.1.9.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b228458d6422593b65f015797bd1ff5ad720f3597ab15beb8d213785674d8c86
|
|
BLAKE2b-256 checksum How to use checksums |
6398498d32d5b676cb854841b31a2bd77e1175e2b5dba10d3df50b940d5ac8ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.19
|
Release files / td_ml_datamodel_create-0.1.9-py3-none-any.whl
| Download URL | td_ml_datamodel_create-0.1.9-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b480071f22922d897651a8438211e9711da2a8e33b2bfca212b3e69571e247c2
|
|
BLAKE2b-256 checksum How to use checksums |
65c4771a16d8f507bec20890e1f8f74131811a53c64aaaa61bfac8b10259ef26
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.19
|