Skip to content

Commit 4ce3fcf

Browse files
committed
updated restore method and model catalog doc
1 parent 4acfcd4 commit 4ce3fcf

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

ads/model/datascience_model.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,19 +1393,16 @@ def _remove_file_description_artifact(self):
13931393
if self.local_copy_dir:
13941394
shutil.rmtree(self.local_copy_dir, ignore_errors=True)
13951395

1396-
@classmethod
13971396
def restore_model(
1398-
cls,
1399-
model_id: str,
1397+
self,
14001398
restore_model_for_hours_specified: Optional[int] = None,
1401-
):
1399+
) -> None:
14021400
"""
14031401
Restore archived model artifact.
14041402
14051403
Parameters
14061404
----------
1407-
model_id : str
1408-
The `OCID` of the model to be restored.
1405+
14091406
restore_model_for_hours_specified : Optional[int]
14101407
Duration in hours for which the archived model is available for access.
14111408
@@ -1419,8 +1416,11 @@ def restore_model(
14191416
If the model ID is invalid or if any parameters are incorrect.
14201417
"""
14211418
# Validate model_id
1422-
if not model_id or not isinstance(model_id, str):
1423-
raise ValueError("model_id must be a non-empty string.")
1419+
if not self.id:
1420+
logger.warn(
1421+
"Model needs to be saved to the model catalog before it can be restored."
1422+
)
1423+
return
14241424

14251425
# Optional: Validate restore_model_for_hours_specified
14261426
if restore_model_for_hours_specified is not None:
@@ -1432,8 +1432,8 @@ def restore_model(
14321432
"restore_model_for_hours_specified must be a positive integer."
14331433
)
14341434

1435-
cls.dsc_model.restore_archived_model_artifact(
1436-
model_id=model_id,
1435+
self.dsc_model.restore_archived_model_artifact(
1436+
model_id=self.id,
14371437
restore_model_for_hours_specified=restore_model_for_hours_specified,
14381438
)
14391439

docs/source/user_guide/model_catalog/model_catalog.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,6 +1394,10 @@ These are the metadata attributes:
13941394
* ``schema_output``: Output schema. However, this field can't be updated.
13951395
* ``time_created``: The date and time that the model artifacts were stored in the model catalog.
13961396
* ``user_name``: User name of the account that created the entry.
1397+
* ``backup_setting``: The backup setting property of the model
1398+
* ``retention_setting``: The retention setting property of the model
1399+
* ``retention_operation_details``: The retention operation details of the model
1400+
* ``backup_operation_details``: The back up operation details of the model
13971401

13981402
The ``provenance_metadata`` attribute returns a `ModelProvenance <https://oracle-cloud-infrastructure-python-sdk.readthedocs.io/en/latest/api/data_science/models/oci.data_science.models.ModelProvenance.html#oci.data_science.models.ModelProvenance>`__ object. This object has the attributes to access the metadata.
13991403

@@ -1545,3 +1549,8 @@ In the next example, the model that was stored in the model catalog as part of t
15451549
.. code-block:: python3
15461550
15471551
mc.delete_model(mc_model.id)
1552+
1553+
Restore Archived Model
1554+
**********************
1555+
1556+
The ``.restore_model()`` method of Model catalog restores the model for a specified number of hours. Restored models can be downloaded for 1-240 hours, defaulting to 24 hours.

0 commit comments

Comments
 (0)