-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Project API #303
Comments
remaining TODO:
|
This is the case of every kind of items, they are all eventually serialized as bytes: JSON, Media or scikit-learn models. |
@tuscland isn't this question (storing the content of an item as bytes or str) just a implementation detail ? |
Writing the docs for this, I am wondering two things:
project.put_item(
"my_string",
MediaItem.factory("<p><h1>Hello</h1></p>", media_type="text/html"),
) But when I wrote the docs, I often accidentally wrote @tuscland What do you think? Should we do this before this gets merged? |
Project Class
Methods
put(key: str, value: Any) -> None
key
: The identifier for the item.value
: The value to store. The appropriate Item subclass will be used based on the value type.put_item(key: str, item: Item) -> None
key
: The identifier for the item.item
: An instance of an Item subclass.get(key: str) -> Any
key
: The identifier of the item to retrieve.get_item(key: str) -> Item
key
: The identifier of the item to retrieve.list_keys() -> List[str]
delete_item(key: str) -> None
key
: The identifier of the item to remove.Notes
put()
method automatically selects the appropriate Item subclass based on the input value type.get()
method returns the value of the item, whileget_item()
returns the Item instance itself.Item Class Hierarchy
Base Class: Item
Abstract base class for all item types.
Subclasses
Item Type Mapping
The following table shows how different input value types provided to the
add()
function correspond to specific Item types:str
int
float
bool
list
dict
pandas.DataFrame
polars.DataFrame
numpy.ndarray
matplotlib.figure.Figure
PIL.Image.Image
altair.Chart
bytes
+ media typestr
+ media typeNote: When adding a MediaItem with raw bytes or string data, you need to specify the media type explicitly using the
add_item()
method instead ofadd()
.Usage Examples
The text was updated successfully, but these errors were encountered: