Skip to content

PyPartition

Bases: PyObject

Main class for interacting with partitions.

See methods for available uses.

Source code in pytabular/partition.py
class PyPartition(PyObject):
    """Main class for interacting with partitions.

    See methods for available uses.
    """

    def __init__(self, object, table) -> None:
        """Extends from `PyObject` class.

        Adds a few custom rows to `rich` table for the partition.

        Args:
            object (Partition): .Net Partition object.
            table (PyTable): Parent table of the partition in question.
        """
        super().__init__(object)
        self.Table = table
        self._display.add_row("Mode", str(self._object.Mode))
        self._display.add_row("State", str(self._object.State))
        self._display.add_row(
            "SourceType", str(self._object.SourceType), end_section=True
        )
        self._display.add_row(
            "RefreshedTime", self.last_refresh().strftime("%m/%d/%Y, %H:%M:%S")
        )

    def last_refresh(self) -> datetime:
        """Queries `RefreshedTime` attribute in the partition.

        Converts from C# Ticks to Python datetime.

        Returns:
            datetime.datetime: Last Refreshed time of Partition in datetime format
        """
        return ticks_to_datetime(self.RefreshedTime.Ticks)

    def refresh(self, *args, **kwargs) -> pd.DataFrame:
        """Same method from Model Refresh.

        You can pass through any extra parameters. For example:
        `Tabular().Tables['Table Name'].Partitions[0].refresh()`

        Returns:
            pd.DataFrame: Returns pandas dataframe with some refresh details
        """
        return self.Table.Model.refresh(self, *args, **kwargs)

__init__(object, table)

Extends from PyObject class.

Adds a few custom rows to rich table for the partition.

Parameters:

Name Type Description Default
object Partition

.Net Partition object.

required
table PyTable

Parent table of the partition in question.

required
Source code in pytabular/partition.py
def __init__(self, object, table) -> None:
    """Extends from `PyObject` class.

    Adds a few custom rows to `rich` table for the partition.

    Args:
        object (Partition): .Net Partition object.
        table (PyTable): Parent table of the partition in question.
    """
    super().__init__(object)
    self.Table = table
    self._display.add_row("Mode", str(self._object.Mode))
    self._display.add_row("State", str(self._object.State))
    self._display.add_row(
        "SourceType", str(self._object.SourceType), end_section=True
    )
    self._display.add_row(
        "RefreshedTime", self.last_refresh().strftime("%m/%d/%Y, %H:%M:%S")
    )

last_refresh()

Queries RefreshedTime attribute in the partition.

Converts from C# Ticks to Python datetime.

Returns:

Type Description
datetime

datetime.datetime: Last Refreshed time of Partition in datetime format

Source code in pytabular/partition.py
def last_refresh(self) -> datetime:
    """Queries `RefreshedTime` attribute in the partition.

    Converts from C# Ticks to Python datetime.

    Returns:
        datetime.datetime: Last Refreshed time of Partition in datetime format
    """
    return ticks_to_datetime(self.RefreshedTime.Ticks)

refresh(*args, **kwargs)

Same method from Model Refresh.

You can pass through any extra parameters. For example: Tabular().Tables['Table Name'].Partitions[0].refresh()

Returns:

Type Description
DataFrame

pd.DataFrame: Returns pandas dataframe with some refresh details

Source code in pytabular/partition.py
def refresh(self, *args, **kwargs) -> pd.DataFrame:
    """Same method from Model Refresh.

    You can pass through any extra parameters. For example:
    `Tabular().Tables['Table Name'].Partitions[0].refresh()`

    Returns:
        pd.DataFrame: Returns pandas dataframe with some refresh details
    """
    return self.Table.Model.refresh(self, *args, **kwargs)