diff --git a/.github/workflows/python-ci.yml b/.github/workflows/python-ci.yml index 2983c890af..8e7938caa1 100644 --- a/.github/workflows/python-ci.yml +++ b/.github/workflows/python-ci.yml @@ -34,7 +34,7 @@ jobs: runs-on: ubuntu-22.04 strategy: matrix: - python: ['3.8', '3.9', '3.10', '3.11'] + python: ['3.11'] steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/python-integration.yml b/.github/workflows/python-integration.yml index 6aeae0fc9e..00e9c95656 100644 --- a/.github/workflows/python-integration.yml +++ b/.github/workflows/python-integration.yml @@ -31,7 +31,10 @@ concurrency: jobs: integration-test: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 + strategy: + matrix: + python: [ '3.11' ] steps: - uses: actions/checkout@v4 diff --git a/pyiceberg/table/snapshots.py b/pyiceberg/table/snapshots.py index b21a0f5613..123611a9f5 100644 --- a/pyiceberg/table/snapshots.py +++ b/pyiceberg/table/snapshots.py @@ -19,6 +19,7 @@ import time from collections import defaultdict from enum import Enum +from functools import lru_cache from typing import TYPE_CHECKING, Any, DefaultDict, Dict, Iterable, List, Mapping, Optional from pydantic import Field, PrivateAttr, model_serializer @@ -228,6 +229,15 @@ def __eq__(self, other: Any) -> bool: ) +@lru_cache +def _manifests(io: FileIO, manifest_list: Optional[str]) -> List[ManifestFile]: + """Return the manifests for the given snapshot.""" + if manifest_list not in (None, ""): + file = io.new_input(manifest_list) # type: ignore + return list(read_manifest_list(file)) + return [] + + class Snapshot(IcebergBaseModel): snapshot_id: int = Field(alias="snapshot-id") parent_snapshot_id: Optional[int] = Field(alias="parent-snapshot-id", default=None) @@ -248,10 +258,8 @@ def __str__(self) -> str: return result_str def manifests(self, io: FileIO) -> List[ManifestFile]: - if self.manifest_list is not None: - file = io.new_input(self.manifest_list) - return list(read_manifest_list(file)) - return [] + """Return the manifests for the given snapshot.""" + return _manifests(io, self.manifest_list) class MetadataLogEntry(IcebergBaseModel):