Skip to content

Commit 7f8f64e

Browse files
author
Dan Choi
committed
Doc updates and style updates
1 parent 4dc9123 commit 7f8f64e

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

src/sagemaker/job.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,16 @@
1717

1818

1919
class _Job(object):
20-
def __init__(self, sagemaker_session, training_job_name):
20+
"""Handles creating, starting and waiting for Amazon SageMaker jobs to finish.
21+
22+
This class shouldn't be directly instantiated.
23+
24+
Subclasses must define a way to create, start and wait for an Amazon SageMaker job.
25+
"""
26+
27+
def __init__(self, sagemaker_session, job_name):
2128
self.sagemaker_session = sagemaker_session
22-
self.job_name = training_job_name
29+
self.job_name = job_name
2330

2431
@abstractmethod
2532
def start_new(cls, estimator, inputs):
@@ -30,9 +37,14 @@ def start_new(cls, estimator, inputs):
3037
inputs (str): Parameters used when called :meth:`~sagemaker.estimator.EstimatorBase.fit`.
3138
3239
Returns:
33-
sagemaker.estimator.Framework: Constructed object that captures all information about the started job.
40+
sagemaker.job: Constructed object that captures all information about the started job.
3441
"""
42+
pass
3543

44+
@abstractmethod
45+
def wait(self):
46+
"""Wait for the Amazon SageMaker job to finish.
47+
"""
3648
pass
3749

3850
@staticmethod
@@ -88,22 +100,14 @@ def _prepare_output_config(s3_path, kms_key_id):
88100

89101
@staticmethod
90102
def _prepare_resource_config(instance_count, instance_type, volume_size):
91-
resource_config = {'InstanceCount': instance_count,
92-
'InstanceType': instance_type,
93-
'VolumeSizeInGB': volume_size}
94-
return resource_config
103+
return {'InstanceCount': instance_count,
104+
'InstanceType': instance_type,
105+
'VolumeSizeInGB': volume_size}
95106

96107
@staticmethod
97108
def _prepare_stopping_condition(max_run):
98-
stop_condition = {'MaxRuntimeInSeconds': max_run}
99-
return stop_condition
109+
return {'MaxRuntimeInSeconds': max_run}
100110

101111
@property
102112
def name(self):
103113
return self.job_name
104-
105-
def wait(self, logs=True):
106-
if logs:
107-
self.sagemaker_session.logs_for_job(self.job_name, wait=True)
108-
else:
109-
self.sagemaker_session.wait_for_job(self.job_name)

0 commit comments

Comments
 (0)