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

Speed up SDV-Enterprise integration tests #2331

Merged
merged 7 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from 4 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
24 changes: 16 additions & 8 deletions sdv/datasets/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import os
import warnings
from collections import defaultdict
from copy import deepcopy
from functools import lru_cache
from pathlib import Path
from zipfile import ZipFile

Expand Down Expand Up @@ -122,6 +124,18 @@ def _get_metadata(output_folder_name, in_memory_directory, dataset_name):
return metadata


@lru_cache()
def _download_demo(modality, dataset_name, output_folder_name=None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of caching here, can we make a download_test_demo fixture in our test utils and just cache that one?

_validate_modalities(modality)
_validate_output_folder(output_folder_name)
bytes_io = _download(modality, dataset_name)
in_memory_directory = _extract_data(bytes_io, output_folder_name)
data = _get_data(modality, output_folder_name, in_memory_directory)
metadata = _get_metadata(output_folder_name, in_memory_directory, dataset_name)

return data, metadata


def download_demo(modality, dataset_name, output_folder_name=None):
"""Download a demo dataset.

Expand All @@ -147,14 +161,8 @@ def download_demo(modality, dataset_name, output_folder_name=None):
* If the ``dataset_name`` doesn't exist in the bucket.
* If there is already a folder named ``output_folder_name``.
"""
_validate_modalities(modality)
_validate_output_folder(output_folder_name)
bytes_io = _download(modality, dataset_name)
in_memory_directory = _extract_data(bytes_io, output_folder_name)
data = _get_data(modality, output_folder_name, in_memory_directory)
metadata = _get_metadata(output_folder_name, in_memory_directory, dataset_name)

return data, metadata
data, metadata = _download_demo(modality, dataset_name, output_folder_name)
return deepcopy(data), deepcopy(metadata)


def get_available_demos(modality):
Expand Down
3 changes: 0 additions & 3 deletions sdv/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ class SDVVersionWarning(UserWarning):
synthesizer and the current version of the SDV software.
"""

def __init__(self, *args, **kwargs):
self.__class__.__name__ = 'SDV Version Warning'


class VersionError(ValueError):
"""Raised when loading a synthesizer from a newer version into an older one."""
Expand Down
5 changes: 4 additions & 1 deletion sdv/logging/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import contextlib
import logging
import shutil
import tempfile
from pathlib import Path

import pandas as pd
Expand All @@ -19,7 +20,9 @@ def get_sdv_logger_config():
if (store_path / 'sdv_logger_config.yml').exists():
config_path = store_path / 'sdv_logger_config.yml'
else:
shutil.copyfile(config_path, store_path / 'sdv_logger_config.yml')
tmp_path = tempfile.mktemp(dir=store_path, suffix='.yml')
shutil.copyfile(config_path, tmp_path)
shutil.move(tmp_path, store_path / 'sdv_logger_config.yml')
Comment on lines +23 to +25
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is required because multiple workers can access the logger at the same time ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this function can be called simultaneously by multiple workers, so while one of them was copying config_path into store_path, another one was resetting the store_path/config_path variables.


with open(config_path, 'r') as f:
logger_conf = yaml.safe_load(f)
Expand Down
Loading