Skip to content

Conversation

@iamishaan
Copy link
Member

@iamishaan iamishaan commented Oct 9, 2024

This PR aims to update the data science model class to introduce new feature of Model Backups and retention.
Also to provide a new method/api call to restore an archived model artifact.
User can enable model backup or retention for their model while creation or while updating a model.
Both of them are Optional fields.
attaching screenshots for model creation with the 2 new fields
Screenshot 2024-10-24 at 5 21 48 PM
Screenshot 2024-10-24 at 5 22 13 PM

@oracle-contributor-agreement
Copy link

Thank you for your pull request and welcome to our community! To contribute, please sign the Oracle Contributor Agreement (OCA).
The following contributors of this PR have not signed the OCA:

  • PR author: iamishaan

To sign the OCA, please create an Oracle account and sign the OCA in Oracle's Contributor Agreement Application.

When signing the OCA, please provide your GitHub username. After signing the OCA and getting an OCA approval from Oracle, this PR will be automatically updated.

If you are an Oracle employee, please make sure that you are a member of the main Oracle GitHub organization, and your membership in this organization is public.

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Required At least one contributor does not have an approved Oracle Contributor Agreement. label Oct 9, 2024
@mrDzurb mrDzurb requested a review from lu-ohai October 9, 2024 17:12
@lu-ohai
Copy link
Member

lu-ohai commented Oct 9, 2024

@iamishaan Could you add some user experience example here and also update the user guide? DataScience Model related user guide should be placed under here.

Copy link
Member

@lu-ohai lu-ohai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some comments.

@oracle-contributor-agreement oracle-contributor-agreement bot added OCA Verified All contributors have signed the Oracle Contributor Agreement. and removed OCA Required At least one contributor does not have an approved Oracle Contributor Agreement. labels Oct 18, 2024
@github-actions
Copy link

📌 Cov diff with main:

Coverage-51%

📌 Overall coverage:

Coverage-20.31%

@github-actions
Copy link

📌 Cov diff with main:

Coverage-86%

📌 Overall coverage:

Coverage-59.18%

@mrDzurb
Copy link
Member

mrDzurb commented Oct 23, 2024

@iamishaan could you add more details in the PR description?


def restore_model(
self,
model_id: str,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This either should be a class method or model_id parameter is not required. See the update nethod.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this update the case shared below will not work. I would rather prefer to remove the model_id attribute from the function.

This case will not work:

DataScienceModel.from_id("OCID"). restore_model()

It will expect from e to provide OCID one more time,
like this

DataScienceModel.from_id("OCID"). restore_model("OCID")

But why should i do this, if I already provided the OCID before?

The better solution would be

    def restore_model(
            cls,
            restore_model_for_hours_specified: Optional[int] = HOURS_24,
    ):

    if not self.id:
          raise ValueError("Model needs to be saved to the model catalog before it can be updated.")

Or if we really want to support both cases below

DataScienceModel.from_id("OCID"). restore_model()
DataScienceModel.restore_model("OCID")

Then the solution could be

@class_or_instance_method
def restore_model(
            cls,
            model_id: Optional[str] = None,
            restore_model_for_hours_specified: Optional[int] = HOURS_24,
    ):

   if not inspect.isclass(cls): # if the instance used
        pass
   
   # otherwise the class is used
   
   # see GenericModel.update_deployment as example.    

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have updated the method to use self and model_id isn't a required parameter anymore now.
just passing it to restore_archived_model_artifact method here

self.dsc_model.restore_archived_model_artifact(
            model_id=self.id,
            restore_model_for_hours_specified=restore_model_for_hours_specified,
        )

@github-actions
Copy link

📌 Cov diff with main:

Coverage-91%

📌 Overall coverage:

Coverage-59.07%

msg="Model needs to be restored before the archived artifact content can be accessed."
)
def restore_archived_model_artifact(
self, model_id: str, restore_model_for_hours_specified: Optional[int] = None
Copy link
Member

@mrDzurb mrDzurb Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The model_id attribute is not required here, the self.id should be used instead.
I think it would be useful to have a default value for the restore_model_for_hours_specified, for example 24 hours.

DITO for the other methods.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have refactored the method

self,
file_path: str,
storage_options: dict = None,
self,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting problem?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undo-ed

return state in (cls.PENDING, cls.SUCCEEDED, cls.FAILED)


class ModelBackupSetting:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class ModelBackupSetting: can be replaced with

@dataclass(repr=False)
class ModelBackupSetting(DataClassSerializable):
      is_backup_enabled: Optional[bool] = None,
      backup_region: Optional[str] = None,
      customer_notification_type: Optional[str] = None

      def validate(self) -> bool:
                    pass

The DataClassSerializable is already implements bunch of the helper functions like form_dict, to_tict, from_json, e.t.c.

DITO for the other classes.

@github-actions
Copy link

📌 Cov diff with main:

Coverage-90%

📌 Overall coverage:

Coverage-59.05%

"restore_model_for_hours_specified must be a positive integer."
)

self.dsc_model.restore_archived_model_artifact(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return self.sync() would get the updated model, in this case user would have the object containing the fresh status and details. Otherwise, after the calling this method user will have an old object.

overwrite_existing_artifact: Optional[bool] = True,
remove_existing_artifact: Optional[bool] = True,
timeout: Optional[int] = None,
self,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting issue?

@github-actions
Copy link

📌 Cov diff with main:

Coverage-91%

📌 Overall coverage:

Coverage-59.05%

@iamishaan iamishaan requested a review from lu-ohai October 24, 2024 18:42
mrDzurb
mrDzurb previously approved these changes Oct 24, 2024
@github-actions
Copy link

📌 Cov diff with main:

Coverage-90%

📌 Overall coverage:

Coverage-59.06%

@github-actions
Copy link

📌 Cov diff with main:

Coverage-90%

📌 Overall coverage:

Coverage-59.06%

@github-actions
Copy link

📌 Cov diff with main:

Coverage-90%

📌 Overall coverage:

Coverage-59.06%

@github-actions
Copy link

📌 Cov diff with main:

Coverage-90%

📌 Overall coverage:

Coverage-59.05%

@iamishaan iamishaan merged commit c10e309 into main Oct 29, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants