Files
NexQuant/rdagent/log/base.py
T

64 lines
1.5 KiB
Python
Raw Normal View History

2024-07-16 20:35:42 +08:00
from __future__ import annotations
from abc import abstractmethod
from pathlib import Path
class Storage:
"""
Basic storage to support saving objects;
# Usage:
The storage has mainly two kind of users:
- The logging end: you can choose any of the following method to use the object
- We can use it directly with the native logging storage
- We can use it with other logging tools; For example, serve as a handler for loggers
- The view end:
- Mainly for the subclass of `logging.base.View`
- It should provide two kind of ways to provide content
- offline content provision.
- online content preovision.
"""
@abstractmethod
def log(self, obj: object, name: str = "", **kwargs: dict) -> str | Path:
"""
Parameters
----------
obj : object
The object for logging.
name : str
The name of the object. For example "a.b.c"
We may log a lot of objects to a same name
Returns
-------
str | Path
The storage identifier of the object.
"""
...
class View:
"""
Motivation:
Display the content in the storage
"""
2024-07-17 15:00:13 +08:00
2024-07-16 20:35:42 +08:00
# TODO: pleas fix me
@abstractmethod
2024-07-17 15:00:13 +08:00
def display(s: Storage, watch: bool = False):
2024-07-16 20:35:42 +08:00
"""
Parameters
----------
s : Storage
2024-07-17 15:00:13 +08:00
2024-07-16 20:35:42 +08:00
watch : bool
should we watch the new content and display them
"""
2024-07-17 15:00:13 +08:00
...