-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
02f8e33
commit 67d2aca
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
docs/manuals/core/config/code_example/data_node_cfg/data-node-config-aws-s3.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#Upload and retrive raw data from existing s3 bucket | ||
import taipy as tp | ||
import boto3 | ||
from taipy import Config, Core, Gui | ||
|
||
|
||
input_text = None | ||
s3_result = None | ||
|
||
|
||
page = """ | ||
message: <|{input_text}|input|> | ||
<|submit|button|on_action=upload_scenario|> | ||
Retrived : <|{s3_result}|text|> | ||
""" | ||
|
||
|
||
|
||
def get_s3_data(s3_object, s3_result): | ||
return f"Your S3 results: {s3_result}" | ||
|
||
|
||
def upload_scenario(state): | ||
state.scenario.input_text.write(state.input_text) | ||
state.scenario.my_s3_object.write(state.input_text) | ||
state.scenario.submit() | ||
state.s3_result = scenario.my_s3_object.read() | ||
|
||
|
||
s3_object_cfg = Config.configure_s3_object_data_node( | ||
id="my_s3_object", | ||
aws_access_key="YOUR AWS ACCESS KEY", # Can be passed as env variable as well | ||
aws_secret_access_key="YOUR AWS SECRET ACCESS KEY", # Can be passed as env variable as well | ||
aws_s3_bucket_name="YOUR AWS BUCKET Name", #Must be Already existing bucket | ||
aws_s3_object_key="taipy_object", | ||
aws_s3_object_parameters = {'CacheControl': 'max-age=86400'}) | ||
|
||
input_text_data_node_cfg = Config.configure_data_node(id="input_text") | ||
s3_result_data_node_cfg = Config.configure_data_node(id="s3_result") | ||
store_data_task_cfg = Config.configure_task("upload", get_s3_data, input=[s3_object_cfg,input_text_data_node_cfg], output=[s3_result_data_node_cfg]) | ||
scenario_cfg = Config.configure_scenario("scenario", task_configs=[store_data_task_cfg]) | ||
|
||
if __name__ == "__main__": | ||
|
||
Core().run() | ||
scenario = tp.create_scenario(scenario_cfg) | ||
Gui(page).run(debug=True) |