mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2025-10-27 08:21:30 +00:00
common : disable progress bar without a tty (#16352)
* common : disable progress bar without a tty Signed-off-by: Adrien Gallouët <angt@huggingface.co> * Add missing headers Signed-off-by: Adrien Gallouët <angt@huggingface.co> --------- Signed-off-by: Adrien Gallouët <angt@huggingface.co>
This commit is contained in:
@@ -54,6 +54,13 @@
|
|||||||
#endif
|
#endif
|
||||||
#define LLAMA_MAX_URL_LENGTH 2084 // Maximum URL Length in Chrome: 2083
|
#define LLAMA_MAX_URL_LENGTH 2084 // Maximum URL Length in Chrome: 2083
|
||||||
|
|
||||||
|
// isatty
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#include <io.h>
|
||||||
|
#else
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
using json = nlohmann::ordered_json;
|
using json = nlohmann::ordered_json;
|
||||||
|
|
||||||
std::initializer_list<enum llama_example> mmproj_examples = {
|
std::initializer_list<enum llama_example> mmproj_examples = {
|
||||||
@@ -100,6 +107,14 @@ static void write_file(const std::string & fname, const std::string & content) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool is_output_a_tty() {
|
||||||
|
#if defined(_WIN32)
|
||||||
|
return _isatty(_fileno(stdout));
|
||||||
|
#else
|
||||||
|
return isatty(1);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
common_arg & common_arg::set_examples(std::initializer_list<enum llama_example> examples) {
|
common_arg & common_arg::set_examples(std::initializer_list<enum llama_example> examples) {
|
||||||
this->examples = std::move(examples);
|
this->examples = std::move(examples);
|
||||||
return *this;
|
return *this;
|
||||||
@@ -652,7 +667,11 @@ static std::string show_masked_url(const common_url & parts) {
|
|||||||
return parts.scheme + "://" + (parts.user.empty() ? "" : "****:****@") + parts.host + parts.path;
|
return parts.scheme + "://" + (parts.user.empty() ? "" : "****:****@") + parts.host + parts.path;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_progress(size_t current, size_t total) { // TODO isatty
|
static void print_progress(size_t current, size_t total) {
|
||||||
|
if (!is_output_a_tty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!total) {
|
if (!total) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user