skore
.Project#
Usage examples at the bottom of this page.
- class skore.Project(item_repository: ItemRepository, view_repository: ViewRepository)#
A project is a collection of items that are stored in a storage.
- delete_item(key: str)#
Delete the item corresponding to
key
from the Project.- Parameters:
- keystr
The key corresponding to the item to delete.
- Raises:
- KeyError
If the key does not correspond to any item.
- delete_view(key: str)#
Delete the view corresponding to
key
from the Project.- Parameters:
- keystr
The key corresponding to the view to delete.
- Raises:
- KeyError
If the key does not correspond to any view.
- get(key: str) Any #
Get the value corresponding to
key
from the Project.- Parameters:
- keystr
The key corresponding to the item to get.
- Raises:
- KeyError
If the key does not correspond to any item.
- get_item(key: str) Item #
Get the item corresponding to
key
from the Project.- Parameters:
- key: str
The key corresponding to the item to get.
- Returns:
- itemItem
The Item corresponding to key
key
.
- Raises:
- KeyError
If the key does not correspond to any item.
- get_item_versions(key: str) list[Item] #
Get all the versions of an item associated with
key
from the Project.The list is ordered from oldest to newest “put” date.
- Parameters:
- keystr
The key corresponding to the item to get.
- Returns:
- list[Item]
The list of items corresponding to key
key
.
- Raises:
- KeyError
If the key does not correspond to any item.
- get_view(key: str) View #
Get the view corresponding to
key
from the Project.- Parameters:
- keystr
The key of the item to get.
- Returns:
- View
The view corresponding to
key
.
- Raises:
- KeyError
If the key does not correspond to any view.
- list_item_keys() list[str] #
List all item keys in the Project.
- Returns:
- list[str]
The list of item keys. The list is empty if there is no item.
- list_view_keys() list[str] #
List all view keys in the Project.
- Returns:
- list[str]
The list of view keys. The list is empty if there is no view.
- put(key: str | dict[str, Any], value: Any | None = None)#
Add one or more key-value pairs to the Project.
If
key
is a string, then put adds the singlekey
-value
pair mapping to the Project. Ifkey
is a dict, it is interpreted as multiple key-value pairs to add to the Project. If an item with the same key already exists, its value is replaced by the new one.The dict format is the same as equivalent to running
put()
for each individual key-value pair. In other words,project.put({"hello": 1, "goodbye": 2})
is equivalent to
project.put("hello", 1) project.put("goodbye", 2)
In particular, this means that if some key-value pair is invalid (e.g. if a key is not a string, or a value’s type is not supported), then all the key-value pairs up to the first offending key-value pair will be successfully inserted, and then an error will be raised.
- Parameters:
- keystr | dict[str, Any]
The key to associate with
value
in the Project, or dict of key-value pairs to add to the Project.- valueAny, optional
The value to associate with
key
in the Project. Ifkey
is a dict, this argument is ignored.
- Raises:
- ProjectPutError
If the key-value pair(s) cannot be saved properly.
- put_item(key: str, item: Item)#
Add an Item to the Project.
- put_one(key: str, value: Any)#
Add a key-value pair to the Project.
- Parameters:
- keystr
The key to associate with
value
in the Project. Must be a string.- valueAny
The value to associate with
key
in the Project.
- Raises:
- ProjectPutError
If the key-value pair cannot be saved properly.
- put_view(key: str, view: View)#
Add a view to the Project.