Skip to content

Commit adb4fa7

Browse files
committed
Remove top-level restrictions
1 parent 57bab3e commit adb4fa7

File tree

1 file changed

+0
-37
lines changed

1 file changed

+0
-37
lines changed

replicate/use.py

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -41,38 +41,6 @@
4141
__all__ = ["use", "get_path_url"]
4242

4343

44-
def _in_repl() -> bool:
45-
return bool(
46-
sys.flags.interactive # python -i
47-
or hasattr(sys, "ps1") # prompt strings exist
48-
or (
49-
sys.stdin.isatty() # tty
50-
and sys.stdout.isatty()
51-
)
52-
or ("get_ipython" in globals())
53-
)
54-
55-
56-
def _in_module_scope() -> bool:
57-
"""
58-
Returns True when called from top level module scope.
59-
"""
60-
if os.getenv("REPLICATE_ALWAYS_ALLOW_USE"):
61-
return True
62-
63-
# If we're running in a REPL.
64-
if _in_repl():
65-
return True
66-
67-
if frame := inspect.currentframe():
68-
print(frame)
69-
if caller := frame.f_back:
70-
print(caller.f_code.co_name)
71-
return caller.f_code.co_name == "<module>"
72-
73-
return False
74-
75-
7644
def _has_concatenate_iterator_output_type(openapi_schema: dict) -> bool:
7745
"""
7846
Returns true if the model output type is ConcatenateIterator or
@@ -767,17 +735,12 @@ def use(
767735
"""
768736
Use a Replicate model as a function.
769737
770-
This function can only be called at the top level of a module.
771-
772738
Example:
773739
774740
flux_dev = replicate.use("black-forest-labs/flux-dev")
775741
output = flux_dev(prompt="make me a sandwich")
776742
777743
"""
778-
if not _in_module_scope():
779-
raise RuntimeError("You may only call replicate.use() at the top level.")
780-
781744
try:
782745
ref = ref.name # type: ignore
783746
except AttributeError:

0 commit comments

Comments
 (0)