Skip to content

Fix test_data_visual_graph unittest #100

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 6 commits into from
Dec 16, 2022
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
21 changes: 11 additions & 10 deletions kgcnn/data/visual_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from visual_graph_datasets.config import Config
from visual_graph_datasets.util import get_dataset_path, ensure_folder
from visual_graph_datasets.web import get_file_share
from visual_graph_datasets.web import PROVIDER_CLASS_MAP, AbstractFileShare
from visual_graph_datasets.data import load_visual_graph_dataset
from visual_graph_datasets.visualization.importances import create_importances_pdf
Expand Down Expand Up @@ -50,31 +51,31 @@ def ensure(self) -> None:
None
"""
# First of all we try to load the dataset, as it might already exist on the system.
try:
if os.path.exists(os.path.join(self.vgd_config.get_datasets_path(), self.dataset_name)):
# This function will try to locate a dataset with the given name inside the system's global
# default folder where all the visual graph datasets are stored. If it does not find a
# corresponding dataset folder there, an exception is raised.
self.data_directory = get_dataset_path(self.dataset_name)
self.data_directory = get_dataset_path(
dataset_name=self.dataset_name,
datasets_path=self.vgd_config.get_datasets_path()
)
return
except (FileNotFoundError, IndexError) as e:
self.logger.info(f'the visual graph dataset "{self.dataset_name}" was not found on the disk. '
f'The following exception was raised during lookup:')
self.logger.info(str(e))

# At this point we know that the folder does not already exist which means we need to download the
# dataset.

# For this we will first check if a dataset with the given name is even available at the remote
# file share provider.
ensure_folder(self.vgd_config.get_datasets_path())
file_share_provider: str = self.vgd_config.get_provider()
file_share_class: type = PROVIDER_CLASS_MAP[file_share_provider]
file_share: AbstractFileShare = file_share_class(config=self.vgd_config, logger=self.logger)
file_share: AbstractFileShare = get_file_share(self.vgd_config)
file_share.check_dataset(self.dataset_name)

# If the dataset is available, then we can download it and then finally load the path
file_share.download_dataset(self.dataset_name, self.vgd_config.get_datasets_path())
self.data_directory = get_dataset_path(self.dataset_name)
self.data_directory = get_dataset_path(
dataset_name=self.dataset_name,
datasets_path=self.vgd_config.get_datasets_path(),
)
self.logger.info(f'visual graph dataset found @ {self.data_directory}')

def read_in_memory(self) -> None:
Expand Down