Skip to content

Add Method to unload sequence data from memory #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions python/pandaset/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,31 @@ def sequences(self, with_semseg: bool = False) -> List[str]:
else:
return list(self._sequences.keys())

def unload(self, sequence: str):
""" Removes all sequence file data from memory if previously loaded from disk.

This is useful if you intend to iterate over all sequences and perform some
operation. If you do not unload the sequences, it quickly leads to sigkill.

Args:
sequence: The sequence name

Returns:
None

Examples:
>>> pandaset = DataSet('...')
>>> for sequence in pandaset.sequences():
>>> seq = pandaset[sequence]
>>> seq.load()
>>> # do operations on sequence here...
>>> # when finished, unload the sequence from memory
>>> pandaset.unload(sequence)

"""
if sequence in self._sequences:
del self._sequences[sequence]


if __name__ == '__main__':
pass