From 1fc7ead2f48f3abccb48212bd518513382d89b60 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 6 Feb 2024 17:10:50 +0100 Subject: [PATCH] sources: transform() is only used in the curl sources, remove from ABC --- osbuild/sources.py | 7 +------ sources/org.osbuild.containers-storage | 8 ++------ sources/org.osbuild.inline | 3 +-- sources/org.osbuild.ostree | 3 +-- sources/org.osbuild.skopeo | 3 +-- sources/org.osbuild.skopeo-index | 3 +-- 6 files changed, 7 insertions(+), 20 deletions(-) diff --git a/osbuild/sources.py b/osbuild/sources.py index 491b986a..a3f532e4 100644 --- a/osbuild/sources.py +++ b/osbuild/sources.py @@ -4,7 +4,7 @@ import hashlib import json import os import tempfile -from typing import ClassVar, Dict, Tuple +from typing import ClassVar, Dict from . import host from .objectstore import ObjectStore @@ -105,11 +105,6 @@ class SourceService(host.Service): """Returns True if the item to download is in cache. """ return os.path.isfile(f"{self.cache}/{checksum}") - # pylint: disable=[no-self-use] - def transform(self, checksum, desc) -> Tuple: - """Modify the input data before downloading. By default only transforms an item object to a Tupple.""" - return checksum, desc - @staticmethod def load_items(fds): with os.fdopen(fds.steal(0)) as f: diff --git a/sources/org.osbuild.containers-storage b/sources/org.osbuild.containers-storage index 1bfea583..4be3c652 100755 --- a/sources/org.osbuild.containers-storage +++ b/sources/org.osbuild.containers-storage @@ -13,7 +13,6 @@ by osbuild itself. Buildhost commands used: `skopeo`. """ -import concurrent.futures import hashlib import subprocess as sp import sys @@ -66,11 +65,8 @@ class ContainersStorageSource(sources.SourceService): self.exists(checksum, desc) def fetch_all(self, items) -> None: - # prepare each item as a (checksum, desc) tuple (where desc=None) - transformed = map(lambda i: self.transform(i, None), items) - with concurrent.futures.ThreadPoolExecutor(max_workers=self.max_workers) as executor: - for _ in executor.map(self.fetch_one, *zip(*transformed)): - pass + for checksum in items: + self.fetch_one(checksum, None) def exists(self, checksum, _) -> bool: image_id = checksum.split(":")[1] diff --git a/sources/org.osbuild.inline b/sources/org.osbuild.inline index 86313ecd..009c4bbe 100755 --- a/sources/org.osbuild.inline +++ b/sources/org.osbuild.inline @@ -59,9 +59,8 @@ class InlineSource(sources.SourceService): def fetch_all(self, items: Dict) -> None: filtered = filter(lambda i: not self.exists(i[0], i[1]), items.items()) # discards items already in cache - transformed = map(lambda i: self.transform(i[0], i[1]), filtered) # prepare each item to be downloaded - for args in transformed: + for args in filtered: self.fetch_one(*args) def fetch_one(self, checksum, desc): diff --git a/sources/org.osbuild.ostree b/sources/org.osbuild.ostree index ed590eda..b7bef478 100755 --- a/sources/org.osbuild.ostree +++ b/sources/org.osbuild.ostree @@ -91,10 +91,9 @@ class OSTreeSource(sources.SourceService): def fetch_all(self, items: Dict) -> None: filtered = filter(lambda i: not self.exists(i[0], i[1]), items.items()) # discards items already in cache - transformed = map(lambda i: self.transform(i[0], i[1]), filtered) # prepare each item to be downloaded with concurrent.futures.ThreadPoolExecutor(max_workers=self.max_workers) as executor: - for _ in executor.map(self.fetch_one, *zip(*transformed)): + for _ in executor.map(self.fetch_one, *zip(*filtered)): pass def fetch_one(self, checksum, desc): diff --git a/sources/org.osbuild.skopeo b/sources/org.osbuild.skopeo index 549cd384..6186d137 100755 --- a/sources/org.osbuild.skopeo +++ b/sources/org.osbuild.skopeo @@ -104,10 +104,9 @@ class SkopeoSource(sources.SourceService): def fetch_all(self, items: Dict) -> None: filtered = filter(lambda i: not self.exists(i[0], i[1]), items.items()) # discards items already in cache - transformed = map(lambda i: self.transform(i[0], i[1]), filtered) # prepare each item to be downloaded with concurrent.futures.ThreadPoolExecutor(max_workers=self.max_workers) as executor: - for _ in executor.map(self.fetch_one, *zip(*transformed)): + for _ in executor.map(self.fetch_one, *zip(*filtered)): pass def fetch_one(self, checksum, desc): diff --git a/sources/org.osbuild.skopeo-index b/sources/org.osbuild.skopeo-index index 4f056d52..8f23dc69 100755 --- a/sources/org.osbuild.skopeo-index +++ b/sources/org.osbuild.skopeo-index @@ -89,10 +89,9 @@ class SkopeoIndexSource(sources.SourceService): def fetch_all(self, items: Dict) -> None: filtered = filter(lambda i: not self.exists(i[0], i[1]), items.items()) # discards items already in cache - transformed = map(lambda i: self.transform(i[0], i[1]), filtered) # prepare each item to be downloaded with concurrent.futures.ThreadPoolExecutor(max_workers=self.max_workers) as executor: - for _ in executor.map(self.fetch_one, *zip(*transformed)): + for _ in executor.map(self.fetch_one, *zip(*filtered)): pass def fetch_one(self, checksum, desc):