Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
yifanwu committed Apr 15, 2022
1 parent 5d2f6ff commit 40d2342
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lineapy/graph_reader/apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@
get_slice_graph,
get_source_code_from_graph,
)
from lineapy.utils.analytics import GetCodeEvent, GetValueEvent, track
from lineapy.utils.analytics import (
GetCodeEvent,
GetValueEvent,
GetVersionEvent,
track,
)
from lineapy.utils.constants import VERSION_DATE_STRING, VERSION_PLACEHOLDER

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -49,15 +54,20 @@ class LineaArtifact:
the first time, it will be unset. When you get the artifact or
catalog of artifacts, we retrieve the date from db and
it will be set."""
version: str = field(init=False)
_version: str = field(init=False)
"""version of the artifact - This is set when the artifact is saved. The format of the version currently is specified by the constant :const:`lineapy.utils.constants.VERSION_DATE_STRING`"""

def __post_init__(self):
# this happens at write time
# when the artifact is loaded in from the db, the version is re-set
# in the .get API call.
# TODO: refactor the logic to avoid resetting somewhere else.
self.version = datetime.now().strftime(VERSION_DATE_STRING)
self._version = datetime.now().strftime(VERSION_DATE_STRING)

@property
def version(self) -> str:
track(GetVersionEvent(""))
return self._version

@property
def value(self) -> object:
Expand Down
5 changes: 5 additions & 0 deletions lineapy/utils/analytics/event_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ class GetCodeEvent:
is_session_code: bool


@dataclass
class GetVersionEvent:
dummy_entry: str # just a dummy entry for now


AllEvents = Union[
CatalogEvent,
LibImportEvent,
Expand Down

0 comments on commit 40d2342

Please sign in to comment.