Skip to content

Commit

Permalink
Merge branch 'develop' into feature/#1044-chat
Browse files Browse the repository at this point in the history
  • Loading branch information
FredLL-Avaiga committed Apr 22, 2024
2 parents 9a3cfd3 + d036c6a commit e58c6c4
Show file tree
Hide file tree
Showing 64 changed files with 749 additions and 269 deletions.
3 changes: 2 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ apispec = {extras = ["yaml"], version = "==6.3"}
apispec-webframeworks = "==0.5.2"
"backports.zoneinfo" = {version="==0.2.1", markers="python_version < '3.9'", extras=["tzdata"]}
cookiecutter = "==2.1.1"
deepdiff = "==6.2.2"
deepdiff = "==6.7.1"
flask = "==3.0.0"
flask-cors = "==4.0.0"
flask-socketio = "==5.3.6"
Expand Down Expand Up @@ -36,6 +36,7 @@ tzlocal = "==3.0"
boto3 = "==1.29.1"
watchdog = "==4.0.0"
charset-normalizer = "==3.3.2"
numpy = "<2.0.0"

[dev-packages]
freezegun = "*"
Expand Down
20 changes: 16 additions & 4 deletions frontend/taipy-gui/base/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@ import { sendWsMessage, TAIPY_CLIENT_ID } from "../../src/context/wsUtils";
import { uploadFile } from "../../src/workers/fileupload";

import { Socket, io } from "socket.io-client";
import { DataManager } from "./dataManager";
import { DataManager, ModuleData } from "./dataManager";
import { initSocket } from "./utils";

export type OnInitHandler = (appManager: TaipyApp) => void;
export type OnChangeHandler = (appManager: TaipyApp, encodedName: string, value: unknown) => void;
export type OnNotifyHandler = (appManager: TaipyApp, type: string, message: string) => void;
export type onReloadHandler = (appManager: TaipyApp, removedChanges: ModuleData) => void;

export class TaipyApp {
socket: Socket;
_onInit: OnInitHandler | undefined;
_onChange: OnChangeHandler | undefined;
_onNotify: OnNotifyHandler | undefined;
_onReload: onReloadHandler | undefined;
variableData: DataManager | undefined;
functionData: DataManager | undefined;
appId: string;
Expand Down Expand Up @@ -46,7 +48,7 @@ export class TaipyApp {
return this._onInit;
}
set onInit(handler: OnInitHandler | undefined) {
if (handler !== undefined && handler?.length !== 1) {
if (handler !== undefined && handler.length !== 1) {
throw new Error("onInit() requires one parameter");
}
this._onInit = handler;
Expand All @@ -56,7 +58,7 @@ export class TaipyApp {
return this._onChange;
}
set onChange(handler: OnChangeHandler | undefined) {
if (handler !== undefined && handler?.length !== 3) {
if (handler !== undefined && handler.length !== 3) {
throw new Error("onChange() requires three parameters");
}
this._onChange = handler;
Expand All @@ -66,12 +68,22 @@ export class TaipyApp {
return this._onNotify;
}
set onNotify(handler: OnNotifyHandler | undefined) {
if (handler !== undefined && handler?.length !== 3) {
if (handler !== undefined && handler.length !== 3) {
throw new Error("onNotify() requires three parameters");
}
this._onNotify = handler;
}

get onReload() {
return this._onReload;
}
set onReload(handler: onReloadHandler | undefined) {
if (handler !== undefined && handler?.length !== 2) {
throw new Error("_onReload() requires two parameters");
}
this._onReload = handler;
}

// Utility methods
init() {
this.clientId = "";
Expand Down
1 change: 1 addition & 0 deletions frontend/taipy-gui/base/src/dataManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export class DataManager {
this._data[vData["encoded_name"]] = vData.value;
}
}
return changes;
}

getEncodedName(varName: string, module: string): string | undefined {
Expand Down
9 changes: 7 additions & 2 deletions frontend/taipy-gui/base/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import merge from "lodash/merge";
import { Socket } from "socket.io-client";
import { IdMessage, storeClientId } from "../../src/context/utils";
import { WsMessage, sendWsMessage } from "../../src/context/wsUtils";
Expand Down Expand Up @@ -74,8 +75,12 @@ const processWsMessage = (message: WsMessage, appManager: TaipyApp) => {
const variableData = payload.variable;
const functionData = payload.function;
if (appManager.variableData && appManager.functionData) {
appManager.variableData.init(variableData);
appManager.functionData.init(functionData);
const varChanges = appManager.variableData.init(variableData);
const functionChanges = appManager.functionData.init(functionData);
const changes = merge(varChanges, functionChanges);
if (varChanges || functionChanges) {
appManager.onReload && appManager.onReload(appManager, changes);
}
} else {
appManager.variableData = new DataManager(variableData);
appManager.functionData = new DataManager(functionData);
Expand Down
12 changes: 6 additions & 6 deletions taipy/config/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
class _Config:
DEFAULT_KEY = "default"

def __init__(self):
def __init__(self) -> None:
self._sections: Dict[str, Dict[str, Section]] = {}
self._unique_sections: Dict[str, UniqueSection] = {}
self._global_config: GlobalAppConfig = GlobalAppConfig()

def _clean(self):
def _clean(self) -> None:
self._global_config._clean()
for unique_section in self._unique_sections.values():
unique_section._clean()
Expand All @@ -39,7 +39,7 @@ def _default_config(cls):
config._global_config = GlobalAppConfig.default_config()
return config

def _update(self, other_config):
def _update(self, other_config) -> None:
self._global_config._update(other_config._global_config._to_dict())
if other_config._unique_sections:
for section_name, other_section in other_config._unique_sections.items():
Expand All @@ -55,12 +55,12 @@ def _update(self, other_config):
self._sections[section_name] = {}
self.__add_sections(self._sections[section_name], other_non_unique_sections)

def __add_sections(self, entity_config, other_entity_configs):
def __add_sections(self, entity_config, other_entity_configs) -> None:
for cfg_id, sub_config in other_entity_configs.items():
entity_config[cfg_id] = copy(sub_config)
self.__point_nested_section_to_self(sub_config)

def __update_sections(self, entity_config, other_entity_configs):
def __update_sections(self, entity_config, other_entity_configs) -> None:
if self.DEFAULT_KEY in other_entity_configs:
if self.DEFAULT_KEY in entity_config:
entity_config[self.DEFAULT_KEY]._update(other_entity_configs[self.DEFAULT_KEY]._to_dict())
Expand All @@ -73,7 +73,7 @@ def __update_sections(self, entity_config, other_entity_configs):
entity_config[cfg_id]._update(sub_config._to_dict(), entity_config.get(self.DEFAULT_KEY))
self.__point_nested_section_to_self(sub_config)

def __point_nested_section_to_self(self, section):
def __point_nested_section_to_self(self, section) -> None:
"""Loop through attributes of a Section to find if any attribute has a list of Section as value.
If there is, update each nested Section by the corresponding instance in self.
Expand Down
4 changes: 2 additions & 2 deletions taipy/config/_config_comparator/_config_comparator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@


class _ConfigComparator:
def __init__(self):
def __init__(self) -> None:
self._unconflicted_sections: Set[str] = set()
self.__logger = _TaipyLogger._get_logger()

def _add_unconflicted_section(self, section_name: Union[str, Set[str]]):
def _add_unconflicted_section(self, section_name: Union[str, Set[str]]) -> None:
if isinstance(section_name, str):
section_name = {section_name}

Expand Down
8 changes: 4 additions & 4 deletions taipy/config/checker/issue_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class IssueCollector:
_WARNING_LEVEL = "WARNING"
_INFO_LEVEL = "INFO"

def __init__(self):
def __init__(self) -> None:
self._errors: List[Issue] = []
self._warnings: List[Issue] = []
self._infos: List[Issue] = []
Expand All @@ -50,11 +50,11 @@ def warnings(self) -> List[Issue]:
def errors(self) -> List[Issue]:
return self._errors

def _add_error(self, field: str, value: Any, message: str, checker_name: str):
def _add_error(self, field: str, value: Any, message: str, checker_name: str) -> None:
self._errors.append(Issue(self._ERROR_LEVEL, field, value, message, checker_name))

def _add_warning(self, field: str, value: Any, message: str, checker_name: str):
def _add_warning(self, field: str, value: Any, message: str, checker_name: str) -> None:
self._warnings.append(Issue(self._WARNING_LEVEL, field, value, message, checker_name))

def _add_info(self, field: str, value: Any, message: str, checker_name: str):
def _add_info(self, field: str, value: Any, message: str, checker_name: str) -> None:
self._infos.append(Issue(self._INFO_LEVEL, field, value, message, checker_name))
8 changes: 4 additions & 4 deletions taipy/config/config.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -787,10 +787,10 @@ class Config:
@staticmethod
def configure_task(
id: str,
function,
function: Optional[Callable],
input: Optional[Union[DataNodeConfig, List[DataNodeConfig]]] = None,
output: Optional[Union[DataNodeConfig, List[DataNodeConfig]]] = None,
skippable: Optional[bool] = False,
skippable: bool = False,
**properties,
) -> "TaskConfig":
"""Configure a new task configuration.
Expand All @@ -815,10 +815,10 @@ class Config:

@staticmethod
def set_default_task_configuration(
function,
function: Optional[Callable],
input: Optional[Union[DataNodeConfig, List[DataNodeConfig]]] = None,
output: Optional[Union[DataNodeConfig, List[DataNodeConfig]]] = None,
skippable: Optional[bool] = False,
skippable: bool = False,
**properties,
) -> "TaskConfig":
"""Set the default values for task configurations.
Expand Down
2 changes: 1 addition & 1 deletion taipy/config/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
if vext := version.get("ext"):
version_string = f"{version_string}.{vext}"

requirements = ["toml>=0.10,<0.11", "deepdiff>=6.2,<6.3"]
requirements = ["toml>=0.10,<0.11", "deepdiff>=6.7,<6.8"]

test_requirements = ["pytest>=3.8"]

Expand Down
2 changes: 1 addition & 1 deletion taipy/core/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Core:
_orchestrator: Optional[_Orchestrator] = None
_dispatcher: Optional[_JobDispatcher] = None

def __init__(self):
def __init__(self) -> None:
"""
Initialize a Core service.
"""
Expand Down
21 changes: 13 additions & 8 deletions taipy/core/_entity/_entity_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,21 @@

from __future__ import annotations

from typing import TYPE_CHECKING, Set

if TYPE_CHECKING:
from taipy import CycleId, DataNodeId, JobId, ScenarioId, SequenceId, SubmissionId, TaskId


class _EntityIds:
def __init__(self):
self.data_node_ids = set()
self.task_ids = set()
self.scenario_ids = set()
self.sequence_ids = set()
self.job_ids = set()
self.cycle_ids = set()
self.submission_ids = set()
def __init__(self) -> None:
self.data_node_ids: Set[DataNodeId] = set()
self.task_ids: Set[TaskId] = set()
self.scenario_ids: Set[ScenarioId] = set()
self.sequence_ids: Set[SequenceId] = set()
self.job_ids: Set[JobId] = set()
self.cycle_ids: Set[CycleId] = set()
self.submission_ids: Set[SubmissionId] = set()

def __add__(self, other: _EntityIds):
self.data_node_ids.update(other.data_node_ids)
Expand Down
2 changes: 1 addition & 1 deletion taipy/core/_entity/_reload.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __exit__(self, exc_type, exc_value, exc_traceback):
self._no_reload_context = False


def _self_reload(manager):
def _self_reload(manager: str):
def __reload(fct):
@functools.wraps(fct)
def _do_reload(self, *args, **kwargs):
Expand Down
5 changes: 1 addition & 4 deletions taipy/core/_manager/_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,7 @@ def _delete_entities_of_multiple_types(cls, _entity_ids: _EntityIds):
_SubmissionManagerFactory._build_manager()._delete_many(_entity_ids.submission_ids)

@classmethod
def _export(cls, id: str, folder_path: Union[str, pathlib.Path]):
"""
Export an entity.
"""
def _export(cls, id: str, folder_path: Union[str, pathlib.Path], **kwargs):
return cls._repository._export(id, folder_path)

@classmethod
Expand Down
8 changes: 1 addition & 7 deletions taipy/core/_repository/_filesystem_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from ..common._utils import _retry_repository_operation
from ..common.typing import Converter, Entity, Json, ModelType
from ..exceptions import FileCannotBeRead, InvalidExportPath, ModelNotFound
from ..exceptions import FileCannotBeRead, ModelNotFound
from ._abstract_repository import _AbstractRepository
from ._decoder import _Decoder
from ._encoder import _Encoder
Expand Down Expand Up @@ -123,17 +123,11 @@ def _export(self, entity_id: str, folder_path: Union[str, pathlib.Path]):
else:
folder = folder_path

if folder.resolve() == self._storage_folder.resolve():
raise InvalidExportPath("The export folder must not be the storage folder.")

export_dir = folder / self._dir_name
if not export_dir.exists():
export_dir.mkdir(parents=True)

export_path = export_dir / f"{entity_id}.json"
# Delete if exists.
if export_path.exists():
export_path.unlink()

shutil.copy2(self.__get_path(entity_id), export_path)

Expand Down
2 changes: 1 addition & 1 deletion taipy/core/_version/_version_fs_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@


class _VersionFSRepository(_FileSystemRepository, _VersionRepositoryInterface):
def __init__(self):
def __init__(self) -> None:
super().__init__(model_type=_VersionModel, converter=_VersionConverter, dir_name="version")

@property
Expand Down
2 changes: 1 addition & 1 deletion taipy/core/_version/_version_sql_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


class _VersionSQLRepository(_SQLRepository, _VersionRepositoryInterface):
def __init__(self):
def __init__(self) -> None:
super().__init__(model_type=_VersionModel, converter=_VersionConverter)

def _set_latest_version(self, version_number):
Expand Down

0 comments on commit e58c6c4

Please sign in to comment.