Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions comfy_api/latest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from PIL import Image
from comfy.cli_args import args
import numpy as np
import os


class ComfyAPI_latest(ComfyAPIBase):
Expand All @@ -25,6 +26,7 @@ def __init__(self):
super().__init__()
self.node_replacement = self.NodeReplacement()
self.execution = self.Execution()
self.environment = self.Environment()
self.caching = self.Caching()

class NodeReplacement(ProxiedSingleton):
Expand Down Expand Up @@ -85,6 +87,27 @@ async def set_progress(
image=to_display,
)

class Environment(ProxiedSingleton):
"""
Query the current execution environment.

Managed deployments set the ``COMFY_EXECUTION_ENVIRONMENT`` env var
so custom nodes can adapt their behaviour at runtime.

Example::

from comfy_api.latest import api

env = api.environment.get() # "local" | "cloud" | "remote"
"""

_VALID = {"local", "cloud", "remote"}

async def get(self) -> str:
"""Return the execution environment: ``"local"``, ``"cloud"``, or ``"remote"``."""
value = os.environ.get("COMFY_EXECUTION_ENVIRONMENT", "local").lower().strip()
return value if value in self._VALID else "local"

class Caching(ProxiedSingleton):
"""
External cache provider API for sharing cached node outputs
Expand Down
Loading