dcbench.common packageο
Submodulesο
dcbench.common.artifact moduleο
- class Artifact(artifact_id, **kwargs)[source]ο
Bases:
abc.ABC
- Parameters
artifact_id (str) β
- Return type
None
- DEFAULT_EXT: str = ''ο
- classmethod from_data(data, artifact_id=None)[source]ο
- Parameters
data (Any) β
artifact_id (Optional[str]) β
- property is_downloaded: boolο
- property is_uploaded: boolο
- isdir: bool = Falseο
- property local_path: strο
- property remote_url: strο
- static to_yaml(dumper, data)[source]ο
- Parameters
dumper (yaml.dumper.Dumper) β
data (dcbench.common.artifact.Artifact) β
- class ArtifactContainer(id, artifacts, attributes=None)[source]ο
Bases:
abc.ABC
,collections.abc.Mapping
,dcbench.common.table.RowMixin
- Parameters
id (str) β
artifacts (Mapping[str, Artifact]) β
attributes (Mapping[str, BASIC_TYPE]) β
- artifact_specs: Mapping[str, ArtifactSpec]ο
- container_type: strο
- classmethod from_artifacts(artifacts, attributes=None, container_id=None)[source]ο
- Parameters
artifacts (Mapping[str, Artifact]) β
attributes (Mapping[str, BASIC_TYPE]) β
container_id (str) β
- property is_downloaded: boolο
- property is_uploaded: boolο
- task_id: str = 'none'ο
- static to_yaml(dumper, data)[source]ο
- Parameters
dumper (yaml.dumper.Dumper) β
data (dcbench.common.artifact.ArtifactContainer) β
- class ArtifactSpec(description: 'str', artifact_type: 'type')[source]ο
Bases:
object
- Parameters
description (str) β
artifact_type (type) β
- Return type
None
- artifact_type: typeο
- description: strο
- class CSVArtifact(artifact_id, **kwargs)[source]ο
Bases:
dcbench.common.artifact.Artifact
- Parameters
artifact_id (str) β
- Return type
None
- DEFAULT_EXT: str = 'csv'ο
- class DataPanelArtifact(artifact_id, **kwargs)[source]ο
Bases:
dcbench.common.artifact.Artifact
- Parameters
artifact_id (str) β
- Return type
None
- DEFAULT_EXT: str = 'mk'ο
- isdir: bool = Trueο
- class ModelArtifact(artifact_id, **kwargs)[source]ο
Bases:
dcbench.common.artifact.Artifact
- Parameters
artifact_id (str) β
- Return type
None
- DEFAULT_EXT: str = 'pt'ο
- class VisionDatasetArtifact(artifact_id, **kwargs)[source]ο
Bases:
dcbench.common.artifact.DataPanelArtifact
- Parameters
artifact_id (str) β
- Return type
None
- COLUMN_SUBSETS = {'celeba': ['id', 'image', 'identity', 'split'], 'imagenet': ['id', 'image', 'name', 'synset']}ο
- DEFAULT_EXT: str = 'mk'ο
- isdir: bool = Trueο
dcbench.common.download_utils moduleο
This file contains utility functions for downloading datasets. The code in this file is taken from the torchvision package, specifically, https://github.com/pytorch/vision/blob/master/torchvision/datasets/utils.py. We package it here to avoid users having to install the rest of torchvision. It is licensed under the following license:
BSD 3-Clause License
Copyright (c) Soumith Chintala 2016, All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS βAS ISβ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- calculate_md5(fpath, chunk_size=1048576)[source]ο
- Parameters
fpath (str) β
chunk_size (int) β
- Return type
str
- check_integrity(fpath, md5=None)[source]ο
- Parameters
fpath (str) β
md5 (Optional[str]) β
- Return type
bool
- check_md5(fpath, md5, **kwargs)[source]ο
- Parameters
fpath (str) β
md5 (str) β
kwargs (Any) β
- Return type
bool
- download_and_extract_archive(url, download_root, extract_root=None, filename=None, md5=None, remove_finished=False, size=None)[source]ο
- Parameters
url (str) β
download_root (str) β
extract_root (Optional[str]) β
filename (Optional[str]) β
md5 (Optional[str]) β
remove_finished (bool) β
size (Optional[int]) β
- Return type
None
- download_file_from_google_drive(file_id, root, filename=None, md5=None)[source]ο
Download a Google Drive file from and place it in root.
- Parameters
file_id (str) β id of file to be downloaded
root (str) β Directory to place downloaded file in
filename (str, optional) β Name to save the file under. If None, use the id of the file.
md5 (str, optional) β MD5 checksum of the download. If None, do not check
- download_url(url, root, filename=None, md5=None, size=None)[source]ο
Download a file from a url and place it in root.
- Parameters
url (str) β URL to download file from
root (str) β Directory to place downloaded file in
filename (str, optional) β Name to save the file under. If None, use the basename of the URL
md5 (str, optional) β MD5 checksum of the download. If None, do not check
size (Optional[int]) β
- Return type
None
- extract_archive(from_path, to_path=None, remove_finished=False)[source]ο
- Parameters
from_path (str) β
to_path (Optional[str]) β
remove_finished (bool) β
- Return type
None
- list_dir(root, prefix=False)[source]ο
List all directories at a given root.
- Parameters
root (str) β Path to directory whose folders need to be listed
prefix (bool, optional) β If true, prepends the path to each result, otherwise only returns the name of the directories found
- Return type
List[str]
- list_files(root, suffix, prefix=False)[source]ο
List all files ending with a suffix at a given root.
- Parameters
root (str) β Path to directory whose folders need to be listed
suffix (str or tuple) β Suffix of the files to match, e.g. β.pngβ or (β.jpgβ, β.pngβ). It uses the Python βstr.endswithβ method and is passed directly
prefix (bool, optional) β If true, prepends the path to each result, otherwise only returns the name of the files found
- Return type
List[str]
- verify_str_arg(value, arg=None, valid_values=None, custom_msg=None)[source]ο
- Parameters
value (dcbench.common.download_utils.T) β
arg (Optional[str]) β
valid_values (Optional[Iterable[dcbench.common.download_utils.T]]) β
custom_msg (Optional[str]) β
- Return type
dcbench.common.download_utils.T
dcbench.common.method moduleο
- class Method(config=None, **kwargs)[source]ο
Bases:
abc.ABC
- Parameters
config (dict) β
- class Config(n_slices: int = 5, emb_group: str = 'main', emb: str = 'emb', xmodal_emb: str = 'emb')[source]ο
Bases:
object
- Parameters
n_slices (int) β
emb_group (str) β
emb (str) β
xmodal_emb (str) β
- Return type
None
- emb: str = 'emb'ο
- emb_group: str = 'main'ο
- n_slices: int = 5ο
- xmodal_emb: str = 'emb'ο
- RESOURCES_REQUIRED = {'cpu': 1, 'custom_resources': {'ram_gb': 4}}ο
dcbench.common.problem moduleο
- class Problem(id, artifacts, attributes=None)[source]ο
Bases:
dcbench.common.artifact.ArtifactContainer
- Parameters
id (str) β
artifacts (Mapping[str, Artifact]) β
attributes (Mapping[str, BASIC_TYPE]) β
- artifact_specs: Mapping[str, ArtifactSpec]ο
- container_type: str = 'problem'ο
- name: strο
- solution_class: typeο
- summary: strο