Skip to content

Commit

Permalink
Merge pull request #97 from DataCanvasIO/hotfix-0.2.5
Browse files Browse the repository at this point in the history
Merge from hotfix-0.2.5
  • Loading branch information
lixfz authored May 6, 2023
2 parents 44c19c0 + 729104f commit e3ab140
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions hypernets/core/trial.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@
from ..core import pareto


def _is_bigdata(v):
big_data_types = (pd.Series, pd.DataFrame, np.ndarray)
if isinstance(v, big_data_types):
return True

type_name = type(v).__name__.lower()
if any(type_name.find(s) for s in ('array', 'dataframe', 'series')):
return True

return False


class Trial():
def __init__(self, space_sample, trial_no, reward=None, elapsed=None, model_file=None, succeeded=True):
self.space_sample = space_sample
Expand Down Expand Up @@ -84,10 +96,9 @@ def __getstate__(self):

# state = {k: v for k, v in state.items() if k != 'memo'}
memo = state.get('memo', None)
big_data_types = (pd.Series, pd.DataFrame, np.ndarray)
big_data_exists = isinstance(memo, dict) and any(isinstance(v, big_data_types) for v in memo.values())
big_data_exists = isinstance(memo, dict) and any(_is_bigdata(v) for v in memo.values())
if big_data_exists:
compacted_memo = {k: v for k, v in memo.items() if not isinstance(v, big_data_types)}
compacted_memo = {k: v for k, v in memo.items() if not _is_bigdata(v)}
state = state.copy()
state['memo'] = compacted_memo

Expand Down
2 changes: 1 addition & 1 deletion hypernets/tabular/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def _store_cache(toolbox, cache_path, data, meta):
elif isinstance(data, (list, tuple)):
items = [f'_{i}' for i in range(len(data))]
for d, i in zip(data, items):
_store_cache(f'{cache_path}{i}', d, meta)
_store_cache(toolbox, f'{cache_path}{i}', d, meta)
meta.update({'kind': _KIND_LIST, 'items': items})
else:
pq = toolbox.parquet()
Expand Down

0 comments on commit e3ab140

Please sign in to comment.