-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…ice-on-main-script Feature/#986 - Document best practice on main script
- Loading branch information
Showing
116 changed files
with
1,737 additions
and
1,679 deletions.
There are no files selected for viewing
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
38 changes: 19 additions & 19 deletions
38
...uals/userman/data-integration/code-example/data-node-history/data-node-history-example.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 |
---|---|---|
@@ -1,32 +1,32 @@ | ||
import random | ||
|
||
import taipy as tp | ||
from taipy import Config | ||
|
||
|
||
def random_value(): | ||
return random.randint(0, 100) | ||
|
||
if __name__ == "__main__": | ||
# Configure a data node, a tasks and a scenario | ||
int_cfg = Config.configure_data_node("random_val", scope=tp.Scope.GLOBAL, default_data=12) | ||
task_cfg = Config.configure_task("random_task", function=random_value, output=int_cfg) | ||
scenario_cfg = Config.configure_scenario("random_scenario", task_configs=[task_cfg]) | ||
|
||
# Configure a data node, a tasks and a scenario | ||
int_cfg = Config.configure_data_node("random_val", scope=tp.Scope.GLOBAL, default_data=12) | ||
task_cfg = Config.configure_task("random_task", function=random_value, output=int_cfg) | ||
scenario_cfg = Config.configure_scenario("random_scenario", task_configs=[task_cfg]) | ||
|
||
# Create a data node along with a scenario. A default value is written automatically | ||
scenario = tp.create_scenario(scenario_cfg) | ||
data_node = scenario.random_val | ||
|
||
# Manually write a new value to the data node | ||
data_node.write(100, editor="John", comment="Manual edition: 100", extra="extra data") | ||
# Create a data node along with a scenario. A default value is written automatically | ||
scenario = tp.create_scenario(scenario_cfg) | ||
data_node = scenario.random_val | ||
|
||
# Submit the scenario so that the data node is written again through a job | ||
tp.Core().run() | ||
scenario.submit() | ||
# Manually write a new value to the data node | ||
data_node.write(100, editor="John", comment="Manual edition: 100", extra="extra data") | ||
|
||
print(data_node.edits) | ||
# [{'timestamp': datetime.datetime(2024, 5, 14, 20, 12, 27, 652773), 'editor': 'TAIPY', 'comment': 'Default data written.'}, | ||
# {'timestamp': datetime.datetime(2024, 5, 14, 20, 12, 27, 689737), 'editor': 'John', 'comment': 'Manual edition: 100', 'extra': 'extra data'}, | ||
# {'timestamp': datetime.datetime(2024, 5, 14, 20, 12, 27, 856928), 'job_id': 'JOB_random_task_a8031d80-26f7-406e-9b31-33561d0f9ccd'}] | ||
# Submit the scenario so that the data node is written again through a job | ||
tp.Core().run() | ||
scenario.submit() | ||
|
||
print(data_node.edits) | ||
# [{'timestamp': datetime.datetime(2024, 5, 14, 20, 12, 27, 652773), 'editor': 'TAIPY', 'comment': 'Default data written.'}, | ||
# {'timestamp': datetime.datetime(2024, 5, 14, 20, 12, 27, 689737), 'editor': 'John', 'comment': 'Manual edition: 100', 'extra': 'extra data'}, | ||
# {'timestamp': datetime.datetime(2024, 5, 14, 20, 12, 27, 856928), 'job_id': 'JOB_random_task_a8031d80-26f7-406e-9b31-33561d0f9ccd'}] | ||
|
||
tp.Gui("<|{scenario.random_val}|data_node|>").run() | ||
tp.Gui("<|{scenario.random_val}|data_node|>").run() |
10 changes: 6 additions & 4 deletions
10
...ata-integration/code-example/data-node-vizelmts/data-node-vizelements-default-behavior.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
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
Oops, something went wrong.