camel_tools.data¶
This sub-module contains utilities for locating datastes for the various CAMeL Tools components.
Classes¶
-
class
camel_tools.data.
DownloaderError
(msg)¶ Exception raised when an error occurs during data download.
-
class
camel_tools.data.
FileEntry
(path: str, sha256: str)¶ Data class containing information about a given file.
-
path
= None¶ Relative path of file in the package directory.
-
sha256
= None¶ SHA256 hash of this file.
-
-
class
camel_tools.data.
PackageType
¶ Enum indicating the type of a package.
-
HTTP
= 1¶ Indicates package is a zip file that can be downloaded via HTTP/HTTPS.
-
META
= 0¶ Indicates a package is a meta package (ie. contains no files, only dependencies)
-
-
class
camel_tools.data.
PackageEntry
(name: str, description: str, size: Optional[int], version: Optional[str], license: str, package_type: camel_tools.data.catalogue.PackageType, url: Optional[str], destination: Optional[pathlib.Path], dependencies: Optional[Set[str]], files: Optional[List[camel_tools.data.catalogue.FileEntry]], private: bool, sha256: Optional[str], post_install: Optional[dict])¶ Data class containing information about a given package.
-
dependencies
= None¶ Names of packages this package depends on.
-
description
= None¶ Description of this package
-
destination
= None¶ Installation path of package. Is None for meta packages.
-
files
= None¶ List of files included in this package. Is None for meta packages.
-
license
= None¶ License this package is distributed under. Is None for meta packages.
-
name
= None¶ Name of this package.
-
package_type
= None¶ Type of this package.
-
post_install
= None¶ Post installation steps. Is ‘None’ for packages that require no post-installation
-
private
= None¶ Indicates if this package should be hidden when being listed.
-
sha256
= None¶ SHA256 hash of package zip file. Is None for meta packages.
-
size
= None¶ Size of this package in bytes. Is None for meta packages.
-
url
= None¶ URL for downlading this package’s zip file. Is None for meta packages.
-
version
= None¶ Package version. Is None for meta packages.
-
-
class
camel_tools.data.
DatasetEntry
(name: str, component: str, path: str)¶ Data class containing information about an individual dataset.
-
component
= None¶ Name of the component this dataset belongs to.
-
name
= None¶ Name of this dataset.
-
path
= None¶ Relative path of this dataset in the data directory.
-
-
class
camel_tools.data.
ComponentEntry
(name: str, default: str, datasets: Mapping[str, camel_tools.data.catalogue.DatasetEntry])¶ Data class that contains dataset information for a given component.
-
datasets
= None¶ A mapping of dataset names to their respective entries.
-
default
= None¶ The default dataset name for this component.
-
name
= None¶ Name of this component.
-
-
class
camel_tools.data.
CatalogueError
(msg: str)¶ Exception raised when an error occurs during data download.
-
class
camel_tools.data.
Catalogue
(version: str, packages: Mapping[str, camel_tools.data.catalogue.PackageEntry], components: Mapping[str, camel_tools.data.catalogue.ComponentEntry])¶ This class allows downloading and querying datasets provided by CAMeL Tools.
-
components
= None¶ Mapping of component names with their respective entries.
-
download_package
(package: str, recursive: bool = True, force: bool = False, print_status: bool = False)¶ Download and install package with a given name.
Parameters: - package (
str
) – Name of package to download and install. - recursive (
bool
, Optional) – If True, dependencies are recursively installed. Otherwise, only the package contents are installed. Defaults to True. - force (
bool
, Optional) – If True, packages that are already installed and up-to-date will be reinstalled, otherwise they are ignored. Defaults to False. - print_status (
bool
, Optional) – If True, prints out the download status to standard output. Defaults to False.
- package (
-
get_component
(component: str) → camel_tools.data.catalogue.ComponentEntry¶ Get component entry for a given component name.
Parameters: component ( str
) – Name of component to query.Returns: Entry associated with given component name. Return type: PackageEntry
Raises: CatalogueError
– When component is not a valid component name.
-
get_dataset
(component: str, dataset: Optional[str] = None) → camel_tools.data.catalogue.DatasetEntry¶ Get dataset entry for a given component name and dataset name.
Parameters: Returns: The dataset entry for the given component and dataset names.
Return type:
-
static
get_default_catalogue_path
() → pathlib.Path¶ Returns the default catalogue path, respecting the CAMELTOOLS_DATA environment variable if it is set.
Returns: Path to the catalogue file. Return type: Path
-
get_package
(package: str) → camel_tools.data.catalogue.PackageEntry¶ Get a package entry for a given package name.
Parameters: package ( str
) – Name of package to query.Returns: Entry associated with given package name. Return type: ComponentEntry
Raises: CatalogueError
– When package is not a valid package name.
-
get_public_packages
() → List[str]¶ Returns a list of all package names marked as public in the catalogue.
Returns: The list of names of all packages marked as public. Return type: list
ofstr
-
static
load_catalogue
(path: Optional[pathlib.Path] = None) → Catalogue¶ Load catalogue file at a given path.
Parameters: path ( Path
) – Path to catalogue file.Returns: Catalogue
instance populated by the contents of the catalogue file.Return type: Catalogue
-
packages
= None¶ Mapping of package names to their respective entries.
-
static
update_catalogue
()¶ Download latest catalogue for the current version of CAMeL Tools.
Raises: DownloaderError
– When an error occurs while downloading catalogue.
-
version
= None¶ Catalogue version string.
-