Skip to content
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

Add size_bytes to DatasetInfo and DataSource #2306

Merged
merged 1 commit into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion ludwig/automl/base_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
class DatasetInfo:
fields: List[FieldInfo]
row_count: int
size_bytes: int


def allocate_experiment_resources(resources: dict) -> dict:
Expand Down Expand Up @@ -223,7 +224,7 @@ def get_dataset_info_from_source(source: DataSource) -> DatasetInfo:
avg_words=avg_words,
)
)
return DatasetInfo(fields=fields, row_count=row_count)
return DatasetInfo(fields=fields, row_count=row_count, size_bytes=source.size_bytes())


def get_features_config(
Expand Down
7 changes: 7 additions & 0 deletions ludwig/utils/automl/data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ def get_avg_num_tokens(self, column: str) -> int:
def is_string_type(self, dtype: str) -> bool:
raise NotImplementedError()

@abstractmethod
def size_bytes(self) -> int:
raise NotImplementedError()

@abstractmethod
def __len__(self) -> int:
raise NotImplementedError()
Expand Down Expand Up @@ -75,6 +79,9 @@ def get_avg_num_tokens(self, column: str) -> int:
def is_string_type(self, dtype: str) -> bool:
return dtype in ["str", "string", "object"]

def size_bytes(self) -> int:
return sum(self.df.memory_usage(deep=True))

def __len__(self) -> int:
return len(self.df)

Expand Down