Implicit Variables for ML Applications Packages

In the Terraform scripts inside the ML Applications packages, you can rely on implicit variables.

For example, when you need to know the identifier of the region, you can refer to an implicit variable this way:
${var.<region_identifier>}

Implementation-Independent Variables

These variables are always defined regardless of the package implementation.
Variables Injected into ML Application Packages
Name Type or Schema Description Sample
region_short_code String The airport code for the region. IAD, PHX
region_identifier String The identifier of the current region of MlApps service. us-ashburn-1
realm String The current realm of MlApps service. OC1, OC2
app
JSON Object
{
"id": string,
"name": string,
"compartment_id": string,
}
app.id String The OCID of the ML Application.
app.name String The name of the ML Application.
app.compartment_id String The compartment OCID of the ML Application.
app_impl
Type: Json Object
Schema:
"app_impl":
 type = object(
  {
   id = string,
   name = string,
   compartment_id = string,
   package_arguments = map(string),
   application_components = map(map(map(string)))
  }
 )
"app_impl":
 {
  "id": "ocid1.impl.oc1.aaaa..",
  "name": "My_Implementation",
  "compartment_id": "ocid1.compartment.oc1.aaaa..",
  "application_components":
   {
    "oci_datascience_job":
     {
      "my_first_job": "ocid1.job.oc1.aaaa.."
     }
     "oci_datascience_pipeline":
    {
     "my_first_pipeline": "ocid1.pl.oc1.aaaa..""
    }
   }
  "package_arguments":
   {
    "bucket_name": "my_bucket"
   }
 } 
app_impl.id String The OCID of the ML Application Implementation.
app_impl.name String The name of the ML Application Implementation.
app_impl.compartment_id String The compartment OCID of the ML Application Implementation.
app_impl.package_arguments Map The map of package arguments. { "bucket_name": "my_bucket"}
app_impl.application_components.oci_datascience_job Map The value of 'oci_datascience_job' application component.

{

"first_job": "ocid1.job.oc1.aaaa",

"second_job": "ocid1.job.oc1.bbbb"

}

app_instance
Type: Json Object
Schema:
"app_instance":
  type = object(
  {
   id = string
   view_id = string
   displayName = string
   compartment_id = string
   instance_components = map(string)
   configuration = map(string)
  }
 )
"app_instance":
{
"id": "ocid1.mlapplicationinstance.oc1.aaaa..",
"view_id" : "ocid1.mlapplicationinstanceview.oc1.aaaa.."
"displayName": "Test_Instance",
"compartment_id": "ocid1.compartment.oc1.aaaa..",
"instance_components":
 {
 "oci_objectstorage_bucket":
 {
  "my_first_bucket": "ocid1.bucket.oc1.aaaa..">
 } "oci_datascience_model":
 {  "my_first_model": "ocid1.model.oc1.aaaa..""
 }
"configuration":
 { "key1": "value1"
 }
}
app_instance.id String The OCID of the ML Application Instance.
app_instance.displayName String DisplayName of the ML Application Instance.
app_instance.compartment_id String The compartment OCID of the ML Application Instance.
app_instance.instance_components.oci_objectstorage_bucket Map
  • The value of 'oci_objectstorage_bucket' instance component.
  • Available ONLY after instance components are created during instance create, update, or upgrade.
  • This implicit variable can be used by, for example, triggers that need to use, for example, the Model Deployment OCID.
"my_bucket": # this is TF resource identifier for the bucket
{
  "id": "ocid1.bucket.oc1.aaaa", #bucket OCID
  "name": "test_bucket" #bucket name
}
app_instance.configuration Map The configuration values for the schema.
{
 "key1": "value1"
}
current_model_id Map

Current model ID for particular prediction use case.

The variable contains a map where:

  • use case name is the key (display name of your model deployment)
  • currently deployed model ID is the value.

Typically, the training pipeline builds a new model and deploys it. The terraform definition needs to know about the new model and refer to the currently deployed model. Otherwise, the currently deployed model would be overridden by the value used in the Terraform definition of the Model Deployment.

{
 "<your use case/MD name>": "ocid1.datasciencemodeldeployment...."
}
Model Reference in Model Deployment Terraform Definition
locals {
 # this assumes that you defined a default model as an application component named "default_model"
 default_model_id = var.app_impl.application_components.oci_datascience_model.default_model.id
}
model_id = var.current_model_id != null ? (contains(keys(var.current_model_id),"<use case>" ?
 (var.current_model_id["<use case>"]!= null ? var.current_model_id["<use case>"]
  :local.default_model_id) : local.default_model_id) :local.default_model_id
Note: The expression is very defensive not to be affected by the Terraform version or implementation used.

Component References

The application components and instance components are organized in a nested manner. This hierarchical structure allows easy reference and management of different application components and can then be used by instance components.

componentName :{  type: String,  minLength: 1,  maxLength: 255,}
"app_impl":
  {
   "application_components":
     {
      "oci_datascience_pipeline":
       {
         "test_pipeline":
           {
           "id" = "ocid1.oci_datascience_pipeline.oc1..aaaaaaaarvllavmi4anvsrpwe3eqyxx3vkzrnfmtzynunkbszrr7dnzfq3qa"
           "name" = "PipelineTriggers"
           }
       }
     }
   }
This previous sample structure is defined in Terraform and can then be referenced in trigger files in the following manner:
${app_impl.application_components.oci_datascience_pipeline.test_pipeline.id}"