text
stringlengths
0
24.9k
# # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software distributed u...
class ConfigIdMissingException(Exception): def __init__(self): self.message = "Config id is missing." class ScenarioIdMissingException(Exception): def __init__(self): self.message = "Scenario id is missing." class SequenceNameMissingException(Exception): def __init__(self): ...
from marshmallow import Schema, fields class CycleSchema(Schema): name = fields.String() frequency = fields.String() properties = fields.Dict() creation_date = fields.String() start_date = fields.String() end_date = fields.String() class CycleResponseSchema(CycleSchema): id ...
from marshmallow import Schema, fields class TaskSchema(Schema): config_id = fields.String() id = fields.String() owner_id = fields.String() parent_ids = fields.List(fields.String) input_ids = fields.List(fields.String) function_name = fields.String() function_module = fields.S...
from marshmallow import Schema, fields class CallableSchema(Schema): fct_name = fields.String() fct_module = fields.String() class JobSchema(Schema): id = fields.String() task_id = fields.String() status = fields.String() force = fields.Boolean() creation_date = fields.Strin...
from marshmallow import Schema, fields class SequenceSchema(Schema): owner_id = fields.String() parent_ids = fields.List(fields.String) tasks = fields.List(fields.String) version = fields.String() properties = fields.Dict() class SequenceResponseSchema(SequenceSchema): id = field...
from .cycle import CycleResponseSchema, CycleSchema from .datanode import ( CSVDataNodeConfigSchema, DataNodeConfigSchema, DataNodeFilterSchema, DataNodeSchema, ExcelDataNodeConfigSchema, GenericDataNodeConfigSchema, InMemoryDataNodeConfigSchema, JSONDataNodeConfigSchema, M...
from marshmallow import Schema, fields, pre_dump class DataNodeSchema(Schema): config_id = fields.String() scope = fields.String() id = fields.String() storage_type = fields.String() name = fields.String() owner_id = fields.String() parent_ids = fields.List(fields.String) la...
from marshmallow import Schema, fields class ScenarioSchema(Schema): sequences = fields.Dict() properties = fields.Dict() primary_scenario = fields.Boolean(default=False) tags = fields.List(fields.String) version = fields.String() class ScenarioResponseSchema(ScenarioSchema): id ...
from importlib import util import inspect import os if util.find_spec("taipy") and util.find_spec("taipy.gui"): from taipy.gui import Gui taipy_path = f"{os.path.dirname(os.path.dirname(inspect.getfile(Gui)))}" potential_file_paths = [ f"{taipy_path}{os.sep}gui{os.sep}viselements.json", ...
import taipy as tp import pandas as pd from taipy import Config from taipy.gui import Gui, Markdown, notify Config.configure_global_app(clean_entities_enabled=True) tp.clean_all_entities() input_text_cfg = Config.configure_data_node(id="input_text") text_length_cfg = Config.configure_data_node(id="text_lengt...
import json def add_line(source, line, step): line = line.replace('Getting Started with Taipy', 'Getting Started with Taipy on Notebooks') line = line.replace('(../src/', '(https://docs.taipy.io/en/latest/getting_started/src/') line = line.replace('(dataset.csv)', '(https://docs.taipy.io/en/latest...
from step_08 import * # Get all the scenarios already created all_scenarios = tp.get_scenarios() # Delete the scenarios that don't have a name attribute # All the scenarios of the previous steps do not have an associated name so they will be deleted, # this will not be the case for those created by this step ...
from step_07 import * # Initial variables ## Initial variables for the scenario day = dt.datetime(2021, 7, 26) n_predictions = 40 max_capacity = 200 page_scenario_manager = page + """ # Change your scenario **Prediction date**\n\n <|{day}|date|not with_time|> **Max capacity**\n\n <|{max_capacity}|nu...
import datetime as dt import pandas as pd from taipy import Config, Scope from step_01 import path_to_csv # Datanodes (3.1) ## Input Data Nodes initial_dataset_cfg = Config.configure_data_node(id="initial_dataset", storage_type="csv", ...
from step_05 import * from step_06 import scenario_cfg from taipy import Config # Set the list of pipelines names # It will be used in a selector of pipelines pipeline_selector = ["baseline", "ml"] selected_pipeline = pipeline_selector[0] scenario_page = page + """ Select the pipeline <|{selected_pipelin...
# For the sake of clarity, we have used an AutoRegressive model rather than a pure ML model such as: # Random Forest, Linear Regression, LSTM, etc from statsmodels.tsa.ar_model import AutoReg from taipy import Config from step_04 import * from step_03 import cleaned_dataset_cfg, n_predictions_cfg, day_cfg, ...
from step_01 import dataset, n_week, Gui # Select the week based on the slider value dataset_week = dataset[dataset["Date"].dt.isocalendar().week == n_week] page = """ # Getting started with Taipy Select week: *<|{n_week}|>* <|{n_week}|slider|min=1|max=52|> <|{dataset_week}|chart|type=bar|x=Date|y=Valu...
from step_11 import * from sklearn.metrics import mean_absolute_error, mean_squared_error # Initial dataset for comparison comparison_scenario = pd.DataFrame({"Scenario Name": [], "RMSE baseline": [], "MAE baseline": [], "RMSE ML": [], "MA...
import numpy as np import pandas as pd from step_04 import tp, baseline_pipeline_cfg, dt from step_02 import * # Initialize the "predictions" dataset predictions_dataset = pd.DataFrame( {"Date": [dt.datetime(2021, 6, 1)], "Historical values": [np.NaN], "Predicted values": [np.NaN]}) # Add a button and ...
from taipy import Gui import pandas as pd def get_data(path_to_csv: str): # pandas.read_csv() returns a pd.DataFrame dataset = pd.read_csv(path_to_csv) dataset["Date"] = pd.to_datetime(dataset["Date"]) return dataset # Read the dataframe path_to_csv = "dataset.csv" dataset = get_data(pa...
from step_10 import * from step_06 import ml_pipeline_cfg from taipy import Config, Frequency from taipy.gui import notify # Create scenarios each week and compare them scenario_daily_cfg = Config.configure_scenario(id="scenario", pipeline_configs=[baseline_pipel...
from taipy import Gui # A dark mode is available in Taipy # However, we will use the light mode for the Getting Started Gui(page="# Getting started with *Taipy*").run(dark_mode=False)
from step_09 import * from taipy.gui import navigate # Our first page is the original page # (with the slider and the chart that displays a week of the historical data) page_data_visualization = page # Second page: create scenarios and display results page_scenario_manager = """ # Create your scenario <...
import taipy as tp from step_03 import Config, clean_data_task_cfg, predict_baseline_task_cfg, dt # Create the first pipeline configuration baseline_pipeline_cfg = Config.configure_pipeline(id="baseline", task_configs=[clean_data_task_cfg, predict_baseline_task_...
AWS_ACCESS_KEY = '' AWS_SECRET_KEY = '' AWS_REGION = '' S3_BUCKET_NAME = ''
from flask import Flask, render_template, redirect, url_for, request, flash from werkzeug.utils import secure_filename from uploads.file_handler import is_file_type_allowed, upload_file_to_s3, get_presigned_file_url from localStoragePy import localStoragePy from transformers import AutoTokenizer, pipeline # from t...
import uuid import boto3 from config import AWS_ACCESS_KEY, AWS_SECRET_KEY, AWS_REGION, S3_BUCKET_NAME s3 = boto3.client('s3', aws_access_key_id=AWS_ACCESS_KEY, aws_secret_access_key=AWS_SECRET_KEY, region_name=AWS_REGION ) ALLOWED_FILE_TYPES = {'csv'} S3_BUCKET_NAME = S3_BUCK...
import json def add_line(source, line, step): on_change_needed = ['step_02', 'step_09', 'step_11'] line = line.replace('Getting Started with Taipy', 'Getting Started with Taipy on Notebooks') line = line.replace('(../src/', '(https://docs.taipy.io/getting_started/src/') line = line.replace('(...
from step_08 import * # Get all the scenarios already created all_scenarios = tp.get_scenarios() # Delete the scenarios that don't have a name attribute # All the scenarios of the previous steps do not have an associated name so they will be deleted, # this will not be the case for those created by this step ...
from step_07 import * # Initial variables ## Initial variables for the scenario day = dt.datetime(2021, 7, 26) n_predictions = 40 max_capacity = 200 page_scenario_manager = page + """ # Change your scenario **Prediction date**\n\n <|{day}|date|not with_time|> **Max capacity**\n\n <|{max_capacity}|nu...
import datetime as dt import pandas as pd from taipy import Config, Scope from step_01 import path_to_csv # Datanodes (3.1) ## Input Data Nodes initial_dataset_cfg = Config.configure_data_node(id="initial_dataset", storage_type="csv", ...
from step_05 import * from step_06 import scenario_cfg from taipy import Config # Set the list of pipelines names # It will be used in a selector of pipelines pipeline_selector = ["baseline", "ml"] selected_pipeline = pipeline_selector[0] scenario_page = page + """ Select the pipeline <|{selected_pipelin...
# For the sake of clarity, we have used an AutoRegressive model rather than a pure ML model such as: # Random Forest, Linear Regression, LSTM, etc from statsmodels.tsa.ar_model import AutoReg from taipy import Config from step_04 import * from step_03 import cleaned_dataset_cfg, n_predictions_cfg, day_cfg, ...
from step_01 import dataset, n_week, Gui # Select the week based on the slider value dataset_week = dataset[dataset["Date"].dt.isocalendar().week == n_week] page = """ # Getting started with Taipy Select week: *<|{n_week}|>* <|{n_week}|slider|min=1|max=52|> <|{dataset_week}|chart|type=bar|x=Date|y=Valu...
from step_11 import * from sklearn.metrics import mean_absolute_error, mean_squared_error # Initial dataset for comparison comparison_scenario = pd.DataFrame({"Scenario Name": [], "RMSE baseline": [], "MAE baseline": [], "RMSE ML": [], "MA...
import numpy as np import pandas as pd from step_04 import tp, baseline_pipeline_cfg, dt from step_02 import * # Initialize the "predictions" dataset predictions_dataset = pd.DataFrame( {"Date": [dt.datetime(2021, 6, 1)], "Historical values": [np.NaN], "Predicted values": [np.NaN]}) # Add a button and ...
from taipy import Gui import pandas as pd def get_data(path_to_csv: str): # pandas.read_csv() returns a pd.DataFrame dataset = pd.read_csv(path_to_csv) dataset["Date"] = pd.to_datetime(dataset["Date"]) return dataset # Read the dataframe path_to_csv = "dataset.csv" dataset = get_data(pa...
from step_10 import * from step_06 import ml_pipeline_cfg from taipy import Config, Frequency from taipy.gui import notify # Create scenarios each week and compare them scenario_daily_cfg = Config.configure_scenario(id="scenario", pipeline_configs=[baseline_pipel...
from taipy import Gui # A dark mode is available in Taipy # However, we will use the light mode for the Getting Started Gui(page="# Getting started with *Taipy*").run(dark_mode=False)
from step_09 import * # Our first page is the original page # (with the slider and the chart that displays a week of the historical data) page_data_visualization = page # Second page: create scenarios and display results page_scenario_manager = """ # Create your scenario <|layout|columns=1 1 1 1| <| **Pr...
import taipy as tp from step_03 import Config, clean_data_task_cfg, predict_baseline_task_cfg, dt # Create the first pipeline configuration baseline_pipeline_cfg = Config.configure_pipeline(id="baseline", task_configs=[clean_data_task_cfg, predict_baseline_task_...
from taipy.gui import Gui from keras.models import load_model from PIL import Image import numpy as np class_names = { 0: 'airplane', 1: 'automobile', 2: 'bird', 3: 'cat', 4: 'deer', 5: 'dog', 6: 'frog', 7: 'horse', 8: 'ship', 9: 'truck', } model = load_model(...
import pandas as pd from sklearn.model_selection import train_test_split from sklearn.ensemble import RandomForestRegressor from sklearn.compose import ColumnTransformer from sklearn.pipeline import Pipeline from sklearn.preprocessing import OneHotEncoder from sklearn.metrics import mean_squared_error import num...
import taipy as tp from taipy.core.config import Config Config.load('my_config.toml') scenario_cfg = Config.scenarios['scenario'] if __name__ == '__main__': tp.Core().run() scenario_1 = tp.create_scenario(scenario_cfg) print("submitting") scenario_1.submit() print("submit shit ayy...
from taipy.gui import Html html_page = Html(""" <head> <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBIeklfsRu1yz97lY2gJzWHJcmrd7lx2zU&libraries=places"></script> <script type="text/javascript"> function initialize() { geocoder = new google.maps.G...
from geopy.geocoders import Nominatim import folium user_agent = "geoapiExercises/1.0 AIzaSyBIeklfsRu1yz97lY2gJzWHJcmrd7lx2zU" # Initialize the geocoder with the user agent geolocator = Nominatim(user_agent=user_agent, timeout=10) # List of locations to geocode locations = ["Denver, CO, United States", "New Y...
from taipy.gui import Gui, notify import pandas as pd import yfinance as yf from taipy.config import Config import taipy as tp import datetime as dt from taipy import Core from show_hospitals_map import html_page from flask import Flask, request, session, jsonify, redirect, render_template from flask_restful ...
from taipy import Config, Scope import pandas as pd from prophet import Prophet from functions import * # Input Data Nodes initial_dataset_cfg = Config.configure_data_node(id="initial_dataset", storage_type="csv", ...
from taipy import Config from functions import build_message name_data_node_cfg = Config.configure_data_node(id="name") message_data_node_cfg = Config.configure_data_node(id="message") build_msg_task_cfg = Config.configure_task("build_msg", build_message, name_data_node_cfg, message_data_node_cfg) scenario...
from functools import wraps import jwt from flask import request, abort from flask import current_app def token_required(f): @wraps(f) def decorated(*args, **kwargs): token = None if "Authorization" in request.headers: token = request.headers["Authorization"].split(" ")[1]...
from flask import Flask, request, session, jsonify from flask_restful import Api, Resource app = Flask(__name__) app.secret_key = "your_secret_key" # Set a secret key for session management api = Api(app) # Dummy user data for demonstration users = { 'maneesh': {'password': 'securepassword'} } # Log...