-
Notifications
You must be signed in to change notification settings - Fork 561
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inject an internal
_emit_metric
method into predictor classes
We use metrics internally to transport metadata about how the model ran out of the model. It's private because it's entirely invisible within our system and we make no claims of stability for how it works.
- Loading branch information
Showing
7 changed files
with
124 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from typing import Any, Optional, Union | ||
|
||
from cog.base_predictor import BasePredictor | ||
from cog.types import File as CogFile | ||
from cog.types import Path as CogPath | ||
|
||
|
||
class Predictor(BasePredictor): | ||
def setup(self, weights: Optional[Union[CogFile, CogPath, str]] = None): | ||
print("did setup") | ||
|
||
def predict(self, *, name: str, **kwargs: Any) -> str: # pylint: disable=arguments-differ | ||
print(f"hello, {name}") | ||
|
||
assert self._emit_metric | ||
self._emit_metric("foo", 123) | ||
|
||
return f"hello, {name}" |
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