Skip to content

Commit

Permalink
Merge branch 'develop' into feature/json-resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
dinhlongviolin1 authored Feb 23, 2024
2 parents c6650ae + 605ad9e commit f16d4cf
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 17 deletions.
15 changes: 10 additions & 5 deletions frontend/taipy/src/DataNodeChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,19 +237,24 @@ const DataNodeChart = (props: DataNodeChartProps) => {

const [config, setConfig] = useState<ChartConfig | undefined>(undefined);
useEffect(() => {
let localConf;
const localItem = localStorage && localStorage.getItem(`${configId}-chart-config`);
if (localItem) {
try {
const conf = JSON.parse(localItem);
conf.cumulative && addCumulative(conf);
setConfig(conf);
return;
localConf = JSON.parse(localItem) as ChartConfig;
} catch {
// do nothing
}
}
const conf = getBaseConfig(defaultConfig, chartConfigs, configId);
if (conf) {
if (localConf && localConf.traces) {
if (conf && conf.columns && localConf.traces.some((tr) => tr.some((id) => (conf.columns || {})[id] === undefined))) {
setConfig(conf);
} else {
localConf.cumulative && addCumulative(localConf);
setConfig(localConf);
}
} else if (conf) {
setConfig(conf);
}
}, [defaultConfig, configId, chartConfigs]);
Expand Down
3 changes: 3 additions & 0 deletions taipy/core/_orchestrator/_dispatcher/_job_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# specific language governing permissions and limitations under the License.

import threading
import time
from abc import abstractmethod
from queue import Empty
from typing import Dict, Optional
Expand Down Expand Up @@ -69,6 +70,8 @@ def run(self):
break
job = self.orchestrator.jobs_to_run.get(block=True, timeout=0.1)
self._execute_job(job)
else:
time.sleep(0.1) # We need to sleep to avoid busy waiting.
except Empty: # In case the last job of the queue has been removed.
pass
except Exception as e:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ def _dispatch(self, job: Job):
future = self._executor.submit(_TaskFunctionWrapper(job.id, job.task), config_as_string=config_as_string)

self._set_dispatched_processes(job.id, future) # type: ignore
future.add_done_callback(self._release_worker) # We must release the worker before updating the job status
# so that the worker is available for another job as soon as possible.
future.add_done_callback(partial(self._update_job_status_from_future, job))
future.add_done_callback(self._release_worker)

def _release_worker(self, _):
self._nb_available_workers += 1
Expand Down
54 changes: 43 additions & 11 deletions taipy/gui_core/_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ def __is_tabular_data(datanode: DataNode, value: t.Any):
if isinstance(datanode, _AbstractTabularDataNode):
return True
if datanode.is_ready_for_reading:
return isinstance(value, (pd.DataFrame, pd.Series))
return isinstance(value, (pd.DataFrame, pd.Series, list, tuple, dict))
return False

def get_data_node_data(self, datanode: DataNode, id: str):
Expand Down Expand Up @@ -804,8 +804,8 @@ def tabular_data_edit(self, state: State, var_name: str, payload: dict):
datanode = core_get(dn_id) if dn_id else None
if isinstance(datanode, DataNode):
try:
idx = payload.get("index")
col = payload.get("col")
idx = t.cast(int, payload.get("index"))
col = t.cast(str, payload.get("col"))
tz = payload.get("tz")
val = (
parser.parse(str(payload.get("value"))).astimezone(zoneinfo.ZoneInfo(tz)).replace(tzinfo=None)
Expand All @@ -814,15 +814,47 @@ def tabular_data_edit(self, state: State, var_name: str, payload: dict):
)
# user_value = payload.get("user_value")
data = self.__read_tabular_data(datanode)
if hasattr(data, "at"):
data.at[idx, col] = val
datanode.write(data, comment=user_data.get(_GuiCoreContext.__PROP_ENTITY_COMMENT))
state.assign(_GuiCoreContext._DATANODE_VIZ_ERROR_VAR, "")
new_data: t.Any = None
if isinstance(data, (pd.DataFrame, pd.Series)):
if isinstance(data, pd.DataFrame):
data.at[idx, col] = val
elif isinstance(data, pd.Series):
data.at[idx] = val
new_data = data
else:
state.assign(
_GuiCoreContext._DATANODE_VIZ_ERROR_VAR,
"Error updating Datanode tabular value: type does not support at[] indexer.",
)
data_tuple = False
if isinstance(data, tuple):
data_tuple = True
data = list(data)
if isinstance(data, list):
row = data[idx]
row_tuple = False
if isinstance(row, tuple):
row = list(row)
row_tuple = True
if isinstance(row, list):
row[int(col)] = val
if row_tuple:
data[idx] = tuple(row)
new_data = data
elif col == "0" and (isinstance(row, (str, Number)) or "date" in type(row).__name__):
data[idx] = val
new_data = data
else:
state.assign(
_GuiCoreContext._DATANODE_VIZ_ERROR_VAR,
"Error updating Datanode: cannot handle multi-column list value.",
)
if data_tuple and new_data is not None:
new_data = tuple(new_data)
else:
state.assign(
_GuiCoreContext._DATANODE_VIZ_ERROR_VAR,
"Error updating Datanode tabular value: type does not support at[] indexer.",
)
if new_data is not None:
datanode.write(new_data, comment=user_data.get(_GuiCoreContext.__PROP_ENTITY_COMMENT))
state.assign(_GuiCoreContext._DATANODE_VIZ_ERROR_VAR, "")
except Exception as e:
state.assign(_GuiCoreContext._DATANODE_VIZ_ERROR_VAR, f"Error updating Datanode tabular value. {e}")
setattr(state, _GuiCoreContext._DATANODE_VIZ_DATA_ID_VAR, dn_id)
Expand Down

0 comments on commit f16d4cf

Please sign in to comment.