Skip to content

Commit dc3cfbd

Browse files
authored
Merge pull request #71 from ClipABit/staging
Staging
2 parents 69ff008 + c4bb93c commit dc3cfbd

File tree

4 files changed

+12
-22
lines changed

4 files changed

+12
-22
lines changed

backend/api/server_fastapi_router.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ServerFastAPIRouter:
2020
def __init__(
2121
self,
2222
server_instance,
23-
is_internal_env: bool,
23+
is_file_change_enabled: bool,
2424
environment: str = "dev",
2525
processing_service_cls=None
2626
):
@@ -30,12 +30,12 @@ def __init__(
3030
3131
Args:
3232
server_instance: The Modal server instance for accessing connectors and spawning local methods
33-
is_internal_env: Whether this is an internal (dev/staging) environment
33+
is_file_change_enabled: Whether this file change is enabled in this environment
3434
environment: Environment name (dev, staging, prod) for cross-app lookups
3535
processing_service_cls: Optional ProcessingService class for dev combined mode (direct access)
3636
"""
3737
self.server_instance = server_instance
38-
self.is_internal_env = is_internal_env
38+
self.is_file_change_enabled = is_file_change_enabled
3939
self.environment = environment
4040
self.processing_service_cls = processing_service_cls
4141
self.router = APIRouter()
@@ -211,7 +211,7 @@ async def delete_video(self, hashed_identifier: str, filename: str, namespace: s
211211
- 403 Forbidden if deletion is not allowed.
212212
"""
213213
logger.info(f"[Delete Video] Request to delete video: {filename} ({hashed_identifier}) | namespace='{namespace}'")
214-
if not self.is_internal_env:
214+
if not self.is_file_change_enabled:
215215
raise HTTPException(status_code=403, detail="Video deletion is not allowed in the current environment.")
216216

217217
job_id = str(uuid.uuid4())
@@ -247,7 +247,7 @@ async def clear_cache(self, namespace: str = "__default__"):
247247
HTTPException: If cache clearing is not allowed (403 Forbidden)
248248
"""
249249
logger.info(f"[Clear Cache] Request to clear cache for namespace: {namespace}")
250-
if not self.is_internal_env:
250+
if not self.is_file_change_enabled:
251251
raise HTTPException(status_code=403, detail="Cache clearing is not allowed in the current environment.")
252252

253253
try:

backend/services/http_server.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def _initialize_connectors(self):
3232
R2_ACCOUNT_ID = get_env_var("R2_ACCOUNT_ID")
3333
R2_ACCESS_KEY_ID = get_env_var("R2_ACCESS_KEY_ID")
3434
R2_SECRET_ACCESS_KEY = get_env_var("R2_SECRET_ACCESS_KEY")
35+
IS_FILE_CHANGE_ENABLED = get_env_var("IS_FILE_CHANGE_ENABLED").lower() == "true"
3536

3637
pinecone_index = get_pinecone_index()
3738
logger.info(f"[{self.__class__.__name__}] Using Pinecone index: {pinecone_index}")
@@ -52,7 +53,7 @@ def _initialize_connectors(self):
5253

5354
# Store config for router
5455
self.env = env
55-
self.is_internal = env in ["dev", "staging"]
56+
self.is_file_change_enabled = IS_FILE_CHANGE_ENABLED
5657

5758
logger.info(f"[{self.__class__.__name__}] Initialized and ready!")
5859

@@ -76,7 +77,7 @@ def create_fastapi_app(self, processing_service_cls=None):
7677
self.fastapi_app = FastAPI(title="Clipabit Server")
7778
api_router = ServerFastAPIRouter(
7879
server_instance=self,
79-
is_internal_env=self.is_internal,
80+
is_file_change_enabled=self.is_file_change_enabled,
8081
environment=self.env,
8182
processing_service_cls=processing_service_cls
8283
)

backend/shared/config.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,6 @@ def get_secrets() -> modal.Secret:
8383
return modal.Secret.from_name(env)
8484

8585

86-
def is_internal_env() -> bool:
87-
"""
88-
Check if running in an internal (non-production) environment.
89-
90-
Returns:
91-
bool: True if dev or staging, False if prod
92-
"""
93-
env = get_environment()
94-
return env in ["dev", "staging"]
95-
96-
9786
def get_pinecone_index() -> str:
9887
"""
9988
Get the Pinecone index name for the current environment.

backend/tests/integration/test_api_endpoints.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,23 +185,23 @@ def lookup_side_effect(app_name: str, class_name: str, **kwargs):
185185
@pytest.fixture()
186186
def test_client_internal(mock_modal_lookup) -> Tuple[TestClient, ServerStub, dict]:
187187
"""
188-
FastAPI TestClient with is_internal_env=True, so delete is allowed.
188+
FastAPI TestClient with is_file_change_enabled=True, so delete is allowed.
189189
"""
190190
server = ServerStub()
191191
app = FastAPI()
192-
router = ServerFastAPIRouter(server, is_internal_env=True, environment="dev")
192+
router = ServerFastAPIRouter(server, is_file_change_enabled=True, environment="dev")
193193
app.include_router(router.router)
194194
return TestClient(app), server, mock_modal_lookup
195195

196196

197197
@pytest.fixture()
198198
def test_client_external(mock_modal_lookup) -> Tuple[TestClient, ServerStub, dict]:
199199
"""
200-
FastAPI TestClient with is_internal_env=False, so delete is forbidden.
200+
FastAPI TestClient with is_file_change_enabled=False, so delete is forbidden.
201201
"""
202202
server = ServerStub()
203203
app = FastAPI()
204-
router = ServerFastAPIRouter(server, is_internal_env=False, environment="prod")
204+
router = ServerFastAPIRouter(server, is_file_change_enabled=False, environment="prod")
205205
app.include_router(router.router)
206206
return TestClient(app), server, mock_modal_lookup
207207

0 commit comments

Comments
 (0)