Skip to content

Commit 48acf51

Browse files
aronphilandstuff
andcommitted
Update replicate/client.py
Co-authored-by: Philip Potter <[email protected]>
1 parent 68551cf commit 48acf51

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

replicate/client.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,12 +353,9 @@ def _get_api_token_from_environment() -> Optional[str]:
353353
try:
354354
import cog
355355

356-
if hasattr(cog, "current_scope"):
357-
scope = cog.current_scope()
358-
if scope and hasattr(scope, "context") and isinstance(scope.context, dict):
359-
for key, value in scope.context.items():
360-
if key.upper() == "REPLICATE_API_TOKEN":
361-
return scope.context[key]
356+
for key, value in cog.current_scope().context.items():
357+
if key.upper() == "REPLICATE_API_TOKEN":
358+
return value
362359
except: # noqa: S110,E722,BLE001 we don't want this code to cause clients to fail
363360
pass
364361

0 commit comments

Comments
 (0)