-
Notifications
You must be signed in to change notification settings - Fork 828
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dev/chenyin_remove_sys_exit
- Loading branch information
Showing
29 changed files
with
371 additions
and
822 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/promptflow-evals/promptflow/evals/evaluate/_batch_run_client/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# --------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# --------------------------------------------------------- | ||
from .batch_run_context import BatchRunContext | ||
from .code_client import CodeClient | ||
from .proxy_client import ProxyClient | ||
|
||
__all__ = ["CodeClient", "ProxyClient", "BatchRunContext"] |
34 changes: 34 additions & 0 deletions
34
src/promptflow-evals/promptflow/evals/evaluate/_batch_run_client/batch_run_context.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# --------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# --------------------------------------------------------- | ||
import os | ||
|
||
from promptflow._sdk._constants import PF_FLOW_ENTRY_IN_TMP, PF_FLOW_META_LOAD_IN_SUBPROCESS | ||
from promptflow._utils.user_agent_utils import ClientUserAgentUtil | ||
from promptflow.tracing._integrations._openai_injector import inject_openai_api, recover_openai_api | ||
|
||
from ..._user_agent import USER_AGENT | ||
from .code_client import CodeClient | ||
from .proxy_client import ProxyClient | ||
|
||
|
||
class BatchRunContext: | ||
def __init__(self, client): | ||
self.client = client | ||
|
||
def __enter__(self): | ||
if isinstance(self.client, CodeClient): | ||
ClientUserAgentUtil.append_user_agent(USER_AGENT) | ||
inject_openai_api() | ||
|
||
if isinstance(self.client, ProxyClient): | ||
os.environ[PF_FLOW_ENTRY_IN_TMP] = "true" | ||
os.environ[PF_FLOW_META_LOAD_IN_SUBPROCESS] = "false" | ||
|
||
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(PF_FLOW_ENTRY_IN_TMP, None) | ||
os.environ.pop(PF_FLOW_META_LOAD_IN_SUBPROCESS, None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.