-
Notifications
You must be signed in to change notification settings - Fork 1
v0.3.7 maintenance: CI Node.js 24 upgrade + 3 deferred features #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5740433
docs: v0.3.7 maintenance plan
magicnight 9e90f9b
chore(ci): upgrade GitHub Actions to Node.js 24 (checkout@v5, cache@v5)
magicnight 6de4680
feat(logs): capture MLX stdout/stderr into the Logs tab
magicnight f6dd3df
feat(library): detect when a downloaded model has an update on HF
magicnight 12301a5
feat(daemon): GUI and CLI share ~/.mac-mlx/macmlx.pid
magicnight 935d0bc
docs: v0.3.7 changelog entry (4 items — CI Node 24, stdout capture, u…
magicnight c68e94a
fix(logs): mark StdoutCapture.installed nonisolated(unsafe)
magicnight File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 44 additions & 10 deletions
54
...x-cli/Sources/macmlx/Shared/PIDFile.swift → ...Sources/MacMLXCore/Managers/PIDFile.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
MacMLXCore/Sources/MacMLXCore/Models/DownloadedModelMeta.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import Foundation | ||
|
|
||
| /// Metadata sidecar stored next to a downloaded model at | ||
| /// `<modelDir>/.macmlx-meta.json`. Persisted on first successful | ||
| /// download so we can later detect when the Hub repo has advanced | ||
| /// past this snapshot. | ||
| public struct DownloadedModelMeta: Codable, Sendable { | ||
| /// Full HF model ID (e.g. `mlx-community/Qwen3-8B-4bit`). | ||
| public let modelID: String | ||
| /// Commit SHA of the `main` branch at download time, if HF | ||
| /// exposed it. Nil for older downloads predating this field. | ||
| public let commitSHA: String? | ||
| /// `lastModified` timestamp reported by `/api/models/{id}` at | ||
| /// download time. | ||
| public let lastModifiedAtDownload: Date? | ||
| /// Wall-clock time of the download event (may lag behind | ||
| /// `lastModifiedAtDownload` by minutes). | ||
| public let downloadedAt: Date | ||
|
|
||
| public init( | ||
| modelID: String, | ||
| commitSHA: String?, | ||
| lastModifiedAtDownload: Date?, | ||
| downloadedAt: Date = Date() | ||
| ) { | ||
| self.modelID = modelID | ||
| self.commitSHA = commitSHA | ||
| self.lastModifiedAtDownload = lastModifiedAtDownload | ||
| self.downloadedAt = downloadedAt | ||
| } | ||
|
|
||
| public static let filename = ".macmlx-meta.json" | ||
|
|
||
| public static func url(inside modelDir: URL) -> URL { | ||
| modelDir.appending(path: filename, directoryHint: .notDirectory) | ||
| } | ||
|
|
||
| public static func load(from modelDir: URL) -> DownloadedModelMeta? { | ||
| let fileURL = url(inside: modelDir) | ||
| guard let data = try? Data(contentsOf: fileURL) else { return nil } | ||
| let decoder = JSONDecoder() | ||
| decoder.dateDecodingStrategy = .iso8601 | ||
| return try? decoder.decode(DownloadedModelMeta.self, from: data) | ||
| } | ||
|
|
||
| public func save(to modelDir: URL) throws { | ||
| let encoder = JSONEncoder() | ||
| encoder.dateEncodingStrategy = .iso8601 | ||
| encoder.outputFormatting = [.prettyPrinted] | ||
| let data = try encoder.encode(self) | ||
| try data.write(to: Self.url(inside: modelDir), options: .atomic) | ||
| } | ||
| } |
42 changes: 42 additions & 0 deletions
42
MacMLXCore/Tests/MacMLXCoreTests/Models/DownloadedModelMetaTests.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import XCTest | ||
| @testable import MacMLXCore | ||
|
|
||
| final class DownloadedModelMetaTests: XCTestCase { | ||
| private func tmpDir() -> URL { | ||
| let dir = FileManager.default.temporaryDirectory | ||
| .appending(path: "macmlx-meta-test-\(UUID().uuidString)", directoryHint: .isDirectory) | ||
| try? FileManager.default.createDirectory(at: dir, withIntermediateDirectories: true) | ||
| return dir | ||
| } | ||
|
|
||
| func testRoundtrip() throws { | ||
| let dir = tmpDir() | ||
| let meta = DownloadedModelMeta( | ||
| modelID: "mlx-community/Qwen3-8B-4bit", | ||
| commitSHA: "abc123", | ||
| lastModifiedAtDownload: Date(timeIntervalSince1970: 1_700_000_000) | ||
| ) | ||
| try meta.save(to: dir) | ||
| let loaded = DownloadedModelMeta.load(from: dir) | ||
| XCTAssertEqual(loaded?.modelID, "mlx-community/Qwen3-8B-4bit") | ||
| XCTAssertEqual(loaded?.commitSHA, "abc123") | ||
| XCTAssertEqual( | ||
| loaded?.lastModifiedAtDownload?.timeIntervalSince1970 ?? 0, | ||
| 1_700_000_000, | ||
| accuracy: 1 | ||
| ) | ||
| } | ||
|
|
||
| func testMissingSidecar() { | ||
| XCTAssertNil(DownloadedModelMeta.load(from: tmpDir())) | ||
| } | ||
|
|
||
| func testCorruptSidecar() throws { | ||
| let dir = tmpDir() | ||
| try "not json".data(using: .utf8)!.write( | ||
| to: DownloadedModelMeta.url(inside: dir), | ||
| options: .atomic | ||
| ) | ||
| XCTAssertNil(DownloadedModelMeta.load(from: dir)) | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New
downloadMetaduplicates existingfilesmethod logicLow Severity
downloadMeta(for:)is a strict superset offiles(for:)— both hit the same/api/models/{id}endpoint, decode the sameModelDetailsEnvelope, and mapsiblingsidentically.files(for:)(still called bysizeBytes(for:)) could simply delegate todownloadMeta(for:).files, eliminating the duplicated URL construction, fetch, decode, and map logic. Maintaining two copies risks them drifting apart on future changes.Additional Locations (1)
MacMLXCore/Sources/MacMLXCore/Managers/HFDownloader.swift#L336-L345Reviewed by Cursor Bugbot for commit c68e94a. Configure here.