Skip to content

Commit

Permalink
fix argument passing for RemoteBox
Browse files Browse the repository at this point in the history
  • Loading branch information
shroominic committed Nov 7, 2024
1 parent aa3f6d2 commit a55d0e4
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/codeboxapi/codebox.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,17 @@


class CodeBox:
def __new__(
cls,
session_id: t.Optional[str] = None,
api_key: t.Optional[t.Union[str, t.Literal["local", "docker"]]] = None,
factory_id: t.Optional[t.Union[str, t.Literal["default"]]] = None,
) -> "CodeBox":
def __new__(cls, *args, **kwargs) -> "CodeBox":
"""
Creates a CodeBox session
"""
api_key = api_key or os.getenv("CODEBOX_API_KEY", "local")
factory_id = factory_id or os.getenv("CODEBOX_FACTORY_ID", "default")
api_key = kwargs.get("api_key") or os.getenv("CODEBOX_API_KEY", "local")
if api_key == "local":
return import_module("codeboxapi.local").LocalBox()
return import_module("codeboxapi.local").LocalBox(*args, **kwargs)

if api_key == "docker":
return import_module("codeboxapi.docker").DockerBox()
return import_module("codeboxapi.remote").RemoteBox()
return import_module("codeboxapi.docker").DockerBox(*args, **kwargs)
return import_module("codeboxapi.remote").RemoteBox(*args, **kwargs)

def __init__(
self,
Expand Down

0 comments on commit a55d0e4

Please sign in to comment.