Skip to content

Commit

Permalink
address the comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ninghu committed Jun 12, 2024
1 parent df42791 commit 9a9c191
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/promptflow-devkit/promptflow/_sdk/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def _prepare_home_dir() -> Path:
PF_TRACE_CONTEXT_ATTR = "attributes"
PF_SERVICE_DEBUG = "PF_SERVICE_DEBUG"
PF_SYSTEM_METRICS_PREFIX = "__pf__"
PF_EVAL_BATCH_RUN = "PF_EVAL_BATCH_RUN"

LOCAL_MGMT_DB_PATH = (HOME_PROMPT_FLOW_DIR / "pf.sqlite").resolve()
LOCAL_MGMT_DB_SESSION_ACQUIRE_LOCK_PATH = (HOME_PROMPT_FLOW_DIR / "pf.sqlite.lock").resolve()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
NODE,
NODE_VARIANTS,
NODES,
PF_EVAL_BATCH_RUN,
PROMPT_FLOW_DIR_NAME,
REFRESH_CONNECTIONS_DIR_LOCK_PATH,
REGISTRY_URI_PREFIX,
Expand Down Expand Up @@ -1092,7 +1093,7 @@ def is_local_module(entry_string: str, code: Path) -> bool:


def is_eval_batch_run() -> bool:
return os.environ.get("EVAL_BATCH_RUN", None) == "true"
return os.environ.get(PF_EVAL_BATCH_RUN, None) == "true"


def is_flex_run(run: "Run") -> bool:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------
from .batch_run_context import BatchRunContext
from .code_client import CodeClient
from .proxy_client import ProxyClient
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------
import os

from promptflow._sdk._constants import PF_EVAL_BATCH_RUN
from promptflow._utils.user_agent_utils import ClientUserAgentUtil
from promptflow.tracing._integrations._openai_injector import inject_openai_api, recover_openai_api

Expand All @@ -18,11 +22,11 @@ def __enter__(self):
inject_openai_api()

if isinstance(self.client, ProxyClient):
os.environ["EVAL_BATCH_RUN"] = "true"
os.environ[PF_EVAL_BATCH_RUN] = "true"

def __exit__(self, exc_type, exc_val, exc_tb):
if isinstance(self.client, CodeClient):
recover_openai_api()

if isinstance(self.client, ProxyClient):
os.environ.pop("EVAL_BATCH_RUN", None)
os.environ.pop(PF_EVAL_BATCH_RUN, None)

0 comments on commit 9a9c191

Please sign in to comment.