17
17
18
18
19
19
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 ):
21
28
self .sagemaker_session = sagemaker_session
22
- self .job_name = training_job_name
29
+ self .job_name = job_name
23
30
24
31
@abstractmethod
25
32
def start_new (cls , estimator , inputs ):
@@ -30,9 +37,14 @@ def start_new(cls, estimator, inputs):
30
37
inputs (str): Parameters used when called :meth:`~sagemaker.estimator.EstimatorBase.fit`.
31
38
32
39
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.
34
41
"""
42
+ pass
35
43
44
+ @abstractmethod
45
+ def wait (self ):
46
+ """Wait for the Amazon SageMaker job to finish.
47
+ """
36
48
pass
37
49
38
50
@staticmethod
@@ -88,22 +100,14 @@ def _prepare_output_config(s3_path, kms_key_id):
88
100
89
101
@staticmethod
90
102
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 }
95
106
96
107
@staticmethod
97
108
def _prepare_stopping_condition (max_run ):
98
- stop_condition = {'MaxRuntimeInSeconds' : max_run }
99
- return stop_condition
109
+ return {'MaxRuntimeInSeconds' : max_run }
100
110
101
111
@property
102
112
def name (self ):
103
113
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