@@ -50,14 +50,15 @@ class Project(DirNamesMixin):
5050 Otherwise, the project is configured to the ``local`` mode to be persisted on
5151 the user machine in a directory called ``workspace``.
5252
53- The workspace can be shared between all the projects.
54- The workspace can be set using kwargs or the envar ``SKORE_WORKSPACE``.
55- If not, it will be by default set to a ``skore/`` directory in the USER
56- cache directory:
53+ | The workspace can be shared between all the projects.
54+ | The workspace can be set using kwargs or the environment variable
55+ ``SKORE_WORKSPACE``.
56+ | If not, it will be by default set to a ``skore/`` directory in the USER
57+ cache directory:
5758
58- - in Windows, usually ``C:\Users\%USER%\AppData\Local\skore``,
59- - in Linux, usually ``${HOME}/.cache/skore``,
60- - in macOS, usually ``${HOME}/Library/Caches/skore``.
59+ - on Windows, usually ``C:\Users\%USER%\AppData\Local\skore``,
60+ - on Linux, usually ``${HOME}/.cache/skore``,
61+ - on macOS, usually ``${HOME}/Library/Caches/skore``.
6162
6263 Refer to the :ref:`project` section of the user guide for more details.
6364
@@ -76,14 +77,15 @@ class Project(DirNamesMixin):
7677 workspace : Path, mode:local only.
7778 The directory where the local project is persisted.
7879
79- The workspace can be shared between all the projects.
80- The workspace can be set using kwargs or the envar ``SKORE_WORKSPACE``.
81- If not, it will be by default set to a ``skore/`` directory in the USER
82- cache directory:
80+ | The workspace can be shared between all the projects.
81+ | The workspace can be set using kwargs or the environment variable
82+ ``SKORE_WORKSPACE``.
83+ | If not, it will be by default set to a ``skore/`` directory in the USER
84+ cache directory:
8385
84- - in Windows, usually ``C:\Users\%USER%\AppData\Local\skore``,
85- - in Linux, usually ``${HOME}/.cache/skore``,
86- - in macOS, usually ``${HOME}/Library/Caches/skore``.
86+ - on Windows, usually ``C:\Users\%USER%\AppData\Local\skore``,
87+ - on Linux, usually ``${HOME}/.cache/skore``,
88+ - on macOS, usually ``${HOME}/Library/Caches/skore``.
8789
8890 Attributes
8991 ----------
@@ -149,32 +151,67 @@ class Project(DirNamesMixin):
149151 """
150152
151153 __HUB_NAME_PATTERN = re .compile (r"hub://(?P<tenant>[^/]+)/(?P<name>.+)" )
154+
152155 reports : _ReportsAccessor
153156 _Project__project : Any
154157 _Project__mode : str
155158 _Project__name : str
156159
157- def __init__ (self , name : str , ** kwargs ):
160+ @staticmethod
161+ def __setup_plugin (name : str ) -> tuple [str , str , Any , dict ]:
158162 if not (PLUGINS := entry_points (group = "skore.plugins.project" )):
159163 raise SystemError ("No project plugin found, please install at least one." )
160164
161- if match := re .match (self .__HUB_NAME_PATTERN , name ):
165+ if match := re .match (Project .__HUB_NAME_PATTERN , name ):
162166 mode = "hub"
163167 name = match ["name" ]
164- kwargs | = {"tenant" : match ["tenant" ], "name" : name }
168+ parameters = {"tenant" : match ["tenant" ], "name" : name }
165169 else :
166170 mode = "local"
167- kwargs | = {"name" : name }
171+ parameters = {"name" : name }
168172
169173 if mode not in PLUGINS .names :
170174 raise ValueError (
171175 f"Unknown mode `{ mode } `. "
172176 f"Please install the `skore-{ mode } -project` python package."
173177 )
174178
179+ return mode , name , PLUGINS [mode ].load (), parameters
180+
181+ def __init__ (self , name : str , ** kwargs ):
182+ r"""
183+ Initialize a project.
184+
185+ Parameters
186+ ----------
187+ name : str
188+ The name of the project:
189+
190+ - if the ``name`` takes the form of the URI ``hub://<tenant>/<name>``, the
191+ project is configured to communicate with the ``skore hub``,
192+ - otherwise, the project is configured to communicate with a local storage,
193+ on the user machine.
194+ **kwargs : dict
195+ Extra keyword arguments passed to the project, depending on its mode.
196+
197+ workspace : Path, mode:local only.
198+ The directory where the local project is persisted.
199+
200+ | The workspace can be shared between all the projects.
201+ | The workspace can be set using kwargs or the environment variable
202+ ``SKORE_WORKSPACE``.
203+ | If not, it will be by default set to a ``skore/`` directory in the
204+ USER cache directory:
205+
206+ - on Windows, usually ``C:\Users\%USER%\AppData\Local\skore``,
207+ - on Linux, usually ``${HOME}/.cache/skore``,
208+ - on macOS, usually ``${HOME}/Library/Caches/skore``.
209+ """
210+ mode , name , plugin , parameters = Project .__setup_plugin (name )
211+
175212 self .__mode = mode
176213 self .__name = name
177- self .__project = PLUGINS [ mode ]. load ()( ** kwargs )
214+ self .__project = plugin ( ** ( kwargs | parameters ) )
178215
179216 @property
180217 def mode (self ):
@@ -218,5 +255,39 @@ def put(self, key: str, report: EstimatorReport):
218255 def __repr__ (self ) -> str : # noqa: D105
219256 return self .__project .__repr__ ()
220257
258+ @staticmethod
259+ def delete (name : str , ** kwargs ):
260+ r"""
261+ Delete a project.
262+
263+ Parameters
264+ ----------
265+ name : str
266+ The name of the project:
267+
268+ - if the ``name`` takes the form of the URI ``hub://<tenant>/<name>``, the
269+ project is configured to communicate with the ``skore hub``,
270+ - otherwise, the project is configured to communicate with a local storage,
271+ on the user machine.
272+ **kwargs : dict
273+ Extra keyword arguments passed to the project, depending on its mode.
274+
275+ workspace : Path, mode:local only.
276+ The directory where the local project is persisted.
277+
278+ | The workspace can be shared between all the projects.
279+ | The workspace can be set using kwargs or the environment variable
280+ ``SKORE_WORKSPACE``.
281+ | If not, it will be by default set to a ``skore/`` directory in the
282+ USER cache directory:
283+
284+ - on Windows, usually ``C:\Users\%USER%\AppData\Local\skore``,
285+ - on Linux, usually ``${HOME}/.cache/skore``,
286+ - on macOS, usually ``${HOME}/Library/Caches/skore``.
287+ """
288+ _ , _ , plugin , parameters = Project .__setup_plugin (name )
289+
290+ return plugin .delete (** (kwargs | parameters ))
291+
221292
222293_register_accessor ("reports" , Project )(_ReportsAccessor )
0 commit comments