Skip to content

Commit

Permalink
Merge pull request #88 from zakv/move-infer_objects
Browse files Browse the repository at this point in the history
Move infer_objects() out of main thread
  • Loading branch information
dihm committed Dec 7, 2021
2 parents 72f82b3 + a98a766 commit 8bf02a2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lyse/__main__.py
Expand Up @@ -190,14 +190,18 @@ def handler(self, request_data):
"'get dataframe'\n 'hello'\n {'filepath': <some_h5_filepath>}")

@inmain_decorator(wait_for_return=True)
def _copy_dataframe(self):
df = app.filebox.shots_model.dataframe.copy(deep=True)
return df

def _retrieve_dataframe(self):
# infer_objects() picks fixed datatypes for columns that are compatible with
# fixed datatypes, dramatically speeding up pickling. It is called here
# rather than when updating the dataframe as calling it during updating may
# call it needlessly often, whereas it only needs to be called prior to
# sending the dataframe to a client requesting it, as we're doing now.
app.filebox.shots_model.infer_objects()
df = app.filebox.shots_model.dataframe.copy(deep=True)
df = self._copy_dataframe()
df.infer_objects()
return df

def _extract_n_sequences_from_df(self, df, n_sequences):
Expand Down

0 comments on commit 8bf02a2

Please sign in to comment.