@@ -104,7 +104,7 @@ def __init__(self, ee2_state, extra_data=None, children=None):
104
104
if ee2_state .get ("job_id" ) is None :
105
105
raise ValueError ("Cannot create a job without a job ID!" )
106
106
107
- self ._update_state (ee2_state )
107
+ self .update_state (ee2_state )
108
108
self .extra_data = extra_data
109
109
110
110
# verify parent-children relationship
@@ -130,9 +130,9 @@ def from_job_ids(cls, job_ids, return_list=True):
130
130
return jobs
131
131
132
132
@staticmethod
133
- def _trim_ee2_state (state : dict , exclude : list ) -> None :
134
- if exclude :
135
- for field in exclude :
133
+ def _trim_ee2_state (state : dict , exclude_fields : list ) -> None :
134
+ if exclude_fields :
135
+ for field in exclude_fields :
136
136
if field in state :
137
137
del state [field ]
138
138
@@ -241,7 +241,7 @@ def __getattr__(self, name):
241
241
242
242
def __setattr__ (self , name , value ):
243
243
if name in STATE_ATTRS : # TODO are/should these assignments be used?
244
- self ._update_state ({name : value })
244
+ self .update_state ({name : value })
245
245
else :
246
246
object .__setattr__ (self , name , value )
247
247
@@ -308,7 +308,7 @@ def parameters(self):
308
308
f"Unable to fetch parameters for job { self .job_id } - { e } "
309
309
)
310
310
311
- def _update_state (self , state : dict , ts : int = None ) -> None :
311
+ def update_state (self , state : dict , ts : int = None ) -> None :
312
312
"""
313
313
Given a state data structure (as emitted by ee2), update the stored state in the job object
314
314
All updates to the job state should go through here to keep the last_updated field accurate
@@ -320,7 +320,7 @@ def _update_state(self, state: dict, ts: int = None) -> None:
320
320
if self ._acc_state :
321
321
if "job_id" in state and state ["job_id" ] != self .job_id :
322
322
raise ValueError (
323
- f"Job ID mismatch in _update_state : job ID: { self .job_id } ; state ID: { state ['job_id' ]} "
323
+ f"Job ID mismatch in update_state : job ID: { self .job_id } ; state ID: { state ['job_id' ]} "
324
324
)
325
325
326
326
# Check if there would be no change in updating
@@ -337,28 +337,28 @@ def _update_state(self, state: dict, ts: int = None) -> None:
337
337
338
338
self .last_updated = time_ns () if ts is None else ts
339
339
340
- def refresh_state (self , force_refresh = False , exclude = JOB_INIT_EXCLUDED_JOB_STATE_FIELDS ):
340
+ def refresh_state (self , force_refresh = False , exclude_fields = JOB_INIT_EXCLUDED_JOB_STATE_FIELDS ):
341
341
"""
342
342
Queries the job service to see the state of the current job.
343
343
"""
344
344
345
345
if force_refresh or not self .was_terminal ():
346
346
state = self .query_ee2_state (self .job_id , init = False )
347
- self ._update_state (state )
347
+ self .update_state (state )
348
348
349
- return self .current_state ( exclude )
349
+ return self .cached_state ( exclude_fields )
350
350
351
- def current_state (self , exclude = None ):
351
+ def cached_state (self , exclude_fields = None ):
352
352
"""Wrapper for self._acc_state"""
353
353
state = copy .deepcopy (self ._acc_state )
354
- self ._trim_ee2_state (state , exclude )
354
+ self ._trim_ee2_state (state , exclude_fields )
355
355
return state
356
356
357
357
def output_state (self , state = None , no_refresh = False ) -> dict :
358
358
"""
359
359
:param state: Supplied when the state is queried beforehand from EE2 in bulk,
360
360
or when it is retrieved from a cache. If not supplied, must be
361
- queried with self.refresh_state() or self.current_state ()
361
+ queried with self.refresh_state() or self.cached_state ()
362
362
:return: dict, with structure
363
363
364
364
{
@@ -412,10 +412,10 @@ def output_state(self, state=None, no_refresh=False) -> dict:
412
412
:rtype: dict
413
413
"""
414
414
if not state :
415
- state = self .current_state () if no_refresh else self .refresh_state ()
415
+ state = self .cached_state () if no_refresh else self .refresh_state ()
416
416
else :
417
- self ._update_state (state )
418
- state = self .current_state ()
417
+ self .update_state (state )
418
+ state = self .cached_state ()
419
419
420
420
if state is None :
421
421
return self ._create_error_state (
@@ -467,8 +467,8 @@ def show_output_widget(self, state=None):
467
467
if not state :
468
468
state = self .refresh_state ()
469
469
else :
470
- self ._update_state (state )
471
- state = self .current_state ()
470
+ self .update_state (state )
471
+ state = self .cached_state ()
472
472
473
473
if state ["status" ] == COMPLETED_STATUS and "job_output" in state :
474
474
(output_widget , widget_params ) = self ._get_output_info (state )
0 commit comments