-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Enable --offline
mode without curl support
#16137
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
Enable --offline
mode without curl support
#16137
Conversation
Signed-off-by: Adrien Gallouët <angt@huggingface.co>
This change refactors the download logic to properly support offline mode even when the project is built without CURL. Without this commit, using `--offline` would give the following error: error: built without CURL, cannot download model from the internet even if all the files are already cached. Signed-off-by: Adrien Gallouët <angt@huggingface.co>
try { | ||
auto j = json::parse(res_str); | ||
|
||
if (j.contains("ggufFile") && j["ggufFile"].contains("rfilename")) { | ||
ggufFile = j["ggufFile"]["rfilename"].get<std::string>(); | ||
} | ||
} | ||
// extract mmprojFile.rfilename in json, using regex | ||
{ | ||
std::regex pattern("\"mmprojFile\"[\\s\\S]*?\"rfilename\"\\s*:\\s*\"([^\"]+)\""); | ||
std::smatch match; | ||
if (std::regex_search(res_str, match, pattern)) { | ||
mmprojFile = match[1].str(); | ||
if (j.contains("mmprojFile") && j["mmprojFile"].contains("rfilename")) { | ||
mmprojFile = j["mmprojFile"]["rfilename"].get<std::string>(); | ||
} | ||
} catch (const std::exception & e) { | ||
throw std::runtime_error(std::string("error parsing manifest JSON: ") + e.what()); |
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.
Small note here: at some point there was an idea to limit the usage of the json library as it is quite heavy on the build times. And specifically it seemed possible to make arg.cpp
not depend on it. That's why here we used regexes. There are a few more json
usages in this source file though, and with recent Docker changes, we introduced even more usages, so I guess this is not very realistic to happen.
Noting this in case there is interest to figure out a lighter approach that does not involve parsing json files when downloading files.
* origin/master: (39 commits) ci : disable AMD workflows + update NVIDIA workflows (ggml-org#16200) ci : enable Vulkan workflow on Mac (ggml-org#16194) ggml-cpu: Respect cpumask settings (ggml-org#16164) ggml : fix uninitialized is_on_grid in quantize_row_iq3_xxs_impl (ggml-org#15928) zdnn: refactor codebase + add docs (ggml-org#16178) codeowners : add @danbev to model-conversion example [no ci] (ggml-org#16190) devops: add s390x containers (ggml-org#15915) ggml-cpu : fix typo in gemm comments [no ci] (ggml-org#16189) feat: Add conversion support in GraniteHybrid for non-hybrid (all attn) (ggml-org#16177) clang-tidy : disable warning about performance enum size (ggml-org#16127) ggml : implement set_rows with i32 index (ggml-org#16159) codeowners : update + cleanup (ggml-org#16174) common : enable `--offline` mode without curl support (ggml-org#16137) webui : fix handling incomplete chunks (ggml-org#16107) embedding : fix typos in README (ggml-org#16171) common : remove unused local variables (ggml-org#16140) ggml : extend ggml_can_fuse to work with non-sequential nodes (ggml-org#16123) ggml : add ggml_op_is_empty (ggml-org#16122) codeowners : update ownership for @ngxson and @allozuar (ggml-org#16128) Vulkan: add conv_transpose_2d operation (ggml-org#16022) ...
* common : use the json parser Signed-off-by: Adrien Gallouët <angt@huggingface.co> * common : enable --offline mode without CURL support This change refactors the download logic to properly support offline mode even when the project is built without CURL. Without this commit, using `--offline` would give the following error: error: built without CURL, cannot download model from the internet even if all the files are already cached. Signed-off-by: Adrien Gallouët <angt@huggingface.co> --------- Signed-off-by: Adrien Gallouët <angt@huggingface.co>
* common : use the json parser Signed-off-by: Adrien Gallouët <angt@huggingface.co> * common : enable --offline mode without CURL support This change refactors the download logic to properly support offline mode even when the project is built without CURL. Without this commit, using `--offline` would give the following error: error: built without CURL, cannot download model from the internet even if all the files are already cached. Signed-off-by: Adrien Gallouët <angt@huggingface.co> --------- Signed-off-by: Adrien Gallouët <angt@huggingface.co>
common : enable --offline mode without CURL support
This change refactors the download logic to properly support offline mode even when the project is built without CURL.
Without this commit, using
--offline
would give the following error:even if all the files are already cached.