Skip to content
This repository has been archived by the owner on Jan 2, 2024. It is now read-only.

Commit

Permalink
move name attribute of dn to properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Toan Quach authored and Toan Quach committed Nov 2, 2023
1 parent 9835dbd commit 74a7ddb
Show file tree
Hide file tree
Showing 25 changed files with 89 additions and 88 deletions.
3 changes: 3 additions & 0 deletions src/taipy/core/_entity/_migrate/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ def __migrate_datanode(datanode: Dict) -> Dict:
# Update Scope enum after Pipeline removal
datanode["scope"] = __update_scope(datanode["scope"])

# Update move name attribute to properties dictionary
datanode["data_node_properties"]["name"] = datanode.pop("name", None)

if "last_edit_date" not in datanode:
datanode["last_edit_date"] = datanode.get("last_edition_date")
if "last_edition_date" in datanode:
Expand Down
2 changes: 0 additions & 2 deletions src/taipy/core/data/_abstract_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ def __init__(
config_id: str,
scope: Scope,
id: Optional[DataNodeId] = None,
name: Optional[str] = None,
owner_id: Optional[str] = None,
parent_ids: Optional[Set[str]] = None,
last_edit_date: Optional[datetime] = None,
Expand All @@ -110,7 +109,6 @@ def __init__(
config_id,
scope,
id,
name,
owner_id,
parent_ids,
last_edit_date,
Expand Down
2 changes: 0 additions & 2 deletions src/taipy/core/data/_data_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ def _entity_to_model(cls, data_node: DataNode) -> _DataNodeModel:
data_node.config_id,
data_node._scope,
data_node.storage_type(),
properties.pop("name", None) or data_node._name,
data_node.owner_id,
list(data_node._parent_ids),
data_node._last_edit_date.isoformat() if data_node._last_edit_date else None,
Expand Down Expand Up @@ -287,7 +286,6 @@ def _model_to_entity(cls, model: _DataNodeModel) -> DataNode:
config_id=model.config_id,
scope=model.scope,
id=model.id,
name=model.name,
owner_id=model.owner_id,
parent_ids=set(model.parent_ids),
last_edit_date=datetime.fromisoformat(model.last_edit_date) if model.last_edit_date else None,
Expand Down
1 change: 0 additions & 1 deletion src/taipy/core/data/_data_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def __create(
return cls.__DATA_NODE_CLASS_MAP[storage_type](
config_id=data_node_config.id,
scope=data_node_config.scope or DataNodeConfig._DEFAULT_SCOPE,
name=props.pop(cls.__NAME_KEY, None),
validity_period=data_node_config.validity_period,
owner_id=owner_id,
parent_ids=parent_ids,
Expand Down
3 changes: 0 additions & 3 deletions src/taipy/core/data/_data_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class _DataNodeModel(_BaseModel):
Column("config_id", String),
Column("scope", Enum(Scope)),
Column("storage_type", String),
Column("name", String),
Column("owner_id", String),
Column("parent_ids", JSON),
Column("last_edit_date", String),
Expand All @@ -50,7 +49,6 @@ class _DataNodeModel(_BaseModel):
config_id: str
scope: Scope
storage_type: str
name: Optional[str]
owner_id: Optional[str]
parent_ids: List[str]
last_edit_date: Optional[str]
Expand All @@ -71,7 +69,6 @@ def from_dict(data: Dict[str, Any]):
config_id=data["config_id"],
scope=Scope._from_repr(data["scope"]),
storage_type=data["storage_type"],
name=data.get("name"),
owner_id=data.get("owner_id"),
parent_ids=data.get("parent_ids", []),
last_edit_date=data.get("last_edit_date"),
Expand Down
3 changes: 0 additions & 3 deletions src/taipy/core/data/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class CSVDataNode(DataNode, _AbstractFileDataNode, _AbstractTabularDataNode):
Python identifier.
scope (Scope^): The scope of this data node.
id (str): The unique identifier of this data node.
name (str): A user-readable name of this data node.
owner_id (str): The identifier of the owner (sequence_id, scenario_id, cycle_id) or `None`.
parent_ids (Optional[Set[str]]): The identifiers of the parent tasks or `None`.
last_edit_date (datetime): The date and time of the last modification.
Expand Down Expand Up @@ -83,7 +82,6 @@ def __init__(
config_id: str,
scope: Scope,
id: Optional[DataNodeId] = None,
name: Optional[str] = None,
owner_id: Optional[str] = None,
parent_ids: Optional[Set[str]] = None,
last_edit_date: Optional[datetime] = None,
Expand Down Expand Up @@ -114,7 +112,6 @@ def __init__(
config_id,
scope,
id,
name,
owner_id,
parent_ids,
last_edit_date,
Expand Down
10 changes: 3 additions & 7 deletions src/taipy/core/data/data_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def __init__(
config_id,
scope: Scope = Scope(Scope.SCENARIO),
id: Optional[DataNodeId] = None,
name: Optional[str] = None,
owner_id: Optional[str] = None,
parent_ids: Optional[Set[str]] = None,
last_edit_date: Optional[datetime] = None,
Expand All @@ -114,7 +113,6 @@ def __init__(
self._parent_ids = parent_ids or set()
self._scope = scope
self._last_edit_date = last_edit_date
self._name = name
self._edit_in_progress = edit_in_progress
self._version = version or _VersionManagerFactory._build_manager()._get_latest_version()
self._validity_period = validity_period
Expand Down Expand Up @@ -201,14 +199,12 @@ def expiration_date(self) -> datetime:
return last_edit_date + validity_period if validity_period else last_edit_date

@property # type: ignore
@_self_reload(_MANAGER_NAME)
def name(self):
return self._name
def name(self) -> Optional[str]:
return self.properties.get("name")

@name.setter # type: ignore
@_self_setter(_MANAGER_NAME)
def name(self, val):
self._name = val
self.properties["name"] = val

@property
def version(self):
Expand Down
3 changes: 0 additions & 3 deletions src/taipy/core/data/excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class ExcelDataNode(DataNode, _AbstractFileDataNode, _AbstractTabularDataNode):
identifier.
scope (Scope^): The scope of this data node.
id (str): The unique identifier of this data node.
name (str): A user-readable name of this data node.
owner_id (str): The identifier of the owner (sequence_id, scenario_id, cycle_id) or
`None`.
parent_ids (Optional[Set[str]]): The identifiers of the parent tasks or `None`.
Expand Down Expand Up @@ -89,7 +88,6 @@ def __init__(
config_id: str,
scope: Scope,
id: Optional[DataNodeId] = None,
name: Optional[str] = None,
owner_id: Optional[str] = None,
parent_ids: Optional[Set[str]] = None,
last_edit_date: Optional[datetime] = None,
Expand Down Expand Up @@ -120,7 +118,6 @@ def __init__(
config_id,
scope,
id,
name,
owner_id,
parent_ids,
last_edit_date,
Expand Down
3 changes: 0 additions & 3 deletions src/taipy/core/data/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class GenericDataNode(DataNode):
identifier.
scope (Scope^): The scope of this data node.
id (str): The unique identifier of the data node.
name (str): A user-readable name of the data node.
owner_id (str): The identifier of the owner (sequence_id, scenario_id, cycle_id) or
`None`.
parent_ids (Optional[Set[str]]): The identifiers of the parent tasks or `None`.
Expand Down Expand Up @@ -67,7 +66,6 @@ def __init__(
config_id: str,
scope: Scope,
id: Optional[DataNodeId] = None,
name: Optional[str] = None,
owner_id: Optional[str] = None,
parent_ids: Optional[Set[str]] = None,
last_edit_date: Optional[datetime] = None,
Expand Down Expand Up @@ -99,7 +97,6 @@ def __init__(
config_id,
scope,
id,
name,
owner_id,
parent_ids,
last_edit_date,
Expand Down
3 changes: 0 additions & 3 deletions src/taipy/core/data/in_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class InMemoryDataNode(DataNode):
identifier.
scope (Scope^): The scope of this data node.
id (str): The unique identifier of this data node.
name (str): A user-readable name of this data node.
owner_id (str): The identifier of the owner (sequence_id, scenario_id, cycle_id) or
`None`.
parent_ids (Optional[Set[str]]): The identifiers of the parent tasks or `None`.
Expand Down Expand Up @@ -66,7 +65,6 @@ def __init__(
config_id: str,
scope: Scope,
id: Optional[DataNodeId] = None,
name: Optional[str] = None,
owner_id: Optional[str] = None,
parent_ids: Optional[Set[str]] = None,
last_edit_date: Optional[datetime] = None,
Expand All @@ -85,7 +83,6 @@ def __init__(
config_id,
scope,
id,
name,
owner_id,
parent_ids,
last_edit_date,
Expand Down
3 changes: 0 additions & 3 deletions src/taipy/core/data/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class JSONDataNode(DataNode, _AbstractFileDataNode):
Python identifier.
scope (Scope^): The scope of this data node.
id (str): The unique identifier of this data node.
name (str): A user-readable name of this data node.
owner_id (str): The identifier of the owner (sequence_id, scenario_id, cycle_id) or `None`.
parent_ids (Optional[Set[str]]): The identifiers of the parent tasks or `None`.
last_edit_date (datetime): The date and time of the last modification.
Expand Down Expand Up @@ -77,7 +76,6 @@ def __init__(
config_id: str,
scope: Scope,
id: Optional[DataNodeId] = None,
name: Optional[str] = None,
owner_id: Optional[str] = None,
parent_ids: Optional[Set[str]] = None,
last_edit_date: Optional[datetime] = None,
Expand All @@ -101,7 +99,6 @@ def __init__(
config_id,
scope,
id,
name,
owner_id,
parent_ids,
last_edit_date,
Expand Down
3 changes: 0 additions & 3 deletions src/taipy/core/data/mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class MongoCollectionDataNode(DataNode):
identifier.
scope (Scope^): The scope of this data node.
id (str): The unique identifier of this data node.
name (str): A user-readable name of this data node.
owner_id (str): The identifier of the owner (sequence_id, scenario_id, cycle_id) or
None.
parent_ids (Optional[Set[str]]): The identifiers of the parent tasks or `None`.
Expand Down Expand Up @@ -88,7 +87,6 @@ def __init__(
config_id: str,
scope: Scope,
id: Optional[DataNodeId] = None,
name: Optional[str] = None,
owner_id: Optional[str] = None,
parent_ids: Optional[Set[str]] = None,
last_edit_date: Optional[datetime] = None,
Expand All @@ -114,7 +112,6 @@ def __init__(
config_id,
scope,
id,
name,
owner_id,
parent_ids,
last_edit_date,
Expand Down
3 changes: 0 additions & 3 deletions src/taipy/core/data/parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class ParquetDataNode(DataNode, _AbstractFileDataNode, _AbstractTabularDataNode)
Python identifier.
scope (Scope^): The scope of this data node.
id (str): The unique identifier of this data node.
name (str): A user-readable name of this data node.
owner_id (str): The identifier of the owner (sequence_id, scenario_id, cycle_id) or `None`.
parent_ids (Optional[Set[str]]): The identifiers of the parent tasks or `None`.
last_edit_date (datetime): The date and time of the last modification.
Expand Down Expand Up @@ -98,7 +97,6 @@ def __init__(
config_id: str,
scope: Scope,
id: Optional[DataNodeId] = None,
name: Optional[str] = None,
owner_id: Optional[str] = None,
parent_ids: Optional[Set[str]] = None,
last_edit_date: Optional[datetime] = None,
Expand Down Expand Up @@ -150,7 +148,6 @@ def __init__(
config_id,
scope,
id,
name,
owner_id,
parent_ids,
last_edit_date,
Expand Down
3 changes: 0 additions & 3 deletions src/taipy/core/data/pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class PickleDataNode(DataNode, _AbstractFileDataNode):
identifer.
scope (Scope^): The scope of this data node.
id (str): The unique identifier of this data node.
name (str): A user-readable name of this data node.
owner_id (str): The identifier of the owner (sequence_id, scenario_id, cycle_id) or
`None`.
parent_ids (Optional[Set[str]]): The identifiers of the parent tasks or `None`.
Expand Down Expand Up @@ -71,7 +70,6 @@ def __init__(
config_id: str,
scope: Scope,
id: Optional[DataNodeId] = None,
name: Optional[str] = None,
owner_id: Optional[str] = None,
parent_ids: Optional[Set[str]] = None,
last_edit_date: Optional[datetime] = None,
Expand All @@ -95,7 +93,6 @@ def __init__(
config_id,
scope,
id,
name,
owner_id,
parent_ids,
last_edit_date,
Expand Down
3 changes: 0 additions & 3 deletions src/taipy/core/data/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class SQLDataNode(_AbstractSQLDataNode):
identifier.
scope (Scope^): The scope of this data node.
id (str): The unique identifier of this data node.
name (str): A user-readable name of this data node.
owner_id (str): The identifier of the owner (sequence_id, scenario_id, cycle_id) or
None.
parent_ids (Optional[Set[str]]): The identifiers of the parent tasks or `None`.
Expand Down Expand Up @@ -77,7 +76,6 @@ def __init__(
config_id: str,
scope: Scope,
id: Optional[DataNodeId] = None,
name: Optional[str] = None,
owner_id: Optional[str] = None,
parent_ids: Optional[Set[str]] = None,
last_edit_date: Optional[datetime] = None,
Expand All @@ -100,7 +98,6 @@ def __init__(
config_id,
scope,
id,
name,
owner_id,
parent_ids,
last_edit_date,
Expand Down
3 changes: 0 additions & 3 deletions src/taipy/core/data/sql_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class SQLTableDataNode(_AbstractSQLDataNode):
identifier.
scope (Scope^): The scope of this data node.
id (str): The unique identifier of this data node.
name (str): A user-readable name of this data node.
owner_id (str): The identifier of the owner (sequence_id, scenario_id, cycle_id) or
None.
parent_ids (Optional[Set[str]]): The identifiers of the parent tasks or `None`.
Expand Down Expand Up @@ -78,7 +77,6 @@ def __init__(
config_id: str,
scope: Scope,
id: Optional[DataNodeId] = None,
name: Optional[str] = None,
owner_id: Optional[str] = None,
parent_ids: Optional[Set[str]] = None,
last_edit_date: Optional[datetime] = None,
Expand All @@ -98,7 +96,6 @@ def __init__(
config_id,
scope,
id=id,
name=name,
owner_id=owner_id,
parent_ids=parent_ids,
last_edit_date=last_edit_date,
Expand Down
6 changes: 4 additions & 2 deletions tests/core/data/test_csv_data_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ def __init__(self, id, integer, text):
class TestCSVDataNode:
def test_create(self):
path = "data/node/path"
dn = CSVDataNode("foo_bar", Scope.SCENARIO, name="super name", properties={"path": path, "has_header": False})
dn = CSVDataNode(
"foo_bar", Scope.SCENARIO, properties={"path": path, "has_header": False, "name": "super name"}
)
assert isinstance(dn, CSVDataNode)
assert dn.storage_type() == "csv"
assert dn.config_id == "foo_bar"
Expand All @@ -63,7 +65,7 @@ def test_create(self):

with pytest.raises(InvalidConfigurationId):
dn = CSVDataNode(
"foo bar", Scope.SCENARIO, name="super name", properties={"path": path, "has_header": False}
"foo bar", Scope.SCENARIO, properties={"path": path, "has_header": False, "name": "super name"}
)

def test_get_user_properties(self, csv_file):
Expand Down
Loading

0 comments on commit 74a7ddb

Please sign in to comment.