code: def testArtifactProtoValue(self):
      # Construct artifact.
      my_artifact = _MyArtifact2()
      self.assertFalse(my_artifact.has_property("proto1"))
      self.assertFalse(my_artifact.has_custom_property("customproto2"))
      my_artifact.proto1 = None
      my_artifact.proto2 = struct_pb2.Value(string_value="aaa")
      my_artifact.set_proto_custom_property("customproto1", None)
      my_artifact.set_proto_custom_property(
          "customproto2", struct_pb2.Value(string_value="bbb")
      )
  
      # Test that the JsonValue getters return the same values we just set
      self.assertIsNone(my_artifact.proto1)
      self.assertProtoEquals(
          my_artifact.proto2, struct_pb2.Value(string_value="aaa")
      )
      self.assertIsNone(
          my_artifact.get_json_value_custom_property("customproto1")
      )
      self.assertProtoEquals(
          my_artifact.get_json_value_custom_property("customproto2"),
          struct_pb2.Value(string_value="bbb"),
      )
      self.assertTrue(my_artifact.has_property("proto1"))
      self.assertTrue(my_artifact.has_custom_property("customproto2"))
  
      # Test string and proto serialization.
      self.assertEqual(
          textwrap.dedent(
              """\
          Artifact(artifact: properties {
            key: "proto2"
            value {
              proto_value {
                type_url: "type.googleapis.com/google.protobuf.Value"
                value: "\\032\\003aaa"
              }
            }
          }
          custom_properties {
            key: "customproto2"
            value {
              proto_value {
                type_url: "type.googleapis.com/google.protobuf.Value"
                value: "\\032\\003bbb"
              }
            }
          }
          , artifact_type: name: "MyTypeName2"
          properties {
            key: "bool1"
            value: BOOLEAN
          }
          properties {
            key: "float1"
            value: DOUBLE
          }
          properties {
            key: "float2"
            value: DOUBLE
          }
          properties {
            key: "int1"
            value: INT
          }
          properties {
            key: "int2"
            value: INT
          }
          properties {
            key: "jsonvalue_dict"
            value: STRUCT
          }
          properties {
            key: "jsonvalue_empty"
            value: STRUCT
          }
          properties {
            key: "jsonvalue_float"
            value: STRUCT
          }
          properties {
            key: "jsonvalue_int"
            value: STRUCT
          }
          properties {
            key: "jsonvalue_list"
            value: STRUCT
          }
          properties {
            key: "jsonvalue_null"
            value: STRUCT
          }
          properties {
            key: "jsonvalue_string"
            value: STRUCT
          }
          properties {
            key: "proto1"
            value: PROTO
          }
          properties {
            key: "proto2"
            value: PROTO
          }
          properties {
            key: "string1"
            value: STRING
          }
          properties {
            key: "string2"
            value: STRING
          }
          )"""
          ),
          str(my_artifact),
      )
  
      copied_artifact = _MyArtifact2()
      copied_artifact.set_mlmd_artifact(my_artifact.mlmd_artifact)
  
      self.assertIsNone(copied_artifact.proto1)
      self.assertProtoEquals(
          copied_artifact.proto2, struct_pb2.Value(string_value="aaa")
      )
      self.assertIsNone(
          copied_artifact.get_proto_custom_property("customproto1")
      )
      self.assertProtoEquals(
          copied_artifact.get_proto_custom_property("customproto2"),
          struct_pb2.Value(string_value="bbb"),
      )
  
      # Modify nested structure and check proto serialization reflects changes.
      copied_artifact.proto2.string_value = "updated1"
      copied_artifact.get_proto_custom_property(
          "customproto2"
      ).string_value = "updated_custom"
  
      self.assertEqual(
          textwrap.dedent(
              """\
          Artifact(artifact: properties {
            key: "proto2"
            value {
              proto_value {
                type_url: "type.googleapis.com/google.protobuf.Value"
                value: "\\032\\010updated1"
              }
            }
          }
          custom_properties {
            key: "customproto2"
            value {
              proto_value {
                type_url: "type.googleapis.com/google.protobuf.Value"
                value: "\\032\\016updated_custom"
              }
            }
          }
          , artifact_type: name: "MyTypeName2"
          properties {
            key: "bool1"
            value: BOOLEAN
          }
          properties {
            key: "float1"
            value: DOUBLE
          }
          properties {
            key: "float2"
            value: DOUBLE
          }
          properties {
            key: "int1"
            value: INT
          }
          properties {
            key: "int2"
            value: INT
          }
          properties {
            key: "jsonvalue_dict"
            value: STRUCT
          }
          properties {
            key: "jsonvalue_empty"
            value: STRUCT
          }
          properties {
            key: "jsonvalue_float"
            value: STRUCT
          }
          properties {
            key: "jsonvalue_int"
            value: STRUCT
          }
          properties {
            key: "jsonvalue_list"
            value: STRUCT
          }
          properties {
            key: "jsonvalue_null"
            value: STRUCT
          }
          properties {
            key: "jsonvalue_string"
            value: STRUCT
          }
          properties {
            key: "proto1"
            value: PROTO
          }
          properties {
            key: "proto2"
            value: PROTO
          }
          properties {
            key: "string1"
            value: STRING
          }
          properties {
            key: "string2"
            value: STRING
          }
          )"""
          ),
          str(copied_artifact),
      )
  
imports: import json
  import textwrap
  from unittest import mock
  from absl import logging
  import tensorflow
  from tfx.types import artifact
  from tfx.types import system_artifacts
  from tfx.types import value_artifact
  from tfx.utils import json_utils
  from google.protobuf import struct_pb2
  from google.protobuf import json_format
  from ml_metadata.proto import metadata_store_pb2
label_desc: Use image node_id 4 for calling the ArtifactTest obj's underlying member method code with example usage: obj.testArtifactProtoValue() without return types