@@ -81,8 +81,8 @@ def __init__(self, instance_type, instance_count, image, sagemaker_session=None)
8181 self .instance_type = instance_type
8282 self .instance_count = instance_count
8383 self .image = image
84- # Since we are using a single docker network, Generate a random suffix to attach to the container names.
85- # This way multiple jobs can run in parallel.
84+ # Since we are using a single docker network, Generate a random suffix to attach to the
85+ # container names. This way multiple jobs can run in parallel.
8686 suffix = "" .join (random .choice (string .ascii_lowercase + string .digits ) for _ in range (5 ))
8787 self .hosts = [
8888 "{}-{}-{}" .format (CONTAINER_PREFIX , i , suffix )
@@ -160,8 +160,8 @@ def train(self, input_data_config, output_data_config, hyperparameters, job_name
160160 dirs_to_delete = [data_dir , shared_dir ]
161161 self ._cleanup (dirs_to_delete )
162162
163- # Print our Job Complete line to have a similar experience to training on SageMaker where you
164- # see this line at the end.
163+ # Print our Job Complete line to have a similar experience to training on SageMaker where
164+ # you see this line at the end.
165165 print ("===== Job Complete =====" )
166166 return artifacts
167167
@@ -702,10 +702,10 @@ def _delete_tree(path):
702702 try :
703703 shutil .rmtree (path )
704704 except OSError as exc :
705- # on Linux, when docker writes to any mounted volume, it uses the container's user. In most cases
706- # this is root. When the container exits and we try to delete them we can't because root owns those
707- # files. We expect this to happen, so we handle EACCESS. Any other error we will raise the
708- # exception up.
705+ # on Linux, when docker writes to any mounted volume, it uses the container's user. In most
706+ # cases this is root. When the container exits and we try to delete them we can't because
707+ # root owns those files. We expect this to happen, so we handle EACCESS. Any other error
708+ # we will raise the exception up.
709709 if exc .errno == errno .EACCES :
710710 logger .warning ("Failed to delete: %s Please remove it manually." , path )
711711 else :
@@ -724,13 +724,14 @@ def _aws_credentials(session):
724724 secret_key = creds .secret_key
725725 token = creds .token
726726
727- # The presence of a token indicates the credentials are short-lived and as such are risky to be used as they
728- # might expire while running.
727+ # The presence of a token indicates the credentials are short-lived and as such are risky
728+ # to be used as they might expire while running.
729729 # Long-lived credentials are available either through
730730 # 1. boto session
731- # 2. EC2 Metadata Service (SageMaker Notebook instances or EC2 instances with roles attached them)
732- # Short-lived credentials available via boto session are permitted to support running on machines with no
733- # EC2 Metadata Service but a warning is provided about their danger
731+ # 2. EC2 Metadata Service (SageMaker Notebook instances or EC2 instances with roles
732+ # attached them)
733+ # Short-lived credentials available via boto session are permitted to support running on
734+ # machines with no EC2 Metadata Service but a warning is provided about their danger
734735 if token is None :
735736 logger .info ("Using the long-lived AWS credentials found in session" )
736737 return [
@@ -739,15 +740,17 @@ def _aws_credentials(session):
739740 ]
740741 if not _aws_credentials_available_in_metadata_service ():
741742 logger .warning (
742- "Using the short-lived AWS credentials found in session. They might expire while running."
743+ "Using the short-lived AWS credentials found in session. They might expire while "
744+ "running."
743745 )
744746 return [
745747 "AWS_ACCESS_KEY_ID=%s" % (str (access_key )),
746748 "AWS_SECRET_ACCESS_KEY=%s" % (str (secret_key )),
747749 "AWS_SESSION_TOKEN=%s" % (str (token )),
748750 ]
749751 logger .info (
750- "No AWS credentials found in session but credentials from EC2 Metadata Service are available."
752+ "No AWS credentials found in session but credentials from EC2 Metadata Service are "
753+ "available."
751754 )
752755 return None
753756 except Exception as e : # pylint: disable=broad-except
0 commit comments