Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self._args = continue_dict['args']
# Keyword arguments to the user's job function
self._kwargs = continue_dict['kwargs']
# Postproc Function
self._postproc = continue_dict['postproc']
# Postprog args
self._postproc_args = continue_dict['postproc_args']
# Postproc Kwargs
self._postproc_kwargs = continue_dict['postproc_kwargs']
old_start_timestamp = continue_dict['start_timestamp']
# Unpack the trajectory
self._traj.v_full_copy = continue_dict['full_copy']
# Load meta data
self._traj.f_load(load_parameters=pypetconstants.LOAD_NOTHING,
load_derived_parameters=pypetconstants.LOAD_NOTHING,
load_results=pypetconstants.LOAD_NOTHING,
load_other_data=pypetconstants.LOAD_NOTHING)
# Now we have to reconstruct previous results
result_list = []
full_filename_list = []
for filename in os.listdir(self._continue_path):
_, ext = os.path.splitext(filename)
if ext != '.rcnt':
continue
full_filename = os.path.join(self._continue_path, filename)
cnt_file = open(full_filename, 'rb')
result_list.append(dill.load(cnt_file))
Attribute Error:
If options 1 and 2 (load skeleton and load data) are applied but the
objects already exist in your trajectory. This prevents implicitly overriding
data in RAM. Use -1 and -2 instead to load only items that are currently not
in your trajectory in RAM. Or remove the items you want to 'reload' first.
"""
# Do some argument validity checks first
if name is None and index is None:
name = self.v_name
if as_new:
load_parameters=pypetconstants.LOAD_DATA
load_derived_parameters = pypetconstants.LOAD_NOTHING
load_results = pypetconstants.LOAD_NOTHING
load_other_data = pypetconstants.LOAD_NOTHING
self._storage_service.load(pypetconstants.TRAJECTORY, self, trajectory_name=name,
trajectory_index=index,
as_new=as_new, load_parameters=load_parameters,
load_derived_parameters=load_derived_parameters,
load_results=load_results,
load_other_data=load_other_data,
force=force)
# If a trajectory is newly loaded, all parameters are unlocked.
if as_new:
for param in self._parameters.itervalues():
param.f_unlock()
self._stored=False
the first place) and returns a :class:`~pypet.trajectory.Trajectory` instance loaded from
the `index` th Trajectory stored in the file. In this function, nothing is loaded
for the results and derived parameters, whereas the parameters are fully loaded.
This is recommended when the file size is REALLY LARGE (e.g. > 20GB)
:param filename: filename of an HDF file created by LTL
:param name_or_index: The name or index of the trajectory to load from the file,
if unspecified, the LAST trajectory is loaded.
"""
traj = Trajectory(filename=filename)
load_params_dict = {
'load_parameters':pypetconstants.LOAD_DATA,
'load_results':pypetconstants.LOAD_NOTHING,
'load_derived_parameters':pypetconstants.LOAD_NOTHING,
'force':True
}
if isinstance(name_or_index, str):
load_params_dict['name'] = name_or_index
else:
index = int(name_or_index)
load_params_dict['index'] = index
# Loading Trajectory from file.
with timed(logger, "Primary Loading of The HDF File"):
traj.f_load(**load_params_dict)
logger.info("Finished Primary Loading")
return traj
If options 1 and 2 (load skeleton and load data) are applied but the
objects already exist in your trajectory. This prevents implicitly overriding
data in RAM. Use -1 and -2 instead to load only items that are currently not
in your trajectory in RAM. Or remove the items you want to 'reload' first.
"""
# Do some argument validity checks first
if name is None and index is None:
name = self.v_name
if as_new:
load_parameters=pypetconstants.LOAD_DATA
load_derived_parameters = pypetconstants.LOAD_NOTHING
load_results = pypetconstants.LOAD_NOTHING
load_other_data = pypetconstants.LOAD_NOTHING
self._storage_service.load(pypetconstants.TRAJECTORY, self, trajectory_name=name,
trajectory_index=index,
as_new=as_new, load_parameters=load_parameters,
load_derived_parameters=load_derived_parameters,
load_results=load_results,
load_other_data=load_other_data,
force=force)
# If a trajectory is newly loaded, all parameters are unlocked.
if as_new:
for param in self._parameters.itervalues():
param.f_unlock()
self._stored=False
else:
self.f_lock_parameters()
# Keyword arguments to the user's job function
self._kwargs = continue_dict['kwargs']
# Postproc Function
self._postproc = continue_dict['postproc']
# Postprog args
self._postproc_args = continue_dict['postproc_args']
# Postproc Kwargs
self._postproc_kwargs = continue_dict['postproc_kwargs']
old_start_timestamp = continue_dict['start_timestamp']
# Unpack the trajectory
self._traj.v_full_copy = continue_dict['full_copy']
# Load meta data
self._traj.f_load(load_parameters=pypetconstants.LOAD_NOTHING,
load_derived_parameters=pypetconstants.LOAD_NOTHING,
load_results=pypetconstants.LOAD_NOTHING,
load_other_data=pypetconstants.LOAD_NOTHING)
# Now we have to reconstruct previous results
result_list = []
full_filename_list = []
for filename in os.listdir(self._continue_path):
_, ext = os.path.splitext(filename)
if ext != '.rcnt':
continue
full_filename = os.path.join(self._continue_path, filename)
cnt_file = open(full_filename, 'rb')
result_list.append(dill.load(cnt_file))
cnt_file.close()
def _finalize(self):
"""Final rollback initiated by the environment
Restores the trajectory as root of the tree, and loads meta data from disk.
This updates the trajectory's information about single runs, i.e. if they've been
completed, when they were started, etc.
"""
self.f_restore_default()
self._nn_interface._change_root(self)
self.f_load(self.v_name,None, False, pypetconstants.LOAD_NOTHING, pypetconstants.LOAD_NOTHING,
pypetconstants.LOAD_NOTHING)
def _finalize(self):
"""Final rollback initiated by the environment
Restores the trajectory as root of the tree, and loads meta data from disk.
This updates the trajectory's information about single runs, i.e. if they've been
completed, when they were started, etc.
"""
self.f_restore_default()
self._nn_interface._change_root(self)
self.f_load(self.v_name,None, False, pypetconstants.LOAD_NOTHING, pypetconstants.LOAD_NOTHING,
pypetconstants.LOAD_NOTHING)
# load_results = kwargs.pop('load_results')
if not as_new:
# if not traj.f_is_empty():
# raise TypeError('You cannot f_load a trajectory from disk into a non-_empty one.')
traj._stored=True
self._trj_load_meta_data(traj,as_new,force)
self._ann_load_annotations(traj,self._trajectory_group)
if (as_new and (load_derived_params != pypetconstants.LOAD_NOTHING or load_results !=
pypetconstants.LOAD_NOTHING)):
raise ValueError('You cannot load a trajectory as new and load the derived '
'parameters and results. Only parameters are allowed.')
if as_new and load_params != pypetconstants.LOAD_DATA:
raise ValueError('You cannot load the trajectory as new and not load the data of '
'the parameters.')
for what,loading in ( ('config',load_params),('parameters',load_params),
('derived_parameters',load_derived_params),
('results',load_results) ):
if loading != pypetconstants.LOAD_NOTHING:
# Postproc Function
self._postproc = continue_dict['postproc']
# Postprog args
self._postproc_args = continue_dict['postproc_args']
# Postproc Kwargs
self._postproc_kwargs = continue_dict['postproc_kwargs']
old_start_timestamp = continue_dict['start_timestamp']
# Unpack the trajectory
self._traj.v_full_copy = continue_dict['full_copy']
# Load meta data
self._traj.f_load(load_parameters=pypetconstants.LOAD_NOTHING,
load_derived_parameters=pypetconstants.LOAD_NOTHING,
load_results=pypetconstants.LOAD_NOTHING,
load_other_data=pypetconstants.LOAD_NOTHING)
# Now we have to reconstruct previous results
result_list = []
full_filename_list = []
for filename in os.listdir(self._continue_path):
_, ext = os.path.splitext(filename)
if ext != '.rcnt':
continue
full_filename = os.path.join(self._continue_path, filename)
cnt_file = open(full_filename, 'rb')
result_list.append(dill.load(cnt_file))
cnt_file.close()
full_filename_list.append(full_filename)