@@ -83,8 +83,7 @@ def __init__(self, operation=None,
8383 files = None , managers = None , executables = None ):
8484 """Initialization.
8585
86- operation (dict|None): the operation, in the format that
87- ESOperation.to_dict() uses.
86+ operation (ESOperation|None): the operation.
8887 task_type (string|None): the name of the task type.
8988 task_type_parameters (object|None): the parameters for the
9089 creation of the correct task type.
@@ -108,8 +107,6 @@ def __init__(self, operation=None,
108107 in the compilation.
109108
110109 """
111- if operation is None :
112- operation = {}
113110 if task_type is None :
114111 task_type = ""
115112 if sandboxes is None :
@@ -142,7 +139,9 @@ def __init__(self, operation=None,
142139 def export_to_dict (self ):
143140 """Return a dict representing the job."""
144141 res = {
145- 'operation' : self .operation ,
142+ 'operation' : (self .operation .to_dict ()
143+ if self .operation is not None
144+ else None ),
146145 'task_type' : self .task_type ,
147146 'task_type_parameters' : self .task_type_parameters ,
148147 'language' : self .language ,
@@ -185,6 +184,8 @@ def import_from_dict_with_type(data):
185184 @classmethod
186185 def import_from_dict (cls , data ):
187186 """Create a Job from the output of export_to_dict."""
187+ if data ['operation' ] is not None :
188+ data ['operation' ] = ESOperation .from_dict (data ['operation' ])
188189 data ['files' ] = dict (
189190 (k , File (k , v )) for k , v in iteritems (data ['files' ]))
190191 data ['managers' ] = dict (
@@ -303,7 +304,7 @@ def from_submission(operation, submission, dataset):
303304 # dict() is required to detach the dictionary that gets added
304305 # to the Job from the control of SQLAlchemy
305306 return CompilationJob (
306- operation = operation . to_dict () ,
307+ operation = operation ,
307308 task_type = dataset .task_type ,
308309 task_type_parameters = dataset .task_type_parameters ,
309310 language = submission .language ,
@@ -382,7 +383,7 @@ def from_user_test(operation, user_test, dataset):
382383 dataset .managers [manager_filename ]
383384
384385 return CompilationJob (
385- operation = operation . to_dict () ,
386+ operation = operation ,
386387 task_type = dataset .task_type ,
387388 task_type_parameters = dataset .task_type_parameters ,
388389 language = user_test .language ,
@@ -527,7 +528,7 @@ def from_submission(operation, submission, dataset):
527528 # dict() is required to detach the dictionary that gets added
528529 # to the Job from the control of SQLAlchemy
529530 return EvaluationJob (
530- operation = operation . to_dict () ,
531+ operation = operation ,
531532 task_type = dataset .task_type ,
532533 task_type_parameters = dataset .task_type_parameters ,
533534 language = submission .language ,
@@ -560,8 +561,7 @@ def to_submission(self, sr):
560561 execution_memory = self .plus .get ('execution_memory' ),
561562 evaluation_shard = self .shard ,
562563 evaluation_sandbox = ":" .join (self .sandboxes ),
563- testcase = sr .dataset .testcases [
564- self .operation ["testcase_codename" ]])]
564+ testcase = sr .dataset .testcases [self .operation .testcase_codename ])]
565565
566566 @staticmethod
567567 def from_user_test (operation , user_test , dataset ):
@@ -608,7 +608,7 @@ def from_user_test(operation, user_test, dataset):
608608 dataset .managers [manager_filename ]
609609
610610 return EvaluationJob (
611- operation = operation . to_dict () ,
611+ operation = operation ,
612612 task_type = dataset .task_type ,
613613 task_type_parameters = dataset .task_type_parameters ,
614614 language = user_test .language ,
0 commit comments