text
stringlengths
0
105k
import datetime as dt import os import pathlib from taipy.config import Config, Frequency, Scope from .complex_application_algos import ( average, create_metrics, create_results, create_train_test_data, divide, forecast, forecast_baseline, mult, mult_by_2, prepr...
# # 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...
import random import time from datetime import datetime from typing import Dict, List import pandas as pd def failing_job(historical_daily_temperature: pd.DataFrame): time.sleep(2) print("----- Prepared to raise exception -----") raise Exception def predict(model, dates: List[datetime]) -...
from datetime import datetime from taipy import Frequency, Scope from taipy.config.config import Config from .algorithms import failing_job, predict historical_data_set = Config.configure_csv_data_node( id="historical_data_set", path="tests//shared_test_cases/arima/daily-min-temperatures.csv", scope=Scop...
from .algorithms import * from .config import *
import random import time from datetime import datetime from typing import Dict, List import pandas as pd from statsmodels.tsa.arima.model import ARIMA def train(historical_daily_temperature: pd.DataFrame): print("----- Started training -----") time.sleep(2) for _ in range(2): print(...
from datetime import datetime from taipy.config import Frequency, Scope from taipy.config.config import Config from .algorithms import predict, train def build_arima_config(): CSV_INPUT_PATH = "tests/shared_test_cases/arima/daily-min-temperatures.csv" XLSX_OUTPUT_PATH = "tests/shared_test_cases/ar...
from .algorithms import * from .config import *
import pandas as pd def algorithm(df: pd.DataFrame) -> pd.DataFrame: return df
import dataclasses from taipy.config.common.frequency import Frequency from taipy.config.config import Config from .algorithms import algorithm CSV_INPUT_PATH = "tests/shared_test_cases/csv_files/input_1000.csv" CSV_OUTPUT_PATH = "tests/shared_test_cases/csv_files/output_1000.csv" ROW_COUNT = 1000 @dat...
from .algorithms import * from .config import *
import pandas as pd def algorithm(df: pd.DataFrame) -> pd.DataFrame: return df
import dataclasses from taipy.config.common.frequency import Frequency from taipy.config.config import Config from .algorithms import algorithm EXCEL_INPUT_PATH = "tests/shared_test_cases/multi_excel_sheets/input_1000_multi_sheets.xlsx" EXCEL_OUTPUT_PATH = "tests/shared_test_cases/multi_excel_sheets/output_1...
from .algorithms import * from .config import *
import pandas as pd def algorithm(df: pd.DataFrame) -> pd.DataFrame: return df
import dataclasses from taipy.config.common.frequency import Frequency from taipy.config.config import Config from .algorithms import algorithm EXCEL_SINGLE_SHEET_INPUT_PATH = "tests/shared_test_cases/single_excel_sheet/input_1000.xlsx" EXCEL_SINGLE_SHEET_OUTPUT_PATH = "tests/shared_test_cases/single_excel_s...
from .algorithms import * from .config import *
def algorithm(data): return data
import dataclasses from taipy.config.common.frequency import Frequency from taipy.config.config import Config from .algorithms import algorithm PICKLE_DICT_INPUT_PATH = "tests/shared_test_cases/pickle_files/input_dict_1000.p" PICKLE_DICT_OUTPUT_PATH = "tests/shared_test_cases/pickle_files/output_dict_1000.p"...
from .algorithms import * from .config import * from .utils import *
import pickle import random from tests.shared_test_cases.pickle_files import Row def gen_list_of_dict_input_pickle(path, n): data = [] for i in range(n): row = {"id": i + 1, "age": random.randint(10, 99), "rating": round(random.uniform(0, 10), 2)} data.append(row) pickle.dump(d...
def algorithm(data): return data
from taipy.config.common.frequency import Frequency from taipy.config.config import Config from .algorithms import algorithm from .utils import RowDecoder, RowEncoder JSON_DICT_INPUT_PATH = "tests/shared_test_cases/json_files/input_dict_1000.json" JSON_DICT_OUTPUT_PATH = "tests/shared_test_cases/json_files/out...
from .algorithms import * from .config import * from .utils import *
import json import random import time from dataclasses import dataclass @dataclass class Row: id: int age: int rating: float class RowEncoder(json.JSONEncoder): def default(self, obj): if isinstance(obj, Row): return {"id": obj.id, "age": obj.age, "rating": obj.ra...
from unittest.mock import patch import taipy.core.taipy as tp from taipy import Config from taipy.core import Core from taipy.core.config import JobConfig from taipy.core.job.status import Status from tests.utils import assert_true_after_time def mult_by_2(a): return a def build_skipped_jobs_co...
# # 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...
# # 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...
from unittest.mock import patch import taipy.core.taipy as tp from taipy import Config from taipy.core import Core from taipy.core.config import JobConfig from tests.test_complex.utils.config_builders import build_churn_classification_config from tests.utils import assert_true_after_time class TestChurnC...
import datetime as dt from time import sleep import numpy as np import pandas as pd from sklearn.ensemble import RandomForestClassifier from sklearn.linear_model import LogisticRegression from sklearn.metrics import roc_auc_score from sklearn.model_selection import train_test_split def sum(a, b): a =...
import os import pathlib from taipy.config import Config, Frequency, Scope from .algos import * def build_complex_config(): ( csv_path_inp, excel_path_inp, csv_path_sum, excel_path_sum, excel_path_out, csv_path_out, ) = build_complex_required_f...
# # 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...
from taipy import Config, Core, Gui if __name__ == "__main__": core = Core() core.run() gui = Gui() gui._config._handle_argparse() print(f"Config.core.version_number: {Config.core.version_number}") print(f"Config.core.mode: {Config.core.mode}") print(f"Config.core.force: {Confi...
import argparse from taipy import Config, Core, Gui if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--mode", dest="mode", type=str, default="training") parser.add_argument("--force", type=str, default="no") parser.add_argument("--host", dest="host", type=str,...
import taipy as tp from taipy.gui import Gui, notify from taipy.config import Config import dask_ml.datasets import dask_ml.cluster import pandas as pd n_clusters = 3 data = dask_ml.datasets.make_blobs( n_samples=1000000, chunks=1000000, random_state=0, centers=n_clusters ) X, _ = data km = dask_ml...
import dask import dask_ml.datasets def generate_data(centers: int): """ Generates synthetic data for clustering. Args: - centers (int): number of clusters to generate Returns: - X (dask.array): array of shape (n_samples, n_features) """ X, _ = dask_ml.datasets....
#!/usr/bin/env python """The setup script.""" import json import os from pathlib import Path from setuptools import find_namespace_packages, find_packages, setup from setuptools.command.build_py import build_py readme = Path("README.md").read_text() with open(f"src{os.sep}taipy{os.sep}gui{os.sep}versi...
# ############################################################ # Generate Python interface definition files # ############################################################ import json import os import typing as t # ############################################################ # Generate gui pyi file (gui/gui.pyi...
import pytest def pytest_addoption(parser): parser.addoption("--e2e-base-url", action="store", default="/", help="base url for e2e testing") parser.addoption("--e2e-port", action="store", default="5000", help="port for e2e testing") @pytest.fixture(scope="session") def e2e_base_url(request): r...
"""Unit test package for taipy."""
# # 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...
import os import sys from importlib.util import find_spec from pathlib import Path import pandas as pd # type: ignore import pytest from flask import Flask, g def pytest_configure(config): if (find_spec("src") and find_spec("src.taipy")) and (not find_spec("taipy") or not find_spec("taipy.gui")): ...
# # 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...
import inspect import json import logging import socket import time import typing as t import warnings from types import FrameType from taipy.gui import Gui, Html, Markdown from taipy.gui._renderers.builder import _Builder from taipy.gui._warnings import TaipyGuiWarning from taipy.gui.utils._variable_direc...
import inspect from taipy.gui import Gui, Html def test_simple_html(gui: Gui, helpers): # html_string = "<html><head></head><body><h1>test</h1><taipy:field value=\"test\"/></body></html>" html_string = "<html><head></head><body><h1>test</h1></body></html>" gui._set_frame(inspect.currentframe()) ...
import pytest from taipy.gui import Gui def test_invalid_control_name(gui: Gui, helpers): md_string = "<|invalid|invalid|>" expected_list = ["INVALID SYNTAX - Control is 'invalid'"] helpers.test_control_md(gui, md_string, expected_list) def test_value_to_negated_property(gui: Gui, helpers): ...
import pytest from taipy.gui.utils._bindings import _Bindings def test_exception_binding_twice(gui, test_client): bind = _Bindings(gui) bind._new_scopes() bind._bind("x", 10) with pytest.raises(ValueError): bind._bind("x", 10) def test_exception_binding_invalid_name(gui): ...
from email import message import pytest from taipy.gui._page import _Page def test_exception_page(gui): page = _Page() page._route = "page1" with pytest.raises(RuntimeError, match="Can't render page page1: no renderer found"): page.render(gui)
# # 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...
# # 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...
import os import tempfile from unittest.mock import patch import pytest from taipy.config import Config from taipy.config._config import _Config from taipy.config._serializer._toml_serializer import _TomlSerializer from taipy.config.checker._checker import _Checker from taipy.config.checker.issue_collector ...
import inspect import warnings import pytest from taipy.gui import Gui def test_no_ignore_file(gui: Gui): with warnings.catch_warnings(record=True): gui._set_frame(inspect.currentframe()) gui.run(run_server=False) client = gui._server.test_client() response = client....
import inspect import warnings import pytest from taipy.gui import Gui def test_ignore_file_found(gui: Gui): with warnings.catch_warnings(record=True): gui._set_frame(inspect.currentframe()) gui.run(run_server=False) client = gui._server.test_client() response = clie...
import inspect import time from urllib.request import urlopen from taipy.gui import Gui # this hangs in github def test_run_thread(gui: Gui, helpers): gui._set_frame(inspect.currentframe()) gui.add_page("page1", "# first page") gui.run(run_in_thread=True, run_browser=False) while not help...
import pytest from taipy.gui import Gui def test_add_shared_variables(gui: Gui): Gui.add_shared_variable("var1", "var2") assert isinstance(gui._Gui__shared_variables, list) assert len(gui._Gui__shared_variables) == 2 Gui.add_shared_variables("var1", "var2") assert len(gui._Gui__shared...
import json from taipy.gui.gui import Gui def test_multiple_instance(): gui1 = Gui("<|gui1|>") gui2 = Gui("<|gui2|>") gui1.run(run_server=False) gui2.run(run_server=False) client1 = gui1._server.test_client() client2 = gui2._server.test_client() assert_multiple_instance(client...
from taipy.gui.utils._variable_directory import _MODULE_NAME_MAP, _variable_decode, _variable_encode def test_variable_encode_decode(): assert _variable_encode("x", "module") == "x_TPMDL_0" assert _MODULE_NAME_MAP[0] == "module" assert _variable_decode("x_TPMDL_0") == ("x", "module") assert _va...
import inspect import warnings from taipy.gui import Gui, Markdown, State, navigate def test_navigate(gui: Gui, helpers): def navigate_to(state: State): navigate(state, "test") with warnings.catch_warnings(record=True): gui._set_frame(inspect.currentframe()) gui.add_page(...
import inspect import pandas as pd # type: ignore from taipy.gui import Gui def test_expression_text_control_str(gui: Gui, test_client, helpers): gui._bind_var_val("x", "Hello World!") md_string = "<|{x}|>" expected_list = ["<Field", 'dataType="str"', 'defaultValue="Hello World!"', "value={tp...
import numpy as np import pandas as pd from taipy.gui.data.decimator.lttb import LTTB from taipy.gui.data.decimator.minmax import MinMaxDecimator from taipy.gui.data.decimator.rdp import RDP from taipy.gui.data.decimator.scatter_decimator import ScatterDecimator from taipy.gui.data.utils import _df_data_filter ...
# # 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...
import inspect import pytest from taipy.gui import Gui, Markdown from .state_asset.page1 import get_a, md_page1, set_a def test_state(gui: Gui): a = 10 # noqa: F841 gui._set_frame(inspect.currentframe()) gui.add_page("page1", md_page1) gui.run(run_server=False, single_client=True) ...
import pytest from taipy.gui import Gui from taipy.gui.utils._locals_context import _LocalsContext def test_locals_context(gui: Gui): lc = _LocalsContext() gui.run(run_server=False) with gui.get_flask_app().app_context(): with pytest.raises(KeyError): lc.get_default() ...
import inspect from taipy.gui.utils.get_module_name import _get_module_name_from_frame, _get_module_name_from_imported_var x = 10 def test_get_module_name(): assert "tests.taipy.gui.gui_specific.test_get_module_name" == _get_module_name_from_frame(inspect.currentframe()) def test_get_module_name_im...
import inspect import os from pathlib import Path from taipy.gui import Gui def test_folder_pages_binding(gui: Gui): folder_path = f"{Path(Path(__file__).parent.resolve())}{os.path.sep}sample_assets" gui._set_frame(inspect.currentframe()) gui.add_pages(folder_path) gui.run(run_server=False...
import inspect import json import warnings from taipy.gui import Gui def test_render_route(gui: Gui): gui._set_frame(inspect.currentframe()) gui.add_page("page1", "# first page") gui.add_page("page2", "# second page") gui.run(run_server=False) with warnings.catch_warnings(record=True)...
import json import pandas as pd import pytest from taipy.gui import Gui from taipy.gui.utils import _TaipyContent def test__get_real_var_name(gui: Gui): res = gui._get_real_var_name("") assert isinstance(res, tuple) assert res[0] == "" assert res[1] == "" gui.run(run_server=False...
import json import warnings from types import SimpleNamespace from taipy.gui import Gui, Markdown def test_partial(gui: Gui): with warnings.catch_warnings(record=True): gui.add_partial(Markdown("#This is a partial")) gui.run(run_server=False) client = gui._server.test_client() ...
from taipy.gui import Gui, Markdown def test_variable_binding(helpers): """ Tests the binding of a few variables and a function """ def another_function(gui): pass x = 10 y = 20 z = "button label" gui = Gui() gui.add_page("test", Markdown("<|{x}|> | <|{y}|>...
from taipy.gui import Markdown a = 20 def get_a(state): return state.a def set_a(state, val): state.a = val md_page1 = Markdown( """ <|{a}|> """ )
import inspect import pytest from taipy.gui import Gui from taipy.gui.extension import Element, ElementLibrary class MyLibrary(ElementLibrary): def get_name(self) -> str: return "taipy_extension_example" def get_elements(self): return dict() def test_extension_no_config(gu...
import inspect import pytest from flask import g from taipy.gui import Gui def test_get_status(gui: Gui): gui.run(run_server=False) flask_client = gui._server.test_client() ret = flask_client.get("/taipy.status.json") assert ret.status_code == 200, f"status_code => {ret.status_code} != 2...
import inspect import io import pathlib import tempfile import pytest from taipy.gui import Gui from taipy.gui.data.data_scope import _DataScopes from taipy.gui.utils import _get_non_existent_file_path def test_file_upload_no_varname(gui: Gui, helpers): gui.run(run_server=False) flask_client =...
import pathlib import pytest from taipy.gui import Gui def test_image_path_not_found(gui: Gui, helpers): gui.run(run_server=False) flask_client = gui._server.test_client() # Get the jsx once so that the page will be evaluated -> variable will be registered sid = helpers.create_scope_and_g...
import inspect import pytest from taipy.gui import Gui def test_user_content_without_callback(gui: Gui, helpers): gui.run(run_server=False, single_client=True) flask_client = gui._server.test_client() with pytest.warns(UserWarning): ret = flask_client.get(gui._get_user_content_url("pa...
import inspect from taipy.gui import Gui, Markdown from taipy.gui.data.data_scope import _DataScopes def test_sending_messages_in_group(gui: Gui, helpers): name = "World!" # noqa: F841 btn_id = "button1" # noqa: F841 # set gui frame gui._set_frame(inspect.currentframe()) gui.add_...
import inspect import logging import pathlib import pytest from taipy.gui import Gui, download def test_download_file(gui: Gui, helpers): def do_something(state, id): download(state, (pathlib.Path(__file__).parent.parent.parent / "resources" / "taipan.jpg")) # Bind a page so that the f...
import inspect from taipy.gui import Gui, Markdown def ws_u_assert_template(gui: Gui, helpers, value_before_update, value_after_update, payload): # Bind test variable var = value_before_update # noqa: F841 # set gui frame gui._set_frame(inspect.currentframe()) # Bind a page so that...
import inspect from taipy.gui import Gui, Markdown def test_du_table_data_fetched(gui: Gui, helpers, csvdata): # Bind test variables csvdata = csvdata # set gui frame gui._set_frame(inspect.currentframe()) Gui._set_timezone("UTC") # Bind a page so that the variable will be eval...
import inspect import pytest from taipy.gui import Gui, Markdown def test_default_on_change(gui: Gui, helpers): st = {"d": False} def on_change(state, var, value): st["d"] = True x = 10 # noqa: F841 # set gui frame gui._set_frame(inspect.currentframe()) gui.add...
import inspect import pytest from taipy.gui import Gui, Markdown def test_ru_selector(gui: Gui, helpers, csvdata): # Bind test variables selected_val = ["value1", "value2"] # noqa: F841 # set gui frame gui._set_frame(inspect.currentframe()) # Bind a page so that the variable wil...
# # 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...
import inspect import pytest from taipy.gui import Gui, Markdown def test_broadcast(gui: Gui, helpers): # Bind test variables selected_val = ["value1", "value2"] # noqa: F841 # set gui frame gui._set_frame(inspect.currentframe()) # Bind a page so that the variable will be evalua...
import inspect import time from taipy.gui import Gui, Markdown def test_a_button_pressed(gui: Gui, helpers): def do_something(state, id): state.x = state.x + 10 state.text = "a random text" x = 10 # noqa: F841 text = "hi" # noqa: F841 # set gui frame gui._set_fram...
import inspect import warnings from flask import g from taipy.gui import Gui from taipy.gui.utils.types import _TaipyNumber def test_unbind_variable_in_expression(gui: Gui, helpers): gui.run(run_server=False, single_client=True) with warnings.catch_warnings(record=True) as records: with ...
import inspect import pytest from taipy.gui.gui import Gui from taipy.gui.utils import _MapDict def test_map_dict(): d = {"a": 1, "b": 2, "c": 3} md = _MapDict(d) md_copy = _MapDict(d).copy() assert len(md) == 3 assert md.__getitem__("a") == d["a"] md.__setitem__("a", 4) a...
import pathlib import tempfile from taipy.gui import Gui from taipy.gui.utils import _get_non_existent_file_path def test_empty_file_name(gui: Gui, helpers): assert _get_non_existent_file_path(pathlib.Path(tempfile.gettempdir()), "").name def test_non_existent_file(gui: Gui, helpers): assert no...
import warnings import pytest from taipy.gui.utils.date import _string_to_date from taipy.gui.utils.types import _TaipyBase, _TaipyBool, _TaipyDate, _TaipyNumber def test_taipy_base(): tb = _TaipyBase("value", "hash") assert tb.get() == "value" assert tb.get_name() == "hash" tb.set("a ...
import inspect from time import sleep import pytest from taipy.gui import Gui, State, invoke_long_callback def test_long_callback(gui: Gui): status = None # noqa: F841 def heavy_function(delay=1): sleep(delay) def heavy_function_with_exception(delay=1): sleep(delay) ...
import inspect from flask import g from taipy.gui import Gui, Markdown, get_state_id def test_get_state_id(gui: Gui, helpers): name = "World!" # noqa: F841 btn_id = "button1" # noqa: F841 # set gui frame gui._set_frame(inspect.currentframe()) gui.add_page("test", Markdown("<|He...
import inspect from flask import g from taipy.gui import Gui, Markdown, State, download def test_download(gui: Gui, helpers): name = "World!" # noqa: F841 btn_id = "button1" # noqa: F841 def on_download_action(state: State): pass # set gui frame gui._set_frame(inspect....
import inspect from flask import g from taipy.gui import Gui, Markdown, navigate def test_navigate(gui: Gui, helpers): name = "World!" # noqa: F841 btn_id = "button1" # noqa: F841 # set gui frame gui._set_frame(inspect.currentframe()) gui.add_page("test", Markdown("<|Hello {nam...
import inspect from flask import g from taipy.gui import Gui, Markdown, State, invoke_callback def test_invoke_callback(gui: Gui, helpers): name = "World!" # noqa: F841 btn_id = "button1" # noqa: F841 val = 1 # noqa: F841 def user_callback(state: State): state.val = 10 ...
import inspect from flask import g from taipy.gui import Gui, Markdown, hold_control def test_hold_control(gui: Gui, helpers): name = "World!" # noqa: F841 btn_id = "button1" # noqa: F841 # set gui frame gui._set_frame(inspect.currentframe()) gui.add_page("test", Markdown("<|He...
import inspect from flask import g from taipy.gui import Gui, Markdown, resume_control def test_resume_control(gui: Gui, helpers): name = "World!" # noqa: F841 btn_id = "button1" # noqa: F841 # set gui frame gui._set_frame(inspect.currentframe()) gui.add_page("test", Markdown("...
import inspect from flask import g from taipy.gui import Gui, Markdown, notify def test_notify(gui: Gui, helpers): name = "World!" # noqa: F841 btn_id = "button1" # noqa: F841 # set gui frame gui._set_frame(inspect.currentframe()) gui.add_page("test", Markdown("<|Hello {name}|b...
import contextlib import time from urllib.request import urlopen import pytest from testbook import testbook @pytest.mark.filterwarnings("ignore::RuntimeWarning") @testbook("tests/taipy/gui/notebook/simple_gui.ipynb") def test_notebook_simple_gui(tb, helpers): tb.execute_cell("import") tb.execute...
from taipy.gui import Gui, Markdown
import inspect from importlib import util import pytest if util.find_spec("playwright"): from playwright._impl._page import Page from taipy.gui import Gui @pytest.mark.teste2e def test_redirect(page: "Page", gui: Gui, helpers): page_md = """ <|Redirect Successfully|id=text1|> """ gui._s...
import pytest @pytest.fixture(scope="session") def browser_context_args(browser_context_args, e2e_port, e2e_base_url): return { **browser_context_args, "base_url": f"http://127.0.0.1:{e2e_port}{e2e_base_url}", "timezone_id": "Europe/Paris", } @pytest.fixture(scope="functi...