Add OFFLINE_MODE for air-gapped deployments#2263
Draft
alexnorell wants to merge 1 commit intomainfrom
Draft
Conversation
Adds an OFFLINE_MODE environment variable that disables all outbound network requests to the Roboflow API. Models and workflows load exclusively from local cache. Designed for air-gapped deployments where the inference server has no network access. When OFFLINE_MODE=True: - METRICS_ENABLED, ACTIVE_LEARNING_ENABLED are set to False - DISABLE_VERSION_CHECK is set to True - SINGLE_TENANT_WORKFLOW_CACHE is set to True (drops API key hash from workflow cache filenames) - All Roboflow API calls are blocked at chokepoints - inference_models loads from the models-cache directory - Workflow specs fall back to file cache via existing error handlers - Uncached models/workflows fail immediately with clear errors Bumps inference-models to 0.27.1.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
OFFLINE_MODEenv var that blocks all outbound Roboflow API trafficMETRICS_ENABLED,DISABLE_VERSION_CHECK,ACTIVE_LEARNING_ENABLED,SINGLE_TENANT_WORKFLOW_CACHE) rather than adding a parallel guard system_get_from_url()andpost_to_roboflow_api()for sync requests, individual POST functions for fire-and-forget operations,AutoModel.from_pretrained()andget_model_from_provider()for inference_models model loadingexcept ConnectionErrorhandler naturallyHow it works
Flag composition (
env.py):OFFLINE_MODE=Trueauto-setsMETRICS_ENABLED=False,DISABLE_VERSION_CHECK=True,ACTIVE_LEARNING_ENABLED=False,SINGLE_TENANT_WORKFLOW_CACHE=True.Chokepoint guards (
roboflow_api.py):_get_from_url()raisesConnectionErrorandpost_to_roboflow_api()raisesRoboflowAPIConnectionError, which flow through existing error handlers (e.g.get_workflow_specificationfalls back to file cache without any OFFLINE_MODE-specific code). Fire-and-forget endpoints (image upload, annotation, monitoring) return empty/no-op.Usage tracking:
UsageCollector._offload_to_api()andPlanDetailsfetch/WebRTC lookups short-circuit silently.inference_models:
get_model_from_provider()raisesModelRetrievalError,download_files_to_directory()raisesRuntimeError.AutoModel.from_pretrained()has a dedicatedattempt_loading_model_from_offline_cache()fallback that scans{INFERENCE_HOME}/models-cache/for cached packages. Also handlesRetryError(API unreachable) with the same offline cache fallback even whenOFFLINE_MODEis not set.Customer usage
Test plan
lildc-hardhat/4loaded from cache with--network none, no API key