-
Notifications
You must be signed in to change notification settings - Fork 888
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add possibility to select logging level. #2786
Changes from all commits
74262a1
6f1dd13
38aa901
9b00dc0
c7f08f7
4540d9e
f43302d
e04f9a0
b3a77ec
06f8926
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
from typing import Optional | ||
|
||
from promptflow.client import load_flow | ||
from pathlib import Path | ||
from promptflow.evals._constants import EvaluationMetrics | ||
|
||
|
||
class HateUnfairnessEvaluator: | ||
def __init__(self, project_scope: dict, credential=None): | ||
def __init__(self, project_scope: dict, credential=None, | ||
log_level: Optional[int] = None): | ||
""" | ||
Initialize an evaluator for hate unfairness score. | ||
|
||
|
@@ -13,6 +16,8 @@ def __init__(self, project_scope: dict, credential=None): | |
:type project_scope: dict | ||
:param credential: The credential for connecting to Azure AI project. | ||
:type credential: TokenCredential | ||
:param log_level: The logging level. | ||
:type log_level: Optional[int] | ||
|
||
**Usage** | ||
|
||
|
@@ -28,7 +33,7 @@ def __init__(self, project_scope: dict, credential=None): | |
# Load the flow as function | ||
current_dir = Path(__file__).resolve().parent | ||
flow_dir = current_dir / "flow" | ||
self._flow = load_flow(source=flow_dir) | ||
self._flow = load_flow(source=flow_dir, log_level=log_level) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could we directly set the logger here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or just give user some doc that they can change logging behavior by setting some env variable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The main problem here is that all the log records, the task are not coming from flow itself, it is from invoker/executor infrastructure. flow_logger = get_logger("execution.flow") Another problem is that we initialize the "flowinvoker" logger on flow invoker level, using different mechanism, which will respect self.logger = kwargs.get("logger", LoggerFactory.get_logger("flowinvoker")) So that the logger created/set on the flow level will not have the effect. All |
||
|
||
def __call__(self, *, question: str, answer: str, **kwargs): | ||
"""Evaluates hate unfairness content. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this setting should not be in Flow obj as it's changes static loggers which is not part of flow