@@ -290,19 +290,34 @@ def get_job(self, job_id: str) -> AsyncJob:
290
290
)
291
291
return AsyncJob .from_json (payload = payload , client = self )
292
292
293
- def get_model (self , model_id : str ) -> Model :
293
+ def get_model (
294
+ self , model_id : str = None , model_run_id : str = None
295
+ ) -> Model :
294
296
"""Fetches a model by its ID.
295
297
296
298
Parameters:
297
- model_id: Nucleus-generated model ID (starts with ``prj_``). This can
298
- be retrieved via :meth:`list_models` or a Nucleus dashboard URL.
299
+ model_id: You can pass either a model ID (starts with ``prj_``) or a model run id (starts with ``run_``) This can
300
+ be retrieved via :meth:`list_models` or a Nucleus dashboard URL. Model run ids result from the application of a model to a dataset.
301
+ model_run_id: You can pass either a model ID (starts with ``prj_``), or a model run id (starts with ``run_``) This can
302
+ be retrieved via :meth:`list_models` or a Nucleus dashboard URL. Model run ids result from the application of a model to a dataset.
303
+
304
+ In the future, we plan to hide model_run_ids fully from users.
299
305
300
306
Returns:
301
307
:class:`Model`: The Nucleus model as an object.
302
308
"""
309
+ if model_id is None and model_run_id is None :
310
+ raise ValueError ("Must pass either a model_id or a model_run_id" )
311
+ if model_id is not None and model_run_id is not None :
312
+ raise ValueError ("Must pass either a model_id or a model_run_id" )
313
+
314
+ model_or_model_run_id = (
315
+ model_id if model_id is not None else model_run_id
316
+ )
317
+
303
318
payload = self .make_request (
304
319
payload = {},
305
- route = f"model/{ model_id } " ,
320
+ route = f"model/{ model_or_model_run_id } " ,
306
321
requests_command = requests .get ,
307
322
)
308
323
return Model .from_json (payload = payload , client = self )
0 commit comments