Project#
- class skore.Project(path='project.skore', *, if_exists='raise')[source]#
- A collection of items persisted in a storage. - This constructor initializes a project, by creating a new project or by loading an existing one. - The class main methods are - put()and- get(), respectively to insert a key-value pair into the Project and to recover the value associated with a key.- You can add any type of objects. In some cases, especially on classes you defined, the persistency is based on the pickle representation. You must therefore ensure that the call to - get()is made in the same environment as- put().- Parameters:
- pathstr or Path, default=”./project.skore”
- The path of the project to initialize. 
- if_exists: Literal[“raise”, “load”], default=”raise”
- What to do if the project already exists. 
 
- Attributes:
- pathPath
- The unified path of the project. 
- namestr
- The name of the project. Corresponds to - path.name.
 
 - Examples - >>> # xdoctest: +SKIP >>> import skore >>> project = skore.Project("my-xp") >>> project.put("score", 1.0) >>> project.get("score") 1.0 - clear(delete_project=False)[source]#
- Remove all items from the project. - Warning - Clearing the project with - delete_project=Truewill invalidate the whole- Projectinstance, making it unusable. A new Project instance can be created using the- skore.Projectconstructor.- Parameters:
- delete_projectbool, default=False
- If set, the project will be deleted entirely. 
 
 
 - delete(key)[source]#
- Delete the item corresponding to - keyfrom the Project.- Parameters:
- keystr
- The key corresponding to the item to delete. 
 
- Raises:
- KeyError
- If the key does not correspond to any item. 
 
 
 - delete_note(key, *, version=-1)[source]#
- Delete a note previously attached to key - key.- If no note is attached, does nothing. - Parameters:
- keystr
- The key of the annotated item. May be qualified with a version number through the - versionargument.
- versionint, default=-1
- The version of the annotated key. Default is the latest version. 
 
- Raises:
- KeyError
- If the - (key, version)couple does not exist.
 
 - Examples - >>> # xdoctest: +SKIP >>> # Delete note attached to latest version of key "key" >>> project.delete_note("key") >>> # Delete note attached to first version of key "key" >>> project.delete_note("key", version=0) 
 - get(key, *, version=-1, metadata=False)[source]#
- Get the value associated to - keyfrom the Project.- Parameters:
- keystr
- The key corresponding to the item to get. 
- versionUnion[Literal[-1, “all”], int], default=-1
- If -1, get the latest value associated to - key. If “all”, get all the values associated to- key. If instance of int, get the nth value associated to- key.
- metadatabool, default=False
- If True, get the metadata in addition to the value. 
 
- Returns:
- valueany
- Value associated to - key, when latest=True and metadata=False.
- value_and_metadatadict
- Value associated to - keywith its metadata, when latest=True and metadata=True.
- list_of_valueslist[any]
- Values associated to - key, ordered by date, when latest=False.
- list_of_values_and_metadatalist[dict]
- Values associated to - keywith their metadata, ordered by date, when latest=False and metadata=False.
 
- Raises:
- KeyError
- If the key is not in the project. 
 
 
 - get_note(key, *, version=-1)[source]#
- Retrieve a note previously attached to key - key.- Parameters:
- keystr
- The key of the annotated item. May be qualified with a version number through the - versionargument.
- versionint, default=-1
- The version of the annotated key. Default is the latest version. 
 
- Returns:
- The attached note, or None if no note is attached.
 
- Raises:
- KeyError
- If the - (key, version)couple does not exist.
 
 - Examples - >>> # xdoctest: +SKIP >>> # Retrieve note attached to latest version of key "key" >>> project.get_note("key") >>> # Retrieve note attached to first version of key "key" >>> project.get_note("key", version=0) 
 - put(key, value, *, note=None, display_as=None)[source]#
- Add a key-value pair to the Project. - If an item with the same key already exists, its value is replaced by the new one. - Parameters:
- keystr
- The key to associate with - valuein the Project.
- valueAny
- The value to associate with - keyin the Project.
- notestr, optional
- A note to attach with the item. 
- display_as{“HTML”, “MARKDOWN”, “SVG”}, optional
- Used in combination with a string value, it customizes the way the value is displayed in the interface. 
 
- Raises:
- TypeError
- If the combination of parameters are not valid. 
- NotImplementedError
- If the value type is not supported. 
 
 
 - set_note(key, note, *, version=-1)[source]#
- Attach a note to key - key.- Parameters:
- keystr
- The key of the item to annotate. May be qualified with a version number through the - versionargument.
- notestr
- The note to be attached. 
- versionint, default=-1
- The version of the key to annotate. Default is the latest version. 
 
- Raises:
- KeyError
- If the - (key, version)couple does not exist.
- TypeError
- If - keyor- noteis not a string.
 
 - Examples - >>> # xdoctest: +SKIP >>> # Annotate latest version of key "key" >>> project.set_note("key", "note") >>> # Annotate first version of key "key" >>> project.set_note("key", "note", version=0) 
 
 
 
 
 
