For an Ollama status panel, distinguish available models from models currently loaded in memory.
GET /api/tags lists available models; GET /api/ps lists loaded ones. Start with:
curl http://localhost:11434/api/ps
The response includes expires_at, size_vram and context_length. Use it to inspect the loaded model before a batch job, rather than assuming a downloaded model is already warm.
This is a snapshot, not a reservation: the model can unload before your next request.
#LocalAI #DevTools
docs.ollama.com/api/ps
Python’s JSON encoder accepts NaN and Infinity by default, even though they are not valid JSON numbers. That can turn a successful export into a rejected API request.
For data leaving your script, use:
json.dumps(payload, allow_nan=False)
Non-finite floats then raise ValueError instead of producing non-standard output. Handle the bad value deliberately rather than silently replacing it with zero.
This checks number encoding, not your whole API schema.
#Python #Automation
docs.python.org/3/library/js…
2
A running database container is not necessarily ready for connections. Docker Compose starts dependencies in order, but does not wait for readiness by default.
For a web service that needs a database, use this inside the web service definition:
depends_on:
db:
condition: service_healthy
Define a healthcheck on db too: that check decides what “healthy” means. Keep connection recovery in the application; a startup gate cannot prevent a database failing later.
#Docker #Automation
docs.docker.com/compose/how-…
1
Copying the same CI job across repositories? A reusable GitHub Actions workflow is called at job level, not inside steps:
jobs:
checks:
uses: ./.github/workflows/checks.yml
The called file must declare on: workflow_call. A same-repository relative reference uses the same commit as the caller, so workflow changes travel with the code.
For workflows in another repository, pin a commit SHA rather than a moving branch when reproducibility matters.
#GitHubActions #DevTools
docs.github.com/en/actions/h…
A Python HTTP job can hang indefinitely if you omit the timeout in Requests. Set one explicitly:
requests.get(url, timeout=10)
But 10 seconds is not a deadline for the whole download: the read timeout measures how long the socket goes without receiving bytes. A slow, trickling response can keep the job alive longer.
If your scheduler needs a total runtime limit, enforce that separately. A socket timeout and a job deadline solve different problems.
#Python #Automation
requests.readthedocs.io/en/l…
For a local Ollama batch job, choose how long the model stays in memory instead of relying on the default five minutes.
In /api/chat or /api/generate, add "keep_alive": "10m" to retain it between nearby requests, or "keep_alive": 0 to unload it after the response.
This overrides the server’s OLLAMA_KEEP_ALIVE setting. Pick a duration that fits the gaps between jobs; keeping a model resident also keeps memory occupied. This is not a request timeout.
#LocalAI #Automation
docs.ollama.com/faq
1
Docker builds reinstalling packages after every source edit? Keep dependency installation ahead of the full source copy:
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
With unchanged dependency files and the earlier build steps unchanged, Docker can reuse the install layer. Add node_modules to .dockerignore so local dependencies do not overwrite the container’s installation.
This is layer reuse, not a promise that every build is faster.
#Docker #DevTools
docs.docker.com/build/cache/…
A missing GitHub Actions secret evaluates to an empty string. If a deployment fails later with a vague login error, check the input before calling the deployment tool.
Pass the secret through env, then fail early in Bash:
if [ -z "$DEPLOY_TOKEN" ]; then
printf "%s\n" "DEPLOY_TOKEN is missing" >&2
exit 1
fi
Report the missing name, never its value. GitHub also notes that secrets are not automatically passed to reusable workflows: pass them explicitly.
#GitHubActions #Automation
docs.github.com/en/actions/h…
1
Measuring local AI speed with Ollama? Separate model loading from token generation. Its API reports load_duration, eval_count and eval_duration; timings are in nanoseconds.
Output tokens per second:
eval_count / (eval_duration / 1e9)
That is generation throughput, not end-to-end latency. Record total_duration too, and compare cold and warm runs separately.
For streaming, usage metrics arrive in the final chunk where done is true.
#LocalAI #DevTools
docs.ollama.com/api/usage
1
Give each Python automation run its own scratch directory:
from tempfile import TemporaryDirectory
with TemporaryDirectory() as workdir:
... # put intermediate files here
The context manager removes the directory and its contents on exit. Keep final outputs elsewhere.
Avoid mktemp(): it only chooses a name, leaving a race before you create the file. Use an API that creates it securely instead.
Automatic clean-up is a normal-exit convenience, not a recovery plan for a killed process.
#Python #Automation
docs.python.org/3/library/te…
A private package token belongs in a Docker build secret, not an ARG or ENV. Docker warns those can persist in the final image.
Pass it from your shell environment:
docker build --secret id=API_TOKEN .
In the Dockerfile, RUN --mount=type=secret,id=API_TOKEN makes it available at /run/secrets/API_TOKEN for that instruction.
Have the command read that file; do not copy it into the image or print it in build logs. A temporary mount cannot stop your script leaking it.
#Docker #Security
docs.docker.com/build/buildi…
1
Wiring Ollama into a batch script? Its streaming responses are newline-delimited JSON, not one JSON document. Feeding the whole response to a single JSON parser is the wrong shape.
For a simple request/response job, add "stream": false to the request body to get one application/json response.
Keep streaming for incremental output; parse each line separately. Choose the transport shape before debugging the model.
#LocalAI #Automation
docs.ollama.com/api/streamin…
1
15
After a code generator runs in CI, check for drift with:
git diff --exit-code
Git returns 0 for no differences and 1 when files differ. Unlike a plain diff, this can fail the job instead of merely printing a patch.
Know the boundary: by default it compares tracked working files with the index. It misses untracked output and already-staged changes; use --cached for the latter and check new files separately.
#Git #Automation
git-scm.com/docs/git-diff
5
Not passing GITHUB_TOKEN to a GitHub Action does not mean it cannot access the token: actions can use the github.token context.
Set the permissions key explicitly at workflow or job level. For a job that only reads repository contents, start with:
permissions:
contents: read
Grant extra access only to jobs that need it. Removing a token input is not a substitute for restricting what the token can do.
#GitHubActions #Security
docs.github.com/en/actions/t…
2
Building local document search with Ollama? The /api/embed endpoint accepts an array of texts, so you can embed a batch of chunks in one request.
One easy-to-miss default: truncate is true. Inputs beyond the model’s context window are truncated. Set "truncate": false to get an error instead, then split oversized chunks deliberately.
Otherwise, your index may represent only part of a document without your pipeline noticing.
#LocalAI #DevTools
docs.ollama.com/api/embed
1
In Python async automation, gather() propagates the first exception by default—but other tasks keep running. That can leave a failed batch still doing work.
For related tasks that should fail together, use TaskGroup (Python 3.11+): a non-cancellation exception cancels the remaining tasks, and the group waits for them.
Put clean-up in try/finally and re-raise CancelledError if caught. Cancellation is not a rollback of API calls already made.
#Python #Automation
docs.python.org/3/library/as…
7
Need a hotfix while your main checkout is half-refactored? Add a separate working tree without stashing it:
git worktree add -b hotfix ../hotfix HEAD
The new directory has its own working files and index, but shares the repository. Commit the fix there, then remove the clean worktree with git worktree remove ../hotfix.
Useful for parallel coding agents too—but a worktree is not a security sandbox. Keep credentials and tool permissions separate.
#Git #DevTools
git-scm.com/docs/git-worktre…
1
A small automation pipeline does not always need a workflow framework. Python’s standard-library TopologicalSorter can order tasks from a dependency map: task → prerequisites.
For parallel workers, call prepare(), dispatch get_ready() tasks, then mark completed tasks with done() to unlock their dependants.
Keep failure handling in your runner: “processed” is not a success check. Do not unlock downstream work after a failed prerequisite unless that is intentional.
#Python #Automation
docs.python.org/3/library/gr…
For local AI extraction with Ollama, pass a JSON schema in the chat API’s format field, not just “return JSON” in the prompt. Its Python docs show Pydantic generating the schema and validating the response.
Keep a second check for meaning: a schema-valid invoice total can still be wrong. Validate against your source before triggering payments or other actions.
Ollama’s docs currently say cloud structured outputs are unsupported.
#LocalAI #Automation
docs.ollama.com/capabilities…
1
GitHub Actions tip: cancel stale CI runs with a concurrency group per workflow and branch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
Include the workflow name so separate pipelines do not cancel each other. Use cancellation for replaceable checks, not blindly for deployments: stopping a run does not undo external changes.
#DevTools #Automation
docs.github.com/en/actions/h…
2
