Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

List the models TensorFlow Hub downloads on the Developer page

Țugui Dragoș768db8de3e4f
diff --git a/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift b/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift
index 844f78c1..10c3ce50 100644
--- a/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift
@@ -1104,6 +1104,13 @@ public enum DeveloperCaches {
Definition(id: "tensorflow", name: "TensorFlow Datasets", systemImage: "brain", appBundleIdentifiers: [], folders: [
Folder("tensorflow_datasets", .models, source: "https://github.com/tensorflow/datasets/blob/ff9ea5fdcba7cc4d25bac833ecb6659397694c12/tensorflow_datasets/core/constants.py#L36-L37"),
]),
+ Definition(id: "tfhub", name: "TensorFlow Hub", systemImage: "brain", appBundleIdentifiers: [], folders: [
+ Folder(
+ "tfhub_modules/", .models,
+ source: "https://github.com/tensorflow/hub/blob/26c94f67716f457efaa70c63b4d1b561a08be9f1/tensorflow_hub/resolver.py#L102-L106",
+ base: .userTemporary
+ ),
+ ]),
Definition(id: "keras", name: "Keras", systemImage: "brain", appBundleIdentifiers: [], folders: [
Folder(".keras/datasets", .models, source: "https://github.com/keras-team/keras/blob/f7116e50cde59245a7b56871b337ca03eb703d11/keras/src/utils/file_utils.py#L230-L232"),
Folder(".keras/models", .models, source: "https://github.com/keras-team/keras/blob/f7116e50cde59245a7b56871b337ca03eb703d11/keras/src/applications/resnet.py#L209"),
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift
index 6c524bfa..cab36a5d 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift
@@ -403,7 +403,7 @@ struct DeveloperCachesTests {
let ownedOutright: Set<String> = [
".ccache", ".electron-gyp", ".gitlibs", ".node-gyp", ".virtualenvs", "nltk_data", "tensorflow_datasets",
".zcompdump*", ".pnpm-store", "playwright_*dev_profile-*/", "playwright-artifacts-*/", "metro-cache/",
- "metro-file-map-*", "node-compile-cache/",
+ "metro-file-map-*", "node-compile-cache/", "tfhub_modules/",
]
for definition in DeveloperCaches.definitions {
for path in definition.folders.map(\.path) {
@@ -1487,6 +1487,20 @@ struct DeveloperCachesTests {
#expect(locations.allSatisfy { $0.kind == .cache && $0.isRecommended })
}
+ @Test func listsTensorFlowHubsModelsInTheTemporaryFolderWithoutSelectingThem() async throws {
+ let directory = try TemporaryDirectory()
+ let temporary = try directory.directory("var/T")
+ try directory.file("var/T/tfhub_modules/5a3e9c1b/saved_model.pb", bytes: 400_000)
+ let hub = DeveloperCaches.definitions.filter { $0.id == "tfhub" }
+
+ let locations = await DeveloperCaches.scan(
+ hub, homeDirectory: directory.url.appending(path: "home"), userTemporaryDirectory: temporary
+ ).flatMap(\.locations)
+
+ #expect(locations.map(\.url.lastPathComponent) == ["tfhub_modules"])
+ #expect(locations.allSatisfy { $0.kind == .models && !$0.isRecommended })
+ }
+
@Test func offersTheSonarScannersCacheAndNeverItsCertificates() async throws {
let directory = try TemporaryDirectory()
try directory.file(".sonar/cache/0f2e/sonar-scanner-engine-shaded-10.jar", bytes: 400_000)