Skip to content

Commit

Permalink
mob next [ci-skip] [ci skip] [skip ci]
Browse files Browse the repository at this point in the history
lastFile:src/skore/project.py
  • Loading branch information
augustebaum committed Sep 6, 2024
1 parent e5c1489 commit 6fcb488
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 29 deletions.
58 changes: 29 additions & 29 deletions src/skore/project.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
""""""

import abc
import json
from abc import abstractmethod
from pathlib import Path
from typing import Any, List

Expand All @@ -9,22 +11,23 @@ def get_filepath_from_project_name(project_name) -> Path:
return None


class Item:
class Item(abc.ABC):
"""An item in the project."""

@property
def raw():
...
@abstractmethod
def raw(): ...

@property
def transformed():
...
@abstractmethod
def transformed(): ...

def to_json() -> str:
...
@abstractmethod
def to_json() -> str: ...

@abstractmethod
def from_json(string: str): ...

def from_json(string:str):
...

class JSONItem(Item):
"""An item that is a JSON serializable Python object."""
Expand All @@ -34,44 +37,45 @@ def __init__(self, value):

# to do cache
@property
def raw():
def raw(self):
return self.raw

# to do cache
@property
def transformed():
def transformed(self):
return json.dumps(self.raw)



class DataFrameItem(Item):
"""An item that is a pandas or polars data frame."""

def __init__(self, value):
self.raw = value
self.__transformed = value.to_json(orient="split")

@property
def raw():
raise NotImplementedError
def raw(self):...
# return self.__raw

@property
def transformed():
return json.dumps(self.raw)
def transformed(self):
return self.__transformed

def from_json(string): ...

def to_json(string): ...


class NumpyArrayItem(Item):
@property
def raw():
...
def raw(self): ...

@property
def transformed():
...

def to_json():
...
def transformed(self): ...

def from_json():
...
def to_json(self): ...

def from_json(self): ...


class MediaItem(Item):
Expand All @@ -84,10 +88,6 @@ class ScikitLearnModelItem(Item):
def __init__(self, value):
self.value = value

@staticmethod
def transform(value):
return html


class Transformer:
@staticmethod
Expand Down
10 changes: 10 additions & 0 deletions tests/test_dataframe_item.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import pandas as pd
from skore.project import DataFrameItem


def test_dataframe_item():
df = pd.DataFrame([[1, 2, 3], [4, 5, 6]])
item = DataFrameItem(df)

assert item.raw == df
assert item.transformed == None

0 comments on commit 6fcb488

Please sign in to comment.