reload_flag=""
if [[ -n "${DEBUG}" ]]; then
reload_flag="--reload"
fi
if [[ -n "${WORKER_COUNT}" ]]; then
workers=${WORKER_COUNT}
else
workers=2
fi
gunicorn --workers ${workers} \
--bind 0.0.0.0:8000 \
${reload_flag} main.wsgi
Писали такие конструкции чтобы проверить наличие флага и сформировать команду правильно?
На самом деле можно сделать тоже самое проще. Для этого используются операторы условной подстановки, доступные в оболочках семейства POSIX.
:- для установки значений по умолчанию
${WORKER_COUNT:-2}
Если переменная не объявлена, то будет дефолтное значение 2.
:+ подставляет указанный текст, если переменная не пуста
${DEBUG:+--reload}
Если что-то есть в переменной то распечатается текст после символа +, в противном случае - ничего. Удобно для опциональных флагов, как в нашем примере.
Итого наш скрипт может выглядеть так:
gunicorn --workers ${WORKER_COUNT:-2} \
--bind 0.0.0.0:8000 \
${DEBUG:+--reload} main.wsgi
Есть еще два оператора.
:= не только подставить дефолтное значение, но и присвоить его переменной, если она пуста
# никаких переменных еще нет
VAL1=${VAL2:=hello}
# теперь доступны обе
echo $VAL1 $VAL2
# hello hello
:? остановить выполнение с ошибкой, если переменной нет.
echo ${MISS:?is required}
bash: MISS: is required
Код выхода будет 1.
#tricks#linux
🚀 AI TRENDS | Tether Launches QVAC SDK for Cross-Platform AI Development
Tether has introduced the QVAC SDK, a unified software development kit designed to enable developers to build, run, and fine-tune AI applications directly on any device. According to Foresight News, this SDK ensures consistency across different environments.
Applications developed using the QVAC SDK can seamlessly operate on platforms such as iOS, Android, Windows, macOS, and Linux. The same codebase can function across all supported environments without the need for platform-specific branches, rewrites, or conditional logic.
The QVAC SDK is built on QVAC Fabric, a branch of llama.cpp, offering broad compatibility with the llama.cpp model ecosystem for text generation, embedding, and multimodal workloads.
#AI#SDK#CrossPlatform#MachineLearning#LlamaCpp#SoftwareDevelopment#Multimodal#QVAC
#python#agents#generative_ai_tools#llamacpp#llm#onnx#openvino#parsing#retrieval_augmented_generation#small_specialized_models
llmware is a powerful, easy-to-use platform that helps you build AI applications using small, specialized language models designed for business tasks like question-answering, summarization, and data extraction. It supports private, secure deployment on your own machines without needing expensive GPUs, making it cost-effective and safe for enterprise use. You can organize and search your documents, run smart queries, and combine knowledge with AI to get accurate answers quickly. It also offers many ready-to-use models and examples, plus tools for building chatbots and agents that automate complex workflows. This helps you save time, improve accuracy, and securely leverage AI for your business needs[1][3][5].
https://github.com/llmware-ai/llmware