コード例 #1
0
 def testInputPreProcessExamplesWithStrAndBytes(self):
   input_examples_str = 'inputs=[{"text":["foo"], "bytes":[b"bar"]}]'
   input_dict = saved_model_cli.preprocess_input_examples_arg_string(
       input_examples_str)
   feature = example_pb2.Example.FromString(input_dict['inputs'][0])
   self.assertProtoEquals(
       """
         features {
           feature {
             key: "bytes"
             value {
               bytes_list {
                 value: "bar"
               }
             }
           }
           feature {
             key: "text"
             value {
               bytes_list {
                 value: "foo"
               }
             }
           }
         }
   """, feature)
コード例 #2
0
 def testInputPreprocessExampleWithCodeInjection(self):
     input_examples_str = 'inputs=os.system("echo hacked")'
     with self.assertRaisesRegex(RuntimeError,
                                 'not a valid python literal.'):
         saved_model_cli.preprocess_input_examples_arg_string(
             input_examples_str)