@@ -18,9 +18,9 @@ def __init__(self, context):
1818 self .input_data = context .remote_profile ['input_data' ].copy ()
1919 self .api_version = 2
2020 if 'api_version' in self .input_data :
21- self .api_version = self .input_data .get ('api_version' )
21+ self .api_version = self .input_data .get ('api_version' , 2 )
2222 if 'lebesgue_version' in self .input_data :
23- self .api_version = self .input_data .get ('lebesgue_version' )
23+ self .api_version = self .input_data .get ('lebesgue_version' , 2 )
2424 self .grouped = self .input_data .get ('grouped' , False )
2525 email = context .remote_profile .get ("email" , None )
2626 username = context .remote_profile .get ('username' , None )
@@ -33,7 +33,7 @@ def __init__(self, context):
3333 if password is None :
3434 raise ValueError ("can not find password in remote_profile, please check your machine file." )
3535 if self .api_version == 1 :
36- warnings .warn ('api version 1 is deprecated and will be removed in a future version . Use version 2 instead.' , DeprecationWarning )
36+ warnings .warn ('api version 1 is deprecated. Use version 2 instead.' , DeprecationWarning )
3737 self .api = API (email , password )
3838 self .group_id = None
3939
@@ -88,26 +88,17 @@ def do_submit(self, job):
8888 # input_data['backward_files'] = self._gen_backward_files_list(job)
8989 if self .context .remote_profile .get ('program_id' ) is None :
9090 warnings .warn ('program_id will be compulsory in the future.' )
91- job_id = None
92- if self .api_version == 2 :
93- job_id , group_id = self .api .job_create_v2 (
94- job_type = input_data ['job_type' ],
95- oss_path = input_data ['job_resources' ],
96- input_data = input_data ,
97- program_id = self .context .remote_profile .get ('program_id' , None ),
98- group_id = self .group_id
99- )
100- if self .grouped :
101- self .group_id = group_id
102- job .job_id = str (job_id ) + ':job_group_id:' + str (group_id )
103- job_id = job .job_id
104- else :
105- job_id = self .api .job_create (
106- job_type = input_data ['job_type' ],
107- oss_path = input_data ['job_resources' ],
108- input_data = input_data ,
109- program_id = self .context .remote_profile .get ('program_id' , None )
110- )
91+ job_id , group_id = self .api .job_create (
92+ job_type = input_data ['job_type' ],
93+ oss_path = input_data ['job_resources' ],
94+ input_data = input_data ,
95+ program_id = self .context .remote_profile .get ('program_id' , None ),
96+ group_id = self .group_id
97+ )
98+ if self .grouped :
99+ self .group_id = group_id
100+ job .job_id = str (job_id ) + ':job_group_id:' + str (group_id )
101+ job_id = job .job_id
111102 job .job_state = JobStatus .waiting
112103 return job_id
113104
@@ -126,20 +117,13 @@ def check_status(self, job):
126117 dlog .debug (f"debug: check_status; job.job_id:{ job_id } ; job.job_hash:{ job .job_hash } " )
127118 check_return = None
128119 # print("api",self.api_version,self.input_data.get('job_group_id'),job.job_id)
129- if self .api_version == 2 :
130- check_return = self .api .get_tasks_v2 (job_id ,group_id )
131- else :
132- check_return = self .api .get_tasks (job_id )
120+ check_return = self .api .get_tasks (job_id ,group_id )
133121 try :
134122 dp_job_status = check_return [0 ]["status" ]
135123 except IndexError as e :
136124 dlog .error (f"cannot find job information in check_return. job { job .job_id } . check_return:{ check_return } ; retry one more time after 60 seconds" )
137125 time .sleep (60 )
138- retry_return = None
139- if self .api_version == 2 :
140- retry_return = self .api .get_tasks_v2 (job_id , group_id )
141- else :
142- retry_return = self .api .get_tasks (job_id )
126+ retry_return = self .api .get_tasks (job_id , group_id )
143127 try :
144128 dp_job_status = retry_return [0 ]["status" ]
145129 except IndexError as e :
0 commit comments