Cloning or Patching a Model Group

Clone to create a new model group in Data Science from an existing one. Use this option to change the composition of an existing model group by adding or removing models. Patch operations include INSERT (add new models) and REMOVE (remove existing models).

  • See Before You Begin.
    1. On the Projects list page, select the project that you want to add the model group to. If you need help finding the list page or the project, see Listing Projects.
    2. On the project details page, select Model Group.
    3. From Actions (under the Search and Filter text box), select Create Model Group.
      The Create Model Group page opens.

    1. Basic information

    Select Clone and modify existing Model Group.

    2. Add Model Group details

    Provide identifying information for the model group.

    • Name (Optional): Enter a unique name (limit of 255 characters). If you don't provide a name, a name is automatically generated.
    • Description (Optional): Enter a description (limit of 400 characters) for the model group.
    • Compartment
    • Upload an artifact file: If you're creating a model group of type HOMOGENOUS, then use the upload artifact option to upload the model group deployment runtime artifact.
    • Tags (under Advanced options) (Optional): Add tags to the model group. If you have permissions to create a resource, then you also have permissions to apply free-form tags to that resource. To apply a defined tag, you must have permissions to use the tag namespace. For more information about tagging, see Resource Tags. If you're not sure whether to apply tags, skip this option or ask an administrator. You can apply tags later.

    3. Add Model

    Add models to the model group.

    • Select from compartment list: Select the compartment that contains the project that includes the models that you want to add to the model group.
    • Select from project list: Select the project that includes the models that you want to add to the model group, then select the models from the list.

    4. Add Model Group Version History

    Optional. Either select an existing model group version history or create a new one.

    • Use existing model group version history
      • Select from compartment list: Select the compartment that contains the project that includes the existing model group version history that you want to add to the model group.
      • Select from project list: Select the project that includes the existing model group version history that you want to add to the model group, then select the model group version history from the list.
    • Create a new Model Group Version History
      • Select from compartment list: Select the compartment that contains the project that you want to add the new model group version history to.
      • Select from project list: Select the project that you want to add the new model group version history to.
      • Name (Optional): Enter a name (limit of 255 characters). If you don't provide a name, a name is automatically generated.
      • Description (Optional): Enter a description (limit of 400 characters) for the model group.

    5. Model group configuration

    Select the classification type for the model group.

    • Homogenous
    • Heterogeneous
    • Stacked Inferencing
      • Base Model OCID

    Review and create

    Review the configuration and then select Create.

    1. Clone the Model Group from an existing Model Group:
      def __clone_from_model_group(compartment_id, project_id):
          print("cloning from the Model Group")
          new_member_model_details_list = [
              MemberModelDetails(
                  model_id="ocid1.datasciencemodel.oc1.<ocid>",
                  inference_key="key-11"),
              MemberModelDetails(
                  model_id="ocid1.datasciencemodel.oc1.<ocid>",
                  inference_key="key-12")
          ]
       
          remove_member_model_details_list = [
              MemberModelDetails(
                  model_id="ocid1.datasciencemodel.oc1.<ocid>",
                  inference_key="key-3")
          ]
          patch_insert_model_details = PatchInsertNewMemberModels()
          patch_insert_model_details.values = new_member_model_details_list
       
          patch_remove_model_details = PatchRemoveMemberModels()
          patch_remove_model_details.values = remove_member_model_details_list
       
          patch_instruction_list = [patch_insert_model_details, patch_remove_model_details]
       
          patch_model_group_member_model_details_object = PatchModelGroupMemberModelDetails()
          patch_model_group_member_model_details_object.items = patch_instruction_list
       
          modify_model_group_details_object = ModifyModelGroupDetails()
          modify_model_group_details_object.display_name = "test model group clone"
          modify_model_group_details_object.description = "test model group clone"
       
          clone_create_from_model_group_object = CloneCreateFromModelGroupDetails()
          clone_create_from_model_group_object.source_id = baseModelGroupId
          clone_create_from_model_group_object.patch_model_group_member_model_details = patch_model_group_member_model_details_object
          clone_create_from_model_group_object.modify_model_group_details = modify_model_group_details_object
       
          clone_model_group_details_object = CloneModelGroupDetails()
          clone_model_group_details_object.compartment_id = compartment_id
          clone_model_group_details_object.project_id = project_id
          clone_model_group_details_object.model_group_clone_source_details = clone_create_from_model_group_object
       
          try:
              model_group_response = data_science_client.create_model_group(clone_model_group_details_object)
              model_group_id = json.loads(str(model_group_response.data))['id']
              logger.info(model_group_id)
              print(model_group_response.headers)
              return model_group_id
          except Exception as e:
              logger.error("Failed to create model group with error: %s", format(e))
    2. Clone the Model Group from the latest version of the Model Group version history:
      def __clone_from_model_group_version_history(compartment_id, project_id, model_group_version_history_id):
          print("cloning from the Model Group Version History")
          new_member_model_details_list = [
              MemberModelDetails(
                  model_id="ocid1.datasciencemodel.oc1.<ocid>",
                  inference_key="key-11"),
              MemberModelDetails(
                  model_id="ocid1.datasciencemodel.oc1.<ocid>",
                  inference_key="key-12")
          ]
       
          remove_member_model_details_list = [
              MemberModelDetails(
                  model_id="ocid1.datasciencemodel.oc1.<ocid>",
                  inference_key="key-3")
          ]
          patch_insert_model_details = PatchInsertNewMemberModels()
          patch_insert_model_details.values = new_member_model_details_list
       
          patch_remove_model_details = PatchRemoveMemberModels()
          patch_remove_model_details.values = remove_member_model_details_list
       
          patch_instruction_list = [patch_insert_model_details, patch_remove_model_details]
       
          patch_model_group_member_model_details_object = PatchModelGroupMemberModelDetails()
          patch_model_group_member_model_details_object.items = patch_instruction_list
       
          modify_model_group_details_object = ModifyModelGroupDetails()
          modify_model_group_details_object.display_name = "test model group clone from mgvh"
          modify_model_group_details_object.description = "test model group clone from mgvh"
       
          clone_create_from_model_group_version_history_object = CloneCreateFromModelGroupVersionHistoryDetails()
          clone_create_from_model_group_version_history_object.source_id = model_group_version_history_id
          clone_create_from_model_group_version_history_object.patch_model_group_member_model_details = patch_model_group_member_model_details_object
          clone_create_from_model_group_version_history_object.modify_model_group_details = modify_model_group_details_object
       
          clone_model_group_details_object = CloneModelGroupDetails()
          clone_model_group_details_object.compartment_id = compartment_id
          clone_model_group_details_object.project_id = project_id
          clone_model_group_details_object.model_group_clone_source_details = clone_create_from_model_group_version_history_object
       
          try:
              model_group_response = data_science_client.create_model_group(clone_model_group_details_object)
              model_group_id = json.loads(str(model_group_response.data))['id']
              logger.info(model_group_id)
              print(model_group_response.headers)
              return model_group_id
          except Exception as e:
              logger.error("Failed to create model group with error: %s", format(e))
    1. Clone from the Model Group:
      {
          "createType": "CLONE",
          "modelGroupCloneSourceDetails" : {
              "modelGroupCloneSourceType": "MODEL_GROUP",
              "sourceId": "ocid1.notreviewedplaceholder.oc1.<ocid>",
              "modifyModelGroupDetails": {
                  "description": "cloned model group"
              },
              "patchModelGroupMemberModelDetails": {
                  "items" : [
                      {
                          "operation":"INSERT",
                          "values": [
                              {
                                  "inferenceKey": "key101",
                                  "modelId": "ocid1.datasciencemodel.oc1.<ocid>"
                              },
                              {
                                  "inferenceKey": "key102",
                                  "modelId": "ocid1.datasciencemodel.oc1.<ocid>"
                              }
                          ]
                      },
                      {
                          "operation":"REMOVE",
                          "values": [
                              {
                                  "inferenceKey": "key3",
                                  "modelId": "ocid1.datasciencemodel.oc1.<ocid>"
                              }  
                          ]
                      }
                  ]
              }
          }
      }
    2. Clone from the latest version of the Model Group version history:
      {
          "createType": "CLONE",
          "modelGroupCloneSourceDetails" : {
              "modelGroupCloneSourceType": "MODEL_GROUP_VERSION_HISTORY",
              "sourceId": "ocid1.notreviewedplaceholder.oc1.<ocid>",
              "modifyModelGroupDetails": {
                  "description": "cloned model group from the latest of model group version history"
              },
              "patchModelGroupMemberModelDetails": {
                  "items" : [
                      {
                          "operation":"INSERT",
                          "values": [
                              {
                                  "inferenceKey": "key101",
                                  "modelId": "ocid1.datasciencemodel.oc1.<ocid>"
                              },
                              {
                                  "inferenceKey": "key102",
                                  "modelId": "ocid1.datasciencemodel.oc1.<ocid>"
                              }
                          ]
                      },
                      {
                          "operation":"REMOVE",
                          "values": [
                              {
                                  "inferenceKey": "key2",
                                  "modelId": "ocid1.datasciencemodel.oc1.<ocid>"
                              }  
                          ]
                      }
                  ]
              }
          }
      }
    3. Update the Model Group:
      {
          "displayName": "updated display name -1 ",
          "description": "update test-1",
          "modelGroupVersionHistoryId": "ocid1.notreviewedplaceholder.oc1.<ocid>",
          "versionLabel": "Model Group Versioning Demo"
      }