Improve docstrings

This commit is contained in:
Andras Schmelczer 2022-07-16 13:53:52 +02:00
parent eb143917be
commit 0dd5b6e8f4
No known key found for this signature in database
GPG key ID: 39260B5B0614A13E
8 changed files with 44 additions and 10 deletions

View file

@ -6,6 +6,15 @@ from ..tracing import TracingContext
def log_metric(argument_name: str, value: Any) -> None:
"""Log a key (argument_name)-value pair that is persisted inside the trace.
The name of the function from where this is called is also stored.
Args:
argument_name: The key for storing the value.
value: Value to log. Must be JSON-serialisable.
"""
tracing_context = TracingContext.get_current_tracing_context()
caller = inspect.stack()[1].function
actual_name = f"metric:{caller}:{argument_name}"

View file

@ -19,6 +19,10 @@ def parameter(
) -> Callable[[F], F]:
"""Control the validation and logging of function parameters.
Basically, a parameter decorator. Unfortunately, Python does not have that concept,
thus, it's a method decorator that expects the name of the to-be-decorated
parameter.
Examples:
>>> @parameter('a')
... def my_function(a: int):
@ -39,7 +43,7 @@ def parameter(
great_ai.errors.argument_validation_error.ArgumentValidationError: ...
Args:
parameter_name: Name of parameter to consider
parameter_name: Name of parameter to consider.
validate: Optional validate to run against the concrete argument.
ArgumentValidationError is thrown when the return value is False.
disable_logging: Do not save the value in any active TracingContext.