Skip to content

Run: add auto-download when model is missing#52

Merged
sxy-trans-n merged 7 commits intomainfrom
kaki-read
Jul 30, 2025
Merged

Run: add auto-download when model is missing#52
sxy-trans-n merged 7 commits intomainfrom
kaki-read

Conversation

@kakiloki
Copy link
Contributor

This PR adds a small feature that automatically downloads the model if it is not found, similar to the logic in the pull command.
Issues 40.
Tested locally — the model downloads successfully and inference runs as expected.

@kakiloki kakiloki requested a review from sxy-trans-n July 11, 2025 09:09
@RamboRogers
Copy link

If you need this is exists in https://github.com/RamboRogers/mlx-gui

try writeModelMetadata(modelName: alias, modelDir: modelDir)
}

public static func ensureModelAvailable(modelName: String, silent: Bool = false) async throws -> String {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like the silent parameter doesn’t add much value here. Even if it were implemented properly, it wouldn’t really make sense in this context because the function already resolves and downloads models with user-facing messages by design.

Maybe we should consider removing silent entirely to simplify the API.

let modelExists = FileManager.default.fileExists(atPath: modelDir.path)

if !silent && resolved != modelName {
fputs("Info: Resolved model alias '\(modelName)' to '\(resolved)'\n", stdout)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not sure if using fputs and fflush(stdout) at this layer is a good idea. This function is part of the model resolution and download logic, so printing directly to stdout tightly couples it to CLI-style usage.

Maybe we should move these log messages up to a higher layer (like a CLI handler) and keep this layer clean and side-effect free? That way, this API can also be reused in other contexts (e.g., GUI or services) without printing unexpectedly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I will have a try

try writeModelMetadata(modelName: alias, modelDir: modelDir)
}

public static func ensureModelAvailable(modelName: String, silent: Bool = false) async throws -> String {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, the function name ensureModelAvailable feels a little off. From the name, I would expect it to just check or guarantee that the model is available, but not to actually resolve aliases, download models, or print logs.

Jiting He added 2 commits July 24, 2025 15:15
@sxy-trans-n sxy-trans-n merged commit 4d2f0f3 into main Jul 30, 2025
2 checks passed
@sxy-trans-n sxy-trans-n deleted the kaki-read branch July 30, 2025 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants