2424class Model :
2525
2626 def __init__ (self , bucket_name , service_role_arn ):
27- """Save bucket name and service role ARN"""
27+ """Saves the bucket name and service role ARN. """
2828 self .bucket_name = bucket_name
2929 self .service_role_arn = service_role_arn
3030
3131 def export_model (self , model_class , model_name ):
32- """Export a TensorFlow model in SavedModel format and upload it to Amazon S3"""
32+ """Exports a TensorFlow model in SavedModel format and uploads it to Amazon S3. """
3333 # TensorFlow 2 only
3434 # MODEL_NAME=model_class.__name__
3535 MODEL_NAME = model_name
@@ -55,7 +55,7 @@ def export_model(self, model_class, model_name):
5555 return model_uri , model_input_name , model_input_shape
5656
5757 def compile_model (self , s3_uri , input_name = 'input_1' , input_shape = '224,224,3' , framework = 'TENSORFLOW' , device = 'jetson_xavier' ):
58- """Compile a model with Amazon Sagemaker Neo"""
58+ """Compiles a model with Amazon Sagemaker Neo. """
5959 MODEL_INPUT_SHAPE = '{{"{}":[1,{}]}}' .format (input_name ,input_shape )
6060 COMPILED_MODEL_FOLDER_URI = 's3://{}/models-compiled' .format (self .bucket_name )
6161 COMPILATION_JOB = 'panorama-custom-model-' + str (time .time ()).split ('.' )[0 ]
@@ -80,7 +80,7 @@ def compile_model(self, s3_uri, input_name='input_1', input_shape='224,224,3', f
8080 return COMPILATION_JOB
8181
8282 def package_model (self , model_name , compilation_job ):
83- """Package a model with Amazon Sagemaker Neo"""
83+ """Packages a model with Amazon Sagemaker Neo. """
8484 PACKAGING_JOB = compilation_job + "-packaging"
8585 MODEL_VERSION = "1.0"
8686 PACKAGED_MODEL_FOLDER_URI = 's3://{}/models-packaged' .format (self .bucket_name )
@@ -99,7 +99,7 @@ def package_model(self, model_name, compilation_job):
9999 return PACKAGING_JOB
100100
101101 def wait_compilation (self , job ):
102- """Wait for a Sagemaker Neo compilation job to complete"""
102+ """Waits for a Sagemaker Neo compilation job to complete. """
103103 while True :
104104 response = sagemaker_client .describe_compilation_job (CompilationJobName = job )
105105 if response ['CompilationJobStatus' ] == 'COMPLETED' :
@@ -110,7 +110,7 @@ def wait_compilation(self, job):
110110 time .sleep (5 )
111111
112112 def wait_packaging (self , job ):
113- """Wait for a Sagemaker Neo packaging job to complete"""
113+ """Waits for a Sagemaker Neo packaging job to complete. """
114114 while True :
115115 response = sagemaker_client .describe_edge_packaging_job (EdgePackagingJobName = job )
116116 if response ['EdgePackagingJobStatus' ] == 'COMPLETED' :
@@ -121,13 +121,13 @@ def wait_packaging(self, job):
121121 time .sleep (5 )
122122
123123 def upload (self , bucket , key , src ):
124- """Upload a file to Amazon S3"""
124+ """Uploads a file to Amazon S3. """
125125 uri = 's3://{}/{}' .format (bucket ,key )
126126 s3_resource .Bucket (bucket ).Object (key ).upload_file (src )
127127 return uri
128128
129129 def remove (self , path ):
130- """Remove a file or directory from /tmp"""
130+ """Removes a file or directory from /tmp. """
131131 if os .path .exists (path ) and path .startswith ('/tmp/' ) and len (path ) > 5 :
132132 if os .path .isfile (path ) or os .path .islink (path ):
133133 os .unlink (path )
0 commit comments