Repository: Avaiga/taipy
File: taipy/core/data/data_node.py (Python)

Code before:
    SQL Data Node, CSV Data Node, ...).

    !!! note
        It is not recommended to instantiate subclasses of `DataNode` directly. Instead,
        you have two ways:

        1. Create a Scenario using the `create_scenario()^` function. Related data nodes
            will be created automatically. Please refer to the `Scenario^` class for more
            information.
        2. Configure a `DataNodeConfig^` with the various configuration methods form `Config^`
            and use the `create_global_data_node()^` function as illustrated in the following
            example.

    !!! Example

        ```python
        import taipy as tp
        from taipy import Config

        # Configure a global data node
        dataset_cfg = Config.configure_data_node("my_dataset", scope=tp.Scope.GLOBAL)

        # Instantiate a global data node
        dataset = tp.create_global_data_node(dataset_cfg)

        # Retrieve all data nodes
        all_data_nodes = tp.get_data_nodes()

        # Write the data
        dataset.write("Hello, World!")

        # Read the data
        print(dataset.read())
        ```

    Attributes:
        config_id (str): Identifier of the data node configuration. It must be a valid 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 set of identifiers of the parent tasks.
        last_edit_date (datetime): The date and time of the last modification.
        edits (List[Edit^]): The list of Edits (an alias for dict) containing metadata about each
            data edition including but not limited to timestamp, comments, job_id:
                timestamp: The time instant of the writing
                comments: Representation of a free text to explain or comment on a data change
                job_id: Only populated when the data node is written by a task execution and
                    corresponds to the job's id.

Review comment (suggestion):
```suggestion
        # Retrieve the list of all data nodes
```

Code after:
            _ReadyToRunProperty._add(dn, f"DataNode {dn.id} is being edited")
        else:
            _ReadyToRunProperty._remove(dn, f"DataNode {dn.id} is being edited")
        if not dn._last_edit_date:
            _ReadyToRunProperty._add(dn, f"DataNode {dn.id} is not written")
        else:
            _ReadyToRunProperty._remove(dn, f"DataNode {dn.id} is not written")

    return _recompute_is_ready_for_reading


class DataNode(_Entity, _Labeled):
    """Reference to a dataset.

    A Data Node is an abstract class that holds metadata related to the dataset it refers to.
    In particular, a data node holds the name, the scope, the owner identifier, the last
    edit date, and some additional properties of the data.<br/>
    A Data Node also contains information and methods needed to access the dataset. This
    information depends on the type of storage, and it is held by subclasses (such as
    SQL Data Node, CSV Data Node, ...).

    !!! note
        It is not recommended to instantiate subclasses of `DataNode` directly. Instead,
        you have two ways:

        1. Create a Scenario using the `create_scenario()^` function. Related data nodes
            will be created automatically. Please refer to the `Scenario^` class for more
            information.
        2. Configure a `DataNodeConfig^` with the various configuration methods form `Config^`
            and use the `create_global_data_node()^` function as illustrated in the following
            example.

    !!! Example

        ```python
        import taipy as tp
        from taipy import Config

        # Configure a global data node
        dataset_cfg = Config.configure_data_node("my_dataset", scope=tp.Scope.GLOBAL)

        # Instantiate a global data node
        dataset = tp.create_global_data_node(dataset_cfg)

        # Retrieve the list of all data nodes
        all_data_nodes = tp.get_data_nodes()

        # Write the data
        dataset.write("Hello, World!")

        # Read the data