-
Notifications
You must be signed in to change notification settings - Fork 0
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
Emnlp #7
base: main
Are you sure you want to change the base?
Emnlp #7
Conversation
(we should probably remove this later)
@chrisrytting @alexgshaw I think I've removed everything we wanted gone. |
You’re a git genius
…On Fri, May 19, 2023 at 6:12 PM Vin Howe ***@***.***> wrote:
@chrisrytting <https://github.com/chrisrytting> @alexgshaw
<https://github.com/alexgshaw> I think I've removed everything we wanted
gone.
—
Reply to this email directly, view it on GitHub
<#7 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALIJGOPMBEOL57ZMUYWPI4TXHAD5FANCNFSM6AAAAAAYIJFK5A>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
# TODO: This is not a good way to do logging; we should actually use | ||
# the logging module or something similar. | ||
if self.logger: | ||
self.logger.exception("Rate limited, retrying...") |
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.
logger.exception
is only used to add context to caught exceptions—almost always in an except
block. This isn't even really an error. logger.warning
would probably be more appropriate here.
https://docs.python.org/3/library/logging.html#logging.Logger.exception
# the logging module or something similar. | ||
if self.logger: | ||
self.logger.exception("Rate limited, retrying...") | ||
print("Rate limited, retrying...", file=sys.stderr) |
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.
Everywhere I've seen, logging libraries replace regular print statements. Assuming that there is a logger available isn't an antipattern. Additionally, you could consider doing what projects like FastAPI do and define a global logger instead.
print(e) | ||
if self.logger: | ||
self.logger.exception(e) |
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.
): | ||
self.model_name = model_name | ||
self.state_dict_path = state_dict_path | ||
self.config_path = config_path | ||
self.logger = logger |
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.
if self.logger: | ||
self.logger.exception(e) |
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.
logger = logging.getLogger(__name__) | ||
logger.setLevel(logging.ERROR) | ||
handler = logging.FileHandler(Path(experiment_dir) / "errors.log") | ||
handler.setLevel(logging.ERROR) | ||
formatter = logging.Formatter("%(asctime)s %(message)s") | ||
handler.setFormatter(formatter) | ||
logger.addHandler(handler) | ||
else: | ||
logger = None |
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.
You can configure the global logger instead of passing a logger to every class. Passing a logger to every class feels a little bit like an antipattern.
|
||
self._async_limiter = AsyncLimiter(OPENAI_RPM) | ||
|
||
print(f"Using async {self.engine} engine.") |
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.
logger.info
would be appropriate here
@@ -50,24 +77,52 @@ def send_prompt(self, prompt, n_probs=100, **kwargs): | |||
sorted_logprobs = dict( | |||
sorted(logprobs.items(), key=lambda x: x[1], reverse=True) | |||
) | |||
return sorted_logprobs | |||
raise Exception("testing logging") |
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.
@chrisrytting this should definitely be removed
No description provided.