|
@@ -67,13 +67,13 @@ from taipy.gui.gui import _DoNotUpdate
|
|
from taipy.gui.utils._map_dict import _MapDict
|
|
from taipy.gui.utils._map_dict import _MapDict
|
|
|
|
|
|
from ._adapters import (
|
|
from ._adapters import (
|
|
- CustomScenarioFilter,
|
|
|
|
_EntityType,
|
|
_EntityType,
|
|
_get_entity_property,
|
|
_get_entity_property,
|
|
_GuiCoreDatanodeAdapter,
|
|
_GuiCoreDatanodeAdapter,
|
|
_GuiCoreScenarioProperties,
|
|
_GuiCoreScenarioProperties,
|
|
_invoke_action,
|
|
_invoke_action,
|
|
)
|
|
)
|
|
|
|
+from .filters import CustomScenarioFilter
|
|
|
|
|
|
|
|
|
|
class _GuiCoreContext(CoreEventConsumerBase):
|
|
class _GuiCoreContext(CoreEventConsumerBase):
|
|
@@ -113,20 +113,20 @@ class _GuiCoreContext(CoreEventConsumerBase):
|
|
|
|
|
|
def process_event(self, event: Event):
|
|
def process_event(self, event: Event):
|
|
self.__lazy_start()
|
|
self.__lazy_start()
|
|
- if event.entity_type == EventEntityType.SCENARIO:
|
|
|
|
- with self.gui._get_autorization(system=True):
|
|
|
|
|
|
+ if event.entity_type is EventEntityType.SCENARIO:
|
|
|
|
+ with self.gui._get_authorization(system=True):
|
|
self.scenario_refresh(
|
|
self.scenario_refresh(
|
|
event.entity_id
|
|
event.entity_id
|
|
- if event.operation == EventOperation.DELETION or is_readable(t.cast(ScenarioId, event.entity_id))
|
|
|
|
|
|
+ if event.operation is EventOperation.DELETION or is_readable(t.cast(ScenarioId, event.entity_id))
|
|
else None
|
|
else None
|
|
)
|
|
)
|
|
- elif event.entity_type == EventEntityType.SEQUENCE and event.entity_id:
|
|
|
|
|
|
+ elif event.entity_type is EventEntityType.SEQUENCE and event.entity_id:
|
|
sequence = None
|
|
sequence = None
|
|
try:
|
|
try:
|
|
- with self.gui._get_autorization(system=True):
|
|
|
|
|
|
+ with self.gui._get_authorization(system=True):
|
|
sequence = (
|
|
sequence = (
|
|
core_get(event.entity_id)
|
|
core_get(event.entity_id)
|
|
- if event.operation != EventOperation.DELETION
|
|
|
|
|
|
+ if event.operation is not EventOperation.DELETION
|
|
and is_readable(t.cast(SequenceId, event.entity_id))
|
|
and is_readable(t.cast(SequenceId, event.entity_id))
|
|
else None
|
|
else None
|
|
)
|
|
)
|
|
@@ -134,13 +134,15 @@ class _GuiCoreContext(CoreEventConsumerBase):
|
|
self.broadcast_core_changed({"scenario": list(sequence.parent_ids)}) # type: ignore
|
|
self.broadcast_core_changed({"scenario": list(sequence.parent_ids)}) # type: ignore
|
|
except Exception as e:
|
|
except Exception as e:
|
|
_warn(f"Access to sequence {event.entity_id} failed", e)
|
|
_warn(f"Access to sequence {event.entity_id} failed", e)
|
|
- elif event.entity_type == EventEntityType.JOB:
|
|
|
|
|
|
+ elif event.entity_type is EventEntityType.JOB:
|
|
with self.lock:
|
|
with self.lock:
|
|
self.jobs_list = None
|
|
self.jobs_list = None
|
|
- self.broadcast_core_changed({"jobs": event.entity_id})
|
|
|
|
- elif event.entity_type == EventEntityType.SUBMISSION:
|
|
|
|
|
|
+ # no broadcast because the submission status will do the job
|
|
|
|
+ if event.operation is EventOperation.DELETION:
|
|
|
|
+ self.broadcast_core_changed({"jobs": True})
|
|
|
|
+ elif event.entity_type is EventEntityType.SUBMISSION:
|
|
self.submission_status_callback(event.entity_id, event)
|
|
self.submission_status_callback(event.entity_id, event)
|
|
- elif event.entity_type == EventEntityType.DATA_NODE:
|
|
|
|
|
|
+ elif event.entity_type is EventEntityType.DATA_NODE:
|
|
with self.lock:
|
|
with self.lock:
|
|
self.data_nodes_by_owner = None
|
|
self.data_nodes_by_owner = None
|
|
self.broadcast_core_changed(
|
|
self.broadcast_core_changed(
|
|
@@ -178,9 +180,9 @@ class _GuiCoreContext(CoreEventConsumerBase):
|
|
client_id = submission.properties.get("client_id")
|
|
client_id = submission.properties.get("client_id")
|
|
if client_id:
|
|
if client_id:
|
|
running_tasks = {}
|
|
running_tasks = {}
|
|
- with self.gui._get_autorization(client_id):
|
|
|
|
|
|
+ with self.gui._get_authorization(client_id):
|
|
for job in submission.jobs:
|
|
for job in submission.jobs:
|
|
- job = job if isinstance(job, Job) else core_get(job)
|
|
|
|
|
|
+ job = job if isinstance(job, Job) else t.cast(Job, core_get(job))
|
|
running_tasks[job.task.id] = (
|
|
running_tasks[job.task.id] = (
|
|
SubmissionStatus.RUNNING.value
|
|
SubmissionStatus.RUNNING.value
|
|
if job.is_running()
|
|
if job.is_running()
|
|
@@ -190,7 +192,7 @@ class _GuiCoreContext(CoreEventConsumerBase):
|
|
)
|
|
)
|
|
payload.update(tasks=running_tasks)
|
|
payload.update(tasks=running_tasks)
|
|
|
|
|
|
- if last_status != new_status:
|
|
|
|
|
|
+ if last_status is not new_status:
|
|
# callback
|
|
# callback
|
|
submission_name = submission.properties.get("on_submission")
|
|
submission_name = submission.properties.get("on_submission")
|
|
if submission_name:
|
|
if submission_name:
|
|
@@ -308,7 +310,7 @@ class _GuiCoreContext(CoreEventConsumerBase):
|
|
|
|
|
|
def get_filtered_scenario_list(
|
|
def get_filtered_scenario_list(
|
|
self,
|
|
self,
|
|
- entities: t.List[t.Union[t.List, Scenario]],
|
|
|
|
|
|
+ entities: t.List[t.Union[t.List, Scenario, None]],
|
|
filters: t.Optional[t.List[t.Dict[str, t.Any]]],
|
|
filters: t.Optional[t.List[t.Dict[str, t.Any]]],
|
|
):
|
|
):
|
|
if not filters:
|
|
if not filters:
|
|
@@ -340,13 +342,15 @@ class _GuiCoreContext(CoreEventConsumerBase):
|
|
e
|
|
e
|
|
for e in filtered_list
|
|
for e in filtered_list
|
|
if not isinstance(e, Scenario)
|
|
if not isinstance(e, Scenario)
|
|
- or _invoke_action(e, col, col_type, is_datanode_prop, action, val, col_fn)
|
|
|
|
|
|
+ or _invoke_action(e, t.cast(str, col), col_type, is_datanode_prop, action, val, col_fn)
|
|
]
|
|
]
|
|
# level 2 filtering
|
|
# level 2 filtering
|
|
filtered_list = [
|
|
filtered_list = [
|
|
e
|
|
e
|
|
if isinstance(e, Scenario)
|
|
if isinstance(e, Scenario)
|
|
- else self.filter_entities(e, col, col_type, is_datanode_prop, action, val, col_fn)
|
|
|
|
|
|
+ else self.filter_entities(
|
|
|
|
+ t.cast(list, e), t.cast(str, col), col_type, is_datanode_prop, action, val, col_fn
|
|
|
|
+ )
|
|
for e in filtered_list
|
|
for e in filtered_list
|
|
]
|
|
]
|
|
# remove empty cycles
|
|
# remove empty cycles
|
|
@@ -414,17 +418,17 @@ class _GuiCoreContext(CoreEventConsumerBase):
|
|
or not isinstance(args[start_idx + 2], dict)
|
|
or not isinstance(args[start_idx + 2], dict)
|
|
):
|
|
):
|
|
return
|
|
return
|
|
- error_var = payload.get("error_id")
|
|
|
|
|
|
+ error_var = t.cast(str, payload.get("error_id"))
|
|
update = args[start_idx]
|
|
update = args[start_idx]
|
|
delete = args[start_idx + 1]
|
|
delete = args[start_idx + 1]
|
|
- data = args[start_idx + 2]
|
|
|
|
|
|
+ data = t.cast(dict, args[start_idx + 2])
|
|
with_dialog = True if len(args) < start_idx + 4 else bool(args[start_idx + 3])
|
|
with_dialog = True if len(args) < start_idx + 4 else bool(args[start_idx + 3])
|
|
scenario = None
|
|
scenario = None
|
|
user_scenario = None
|
|
user_scenario = None
|
|
|
|
|
|
name = data.get(_GuiCoreContext.__PROP_ENTITY_NAME)
|
|
name = data.get(_GuiCoreContext.__PROP_ENTITY_NAME)
|
|
if update:
|
|
if update:
|
|
- scenario_id = data.get(_GuiCoreContext.__PROP_ENTITY_ID)
|
|
|
|
|
|
+ scenario_id = t.cast(ScenarioId, data.get(_GuiCoreContext.__PROP_ENTITY_ID))
|
|
if delete:
|
|
if delete:
|
|
if not (reason := is_deletable(scenario_id)):
|
|
if not (reason := is_deletable(scenario_id)):
|
|
state.assign(error_var, f"Scenario. {scenario_id} is not deletable: {_get_reason(reason)}.")
|
|
state.assign(error_var, f"Scenario. {scenario_id} is not deletable: {_get_reason(reason)}.")
|
|
@@ -454,11 +458,11 @@ class _GuiCoreContext(CoreEventConsumerBase):
|
|
scenario_config = None
|
|
scenario_config = None
|
|
date = None
|
|
date = None
|
|
scenario_id = None
|
|
scenario_id = None
|
|
|
|
+ gui = state.get_gui()
|
|
try:
|
|
try:
|
|
- gui = state.get_gui()
|
|
|
|
on_creation = args[0] if isinstance(args[0], str) else None
|
|
on_creation = args[0] if isinstance(args[0], str) else None
|
|
on_creation_function = gui._get_user_function(on_creation) if on_creation else None
|
|
on_creation_function = gui._get_user_function(on_creation) if on_creation else None
|
|
- if callable(on_creation_function):
|
|
|
|
|
|
+ if callable(on_creation_function) and on_creation:
|
|
try:
|
|
try:
|
|
res = gui._call_function_with_state(
|
|
res = gui._call_function_with_state(
|
|
on_creation_function,
|
|
on_creation_function,
|
|
@@ -503,9 +507,8 @@ class _GuiCoreContext(CoreEventConsumerBase):
|
|
+ f"({len(Config.scenarios) - 1}) found.",
|
|
+ f"({len(Config.scenarios) - 1}) found.",
|
|
)
|
|
)
|
|
return
|
|
return
|
|
-
|
|
|
|
- scenario = create_scenario(scenario_config, date, name)
|
|
|
|
- scenario_id = scenario.id
|
|
|
|
|
|
+ scenario = create_scenario(scenario_config, date, name) if scenario_config else None
|
|
|
|
+ scenario_id = scenario.id if scenario else None
|
|
except Exception as e:
|
|
except Exception as e:
|
|
state.assign(error_var, f"Error creating Scenario. {e}")
|
|
state.assign(error_var, f"Error creating Scenario. {e}")
|
|
finally:
|
|
finally:
|
|
@@ -547,17 +550,17 @@ class _GuiCoreContext(CoreEventConsumerBase):
|
|
if args is None or not isinstance(args, list) or len(args) < 1 or not isinstance(args[0], dict):
|
|
if args is None or not isinstance(args, list) or len(args) < 1 or not isinstance(args[0], dict):
|
|
return
|
|
return
|
|
error_var = payload.get("error_id")
|
|
error_var = payload.get("error_id")
|
|
- data = args[0]
|
|
|
|
- entity_id = data.get(_GuiCoreContext.__PROP_ENTITY_ID)
|
|
|
|
|
|
+ data = t.cast(dict, args[0])
|
|
|
|
+ entity_id = t.cast(str, data.get(_GuiCoreContext.__PROP_ENTITY_ID))
|
|
sequence = data.get("sequence")
|
|
sequence = data.get("sequence")
|
|
if not self.__check_readable_editable(state, entity_id, "Scenario", error_var):
|
|
if not self.__check_readable_editable(state, entity_id, "Scenario", error_var):
|
|
return
|
|
return
|
|
- scenario: Scenario = core_get(entity_id)
|
|
|
|
|
|
+ scenario = t.cast(Scenario, core_get(entity_id))
|
|
if scenario:
|
|
if scenario:
|
|
try:
|
|
try:
|
|
if not sequence:
|
|
if not sequence:
|
|
if isinstance(sequence, str) and (name := data.get(_GuiCoreContext.__PROP_ENTITY_NAME)):
|
|
if isinstance(sequence, str) and (name := data.get(_GuiCoreContext.__PROP_ENTITY_NAME)):
|
|
- scenario.add_sequence(name, data.get("task_ids"))
|
|
|
|
|
|
+ scenario.add_sequence(name, t.cast(list, data.get("task_ids")))
|
|
else:
|
|
else:
|
|
primary = data.get(_GuiCoreContext.__PROP_SCENARIO_PRIMARY)
|
|
primary = data.get(_GuiCoreContext.__PROP_SCENARIO_PRIMARY)
|
|
if primary is True:
|
|
if primary is True:
|
|
@@ -572,11 +575,11 @@ class _GuiCoreContext(CoreEventConsumerBase):
|
|
if data.get("del", False):
|
|
if data.get("del", False):
|
|
scenario.remove_sequence(sequence)
|
|
scenario.remove_sequence(sequence)
|
|
else:
|
|
else:
|
|
- name = data.get(_GuiCoreContext.__PROP_ENTITY_NAME)
|
|
|
|
|
|
+ name = t.cast(str, data.get(_GuiCoreContext.__PROP_ENTITY_NAME))
|
|
if sequence != name:
|
|
if sequence != name:
|
|
scenario.rename_sequence(sequence, name)
|
|
scenario.rename_sequence(sequence, name)
|
|
if seqEntity := scenario.sequences.get(name):
|
|
if seqEntity := scenario.sequences.get(name):
|
|
- seqEntity.tasks = data.get("task_ids")
|
|
|
|
|
|
+ seqEntity.tasks = t.cast(list, data.get("task_ids"))
|
|
self.__edit_properties(seqEntity, data)
|
|
self.__edit_properties(seqEntity, data)
|
|
else:
|
|
else:
|
|
_GuiCoreContext.__assign_var(
|
|
_GuiCoreContext.__assign_var(
|
|
@@ -595,13 +598,13 @@ class _GuiCoreContext(CoreEventConsumerBase):
|
|
args = payload.get("args")
|
|
args = payload.get("args")
|
|
if args is None or not isinstance(args, list) or len(args) < 1 or not isinstance(args[0], dict):
|
|
if args is None or not isinstance(args, list) or len(args) < 1 or not isinstance(args[0], dict):
|
|
return
|
|
return
|
|
- data = args[0]
|
|
|
|
|
|
+ data = t.cast(dict, args[0])
|
|
error_var = payload.get("error_id")
|
|
error_var = payload.get("error_id")
|
|
try:
|
|
try:
|
|
- scenario_id = data.get(_GuiCoreContext.__PROP_ENTITY_ID)
|
|
|
|
- entity = core_get(scenario_id)
|
|
|
|
- if sequence := data.get("sequence"):
|
|
|
|
- entity = entity.sequences.get(sequence)
|
|
|
|
|
|
+ scenario_id = t.cast(str, data.get(_GuiCoreContext.__PROP_ENTITY_ID))
|
|
|
|
+ entity = t.cast(Scenario, core_get(scenario_id))
|
|
|
|
+ if sequence := t.cast(str, data.get("sequence")):
|
|
|
|
+ entity = t.cast(Sequence, entity.sequences.get(sequence))
|
|
|
|
|
|
if not (reason := is_submittable(entity)):
|
|
if not (reason := is_submittable(entity)):
|
|
_GuiCoreContext.__assign_var(
|
|
_GuiCoreContext.__assign_var(
|
|
@@ -631,7 +634,7 @@ class _GuiCoreContext(CoreEventConsumerBase):
|
|
|
|
|
|
def get_filtered_datanode_list(
|
|
def get_filtered_datanode_list(
|
|
self,
|
|
self,
|
|
- entities: t.List[t.Union[t.List, DataNode]],
|
|
|
|
|
|
+ entities: t.List[t.Union[t.List, DataNode, None]],
|
|
filters: t.Optional[t.List[t.Dict[str, t.Any]]],
|
|
filters: t.Optional[t.List[t.Dict[str, t.Any]]],
|
|
):
|
|
):
|
|
if not filters or not entities:
|
|
if not filters or not entities:
|
|
@@ -660,13 +663,16 @@ class _GuiCoreContext(CoreEventConsumerBase):
|
|
filtered_list = [
|
|
filtered_list = [
|
|
e
|
|
e
|
|
for e in filtered_list
|
|
for e in filtered_list
|
|
- if not isinstance(e, DataNode) or _invoke_action(e, col, col_type, False, action, val, col_fn)
|
|
|
|
|
|
+ if not isinstance(e, DataNode)
|
|
|
|
+ or _invoke_action(e, t.cast(str, col), col_type, False, action, val, col_fn)
|
|
]
|
|
]
|
|
# level 3 filtering
|
|
# level 3 filtering
|
|
filtered_list = [
|
|
filtered_list = [
|
|
- e if isinstance(e, DataNode) else self.filter_entities(d, col, col_type, False, action, val, col_fn)
|
|
|
|
|
|
+ e
|
|
|
|
+ if isinstance(e, DataNode)
|
|
|
|
+ else self.filter_entities(d, t.cast(str, col), col_type, False, action, val, col_fn)
|
|
for e in filtered_list
|
|
for e in filtered_list
|
|
- for d in e[2]
|
|
|
|
|
|
+ for d in t.cast(list, t.cast(list, e)[2])
|
|
]
|
|
]
|
|
# remove empty cycles
|
|
# remove empty cycles
|
|
return [e for e in filtered_list if isinstance(e, DataNode) or (isinstance(e, (tuple, list)) and len(e[2]))]
|
|
return [e for e in filtered_list if isinstance(e, DataNode) or (isinstance(e, (tuple, list)) and len(e[2]))]
|
|
@@ -724,8 +730,8 @@ class _GuiCoreContext(CoreEventConsumerBase):
|
|
base_list = []
|
|
base_list = []
|
|
else:
|
|
else:
|
|
base_list = datanodes
|
|
base_list = datanodes
|
|
- adapted_list = self.get_sorted_datanode_list(base_list, sorts)
|
|
|
|
- return self.get_filtered_datanode_list(adapted_list, filters)
|
|
|
|
|
|
+ adapted_list = self.get_sorted_datanode_list(t.cast(list, base_list), sorts)
|
|
|
|
+ return self.get_filtered_datanode_list(t.cast(list, adapted_list), filters)
|
|
|
|
|
|
def data_node_adapter(
|
|
def data_node_adapter(
|
|
self,
|
|
self,
|
|
@@ -737,8 +743,8 @@ class _GuiCoreContext(CoreEventConsumerBase):
|
|
if isinstance(data, tuple):
|
|
if isinstance(data, tuple):
|
|
raise NotImplementedError
|
|
raise NotImplementedError
|
|
if isinstance(data, list):
|
|
if isinstance(data, list):
|
|
- if data[2] and isinstance(data[2][0], (Cycle, Scenario, Sequence, DataNode)):
|
|
|
|
- data[2] = self.get_sorted_datanode_list(data[2], sorts, False)
|
|
|
|
|
|
+ if data[2] and isinstance(t.cast(list, data[2])[0], (Cycle, Scenario, Sequence, DataNode)):
|
|
|
|
+ data[2] = self.get_sorted_datanode_list(t.cast(list, data[2]), sorts, False)
|
|
return data
|
|
return data
|
|
try:
|
|
try:
|
|
if hasattr(data, "id") and is_readable(data.id) and core_get(data.id) is not None:
|
|
if hasattr(data, "id") and is_readable(data.id) and core_get(data.id) is not None:
|
|
@@ -770,7 +776,7 @@ class _GuiCoreContext(CoreEventConsumerBase):
|
|
data.id,
|
|
data.id,
|
|
data.get_simple_label(),
|
|
data.get_simple_label(),
|
|
self.get_sorted_datanode_list(
|
|
self.get_sorted_datanode_list(
|
|
- self.data_nodes_by_owner.get(data.id, []) + list(data.sequences.values()),
|
|
|
|
|
|
+ t.cast(list, self.data_nodes_by_owner.get(data.id, []) + list(data.sequences.values())),
|
|
sorts,
|
|
sorts,
|
|
False,
|
|
False,
|
|
),
|
|
),
|
|
@@ -828,7 +834,7 @@ class _GuiCoreContext(CoreEventConsumerBase):
|
|
args = payload.get("args")
|
|
args = payload.get("args")
|
|
if args is None or not isinstance(args, list) or len(args) < 1 or not isinstance(args[0], dict):
|
|
if args is None or not isinstance(args, list) or len(args) < 1 or not isinstance(args[0], dict):
|
|
return
|
|
return
|
|
- data = args[0]
|
|
|
|
|
|
+ data = t.cast(dict, args[0])
|
|
job_ids = data.get(_GuiCoreContext.__PROP_ENTITY_ID)
|
|
job_ids = data.get(_GuiCoreContext.__PROP_ENTITY_ID)
|
|
job_action = data.get(_GuiCoreContext.__ACTION)
|
|
job_action = data.get(_GuiCoreContext.__ACTION)
|
|
if job_action and isinstance(job_ids, list):
|
|
if job_action and isinstance(job_ids, list):
|
|
@@ -879,7 +885,7 @@ class _GuiCoreContext(CoreEventConsumerBase):
|
|
[] if job.stacktrace is None else job.stacktrace,
|
|
[] if job.stacktrace is None else job.stacktrace,
|
|
)
|
|
)
|
|
except Exception as e:
|
|
except Exception as e:
|
|
- _warn(f"Access to job ({job.id if hasattr(job, 'id') else 'No_id'}) failed", e)
|
|
|
|
|
|
+ _warn(f"Access to job ({job_id}) failed", e)
|
|
return None
|
|
return None
|
|
|
|
|
|
def edit_data_node(self, state: State, id: str, payload: t.Dict[str, str]):
|
|
def edit_data_node(self, state: State, id: str, payload: t.Dict[str, str]):
|
|
@@ -888,11 +894,11 @@ class _GuiCoreContext(CoreEventConsumerBase):
|
|
if args is None or not isinstance(args, list) or len(args) < 1 or not isinstance(args[0], dict):
|
|
if args is None or not isinstance(args, list) or len(args) < 1 or not isinstance(args[0], dict):
|
|
return
|
|
return
|
|
error_var = payload.get("error_id")
|
|
error_var = payload.get("error_id")
|
|
- data = args[0]
|
|
|
|
- entity_id = data.get(_GuiCoreContext.__PROP_ENTITY_ID)
|
|
|
|
|
|
+ data = t.cast(dict, args[0])
|
|
|
|
+ entity_id = t.cast(str, data.get(_GuiCoreContext.__PROP_ENTITY_ID))
|
|
if not self.__check_readable_editable(state, entity_id, "DataNode", error_var):
|
|
if not self.__check_readable_editable(state, entity_id, "DataNode", error_var):
|
|
return
|
|
return
|
|
- entity: DataNode = core_get(entity_id)
|
|
|
|
|
|
+ entity = t.cast(DataNode, core_get(entity_id))
|
|
if isinstance(entity, DataNode):
|
|
if isinstance(entity, DataNode):
|
|
try:
|
|
try:
|
|
self.__edit_properties(entity, data)
|
|
self.__edit_properties(entity, data)
|
|
@@ -905,13 +911,13 @@ class _GuiCoreContext(CoreEventConsumerBase):
|
|
args = payload.get("args")
|
|
args = payload.get("args")
|
|
if args is None or not isinstance(args, list) or len(args) < 1 or not isinstance(args[0], dict):
|
|
if args is None or not isinstance(args, list) or len(args) < 1 or not isinstance(args[0], dict):
|
|
return
|
|
return
|
|
- data = args[0]
|
|
|
|
|
|
+ data = t.cast(dict, args[0])
|
|
error_var = payload.get("error_id")
|
|
error_var = payload.get("error_id")
|
|
- entity_id = data.get(_GuiCoreContext.__PROP_ENTITY_ID)
|
|
|
|
|
|
+ entity_id = t.cast(str, data.get(_GuiCoreContext.__PROP_ENTITY_ID))
|
|
if not self.__check_readable_editable(state, entity_id, "Data node", error_var):
|
|
if not self.__check_readable_editable(state, entity_id, "Data node", error_var):
|
|
return
|
|
return
|
|
lock = data.get("lock", True)
|
|
lock = data.get("lock", True)
|
|
- entity: DataNode = core_get(entity_id)
|
|
|
|
|
|
+ entity = t.cast(DataNode, core_get(entity_id))
|
|
if isinstance(entity, DataNode):
|
|
if isinstance(entity, DataNode):
|
|
try:
|
|
try:
|
|
if lock:
|
|
if lock:
|
|
@@ -937,13 +943,13 @@ class _GuiCoreContext(CoreEventConsumerBase):
|
|
props = data.get("properties")
|
|
props = data.get("properties")
|
|
if isinstance(props, (list, tuple)):
|
|
if isinstance(props, (list, tuple)):
|
|
for prop in props:
|
|
for prop in props:
|
|
- key = prop.get("key")
|
|
|
|
|
|
+ key = t.cast(dict, prop).get("key")
|
|
if key and key not in _GuiCoreContext.__ENTITY_PROPS:
|
|
if key and key not in _GuiCoreContext.__ENTITY_PROPS:
|
|
- ent.properties[key] = prop.get("value")
|
|
|
|
|
|
+ ent.properties[key] = t.cast(dict, prop).get("value")
|
|
deleted_props = data.get("deleted_properties")
|
|
deleted_props = data.get("deleted_properties")
|
|
if isinstance(deleted_props, (list, tuple)):
|
|
if isinstance(deleted_props, (list, tuple)):
|
|
for prop in deleted_props:
|
|
for prop in deleted_props:
|
|
- key = prop.get("key")
|
|
|
|
|
|
+ key = t.cast(dict, prop).get("key")
|
|
if key and key not in _GuiCoreContext.__ENTITY_PROPS:
|
|
if key and key not in _GuiCoreContext.__ENTITY_PROPS:
|
|
ent.properties.pop(key, None)
|
|
ent.properties.pop(key, None)
|
|
|
|
|
|
@@ -1006,23 +1012,24 @@ class _GuiCoreContext(CoreEventConsumerBase):
|
|
args = payload.get("args")
|
|
args = payload.get("args")
|
|
if args is None or not isinstance(args, list) or len(args) < 1 or not isinstance(args[0], dict):
|
|
if args is None or not isinstance(args, list) or len(args) < 1 or not isinstance(args[0], dict):
|
|
return
|
|
return
|
|
- data = args[0]
|
|
|
|
|
|
+ data = t.cast(dict, args[0])
|
|
error_var = payload.get("error_id")
|
|
error_var = payload.get("error_id")
|
|
- entity_id = data.get(_GuiCoreContext.__PROP_ENTITY_ID)
|
|
|
|
|
|
+ entity_id = t.cast(str, data.get(_GuiCoreContext.__PROP_ENTITY_ID))
|
|
if not self.__check_readable_editable(state, entity_id, "Data node", error_var):
|
|
if not self.__check_readable_editable(state, entity_id, "Data node", error_var):
|
|
return
|
|
return
|
|
- entity: DataNode = core_get(entity_id)
|
|
|
|
|
|
+ entity = t.cast(DataNode, core_get(entity_id))
|
|
if isinstance(entity, DataNode):
|
|
if isinstance(entity, DataNode):
|
|
try:
|
|
try:
|
|
|
|
+ val = t.cast(str, data.get("value"))
|
|
entity.write(
|
|
entity.write(
|
|
- parser.parse(data.get("value"))
|
|
|
|
|
|
+ parser.parse(val)
|
|
if data.get("type") == "date"
|
|
if data.get("type") == "date"
|
|
- else int(data.get("value"))
|
|
|
|
|
|
+ else int(val)
|
|
if data.get("type") == "int"
|
|
if data.get("type") == "int"
|
|
- else float(data.get("value"))
|
|
|
|
|
|
+ else float(val)
|
|
if data.get("type") == "float"
|
|
if data.get("type") == "float"
|
|
else data.get("value"),
|
|
else data.get("value"),
|
|
- comment=data.get(_GuiCoreContext.__PROP_ENTITY_COMMENT),
|
|
|
|
|
|
+ comment=t.cast(dict, data.get(_GuiCoreContext.__PROP_ENTITY_COMMENT)),
|
|
)
|
|
)
|
|
entity.unlock_edit(self.gui._get_client_id())
|
|
entity.unlock_edit(self.gui._get_client_id())
|
|
_GuiCoreContext.__assign_var(state, error_var, "")
|
|
_GuiCoreContext.__assign_var(state, error_var, "")
|
|
@@ -1184,7 +1191,7 @@ class _GuiCoreContext(CoreEventConsumerBase):
|
|
try:
|
|
try:
|
|
entity = (
|
|
entity = (
|
|
core_get(args[0])
|
|
core_get(args[0])
|
|
- if (reason := is_readable(args[0]))
|
|
|
|
|
|
+ if (reason := is_readable(t.cast(ScenarioId, args[0])))
|
|
else f"{args[0]} is not readable: {_get_reason(reason)}"
|
|
else f"{args[0]} is not readable: {_get_reason(reason)}"
|
|
)
|
|
)
|
|
self.gui._call_function_with_state(
|
|
self.gui._call_function_with_state(
|