thoth.lab package¶
Subpackages¶
Submodules¶
thoth.lab.adviser module¶
thoth.lab.common module¶
thoth.lab.convert module¶
Utilities to work with package dependencies.
thoth.lab.dependency_monkey module¶
thoth.lab.exception module¶
Exceptions for thoth-lab methods.
thoth.lab.graph module¶
Various helpers and utils for interaction with the graph database.
-
class
thoth.lab.graph.
DependencyGraph
(incoming_graph_data=None, **attr)[source]¶ Bases:
networkx.classes.ordered.OrderedDiGraph
Construct a dependency graph by extending nx.OrderedDiGraph.
-
adjlist_dict_factory
¶ alias of
collections.OrderedDict
-
static
get_root
(tree)[source]¶ Return root of the current graph, if any.
By default, tree topology is considered as input, so if there are multiple roots, only the first one is returned.
-
node_dict_factory
¶ alias of
collections.OrderedDict
-
-
class
thoth.lab.graph.
GraphQueryResult
(result)[source]¶ Bases:
object
Wrap results of graph database queries.
-
thoth.lab.graph.
get_root
(tree)¶ Return root of the current graph, if any.
By default, tree topology is considered as input, so if there are multiple roots, only the first one is returned.
thoth.lab.inspection module¶
thoth.lab.inspection_report module¶
thoth.lab.security module¶
thoth.lab.solver module¶
thoth.lab.underscore module¶
Pandas common operations and utilities.
-
thoth.lab.underscore.
rget
(obj: Any, attr: str, default: Any = <object object>) → Any¶ Recursively retrieve nested attributes of an object.
- Parameters
f – callable, function to be used as getattr
obj – Any, object to check
attr – str, attribute to find declared by dot notation accessor
default – default attribute, similar to getattr’s default
- Returns
Any, retrieved attribute
thoth.lab.utils module¶
Various utilities for notebooks.
-
thoth.lab.utils.
display_page
(location: str, verify: bool = True, no_obtain_location: bool = False, width: int = 980, height: int = 900)[source]¶ Display the given page in notebook as iframe.
-
thoth.lab.utils.
get
(obj, attr, *, default: Any = <object object>)[source]¶ Combine both getattr and dict.get into universal get.
-
thoth.lab.utils.
get_column_group
(df: pandas.core.frame.DataFrame, columns: Union[List[Union[str, int]], pandas.core.indexes.base.Index] = None, label: str = None) → pandas.core.series.Series[source]¶ Group columns of the DataFrame into a single column group.
-
thoth.lab.utils.
get_index_group
(df: pandas.core.frame.DataFrame, names: List[Union[str, int]] = None, label: str = None) → pandas.core.series.Series[source]¶ Group multiple index levels into single index group.
-
thoth.lab.utils.
group_columns
(df: pandas.core.frame.DataFrame, columns: Union[List[Union[str, int]], pandas.core.indexes.base.Index] = None, label: str = None, inplace: bool = False) → pandas.core.series.Series[source]¶ Group columns of the DataFrame into a single column group and set it to the DataFrame.
-
thoth.lab.utils.
group_index
(df: pandas.core.frame.DataFrame, names: List[Union[str, int]] = None, label: str = None, inplace: bool = False) → pandas.core.frame.DataFrame[source]¶ Group multiple index levels into single index group and set it as index to the DataFrame.
-
thoth.lab.utils.
highlight
(df: pandas.core.frame.DataFrame, content: str = None, column_class: str = None, colours: Union[list, str] = None)[source]¶ Highlight rows of content column of a given DataFrame.
Highlight can be based on column_class or custom colours provided.
-
thoth.lab.utils.
obtain_location
(name: str, verify: bool = False, only_netloc: bool = False) → str[source]¶ Obtain location of a service based on it’s name in Red Hat’s internal network.
This function basically checks redirect of URL registered at Red Hat’s internal network. By doing so it is prevented to expose internal URLs. There is queried https://url.corp.redhat.com for redirects.
>>> obtain_location('thoth-sbu', verify=False)
-
thoth.lab.utils.
packages_info
(thoth_packages: bool = True) → pandas.core.frame.DataFrame[source]¶ Display information about versions of packages available in the installation.
-
thoth.lab.utils.
resolve_query
(query: str, context: pandas.core.frame.DataFrame = None, resolvers: tuple = None, engine: str = None, parser: str = 'pandas')[source]¶ Resolve query in the given context.
-
thoth.lab.utils.
rget
(obj: Any, attr: str, default: Any = <object object>) → Any¶ Recursively retrieve nested attributes of an object.
- Parameters
f – callable, function to be used as getattr
obj – Any, object to check
attr – str, attribute to find declared by dot notation accessor
default – default attribute, similar to getattr’s default
- Returns
Any, retrieved attribute
-
thoth.lab.utils.
rgetattr
(obj: Any, attr: str, default: Any = <object object>) → Any¶ Recursively retrieve nested attributes of an object.
- Parameters
f – callable, function to be used as getattr
obj – Any, object to check
attr – str, attribute to find declared by dot notation accessor
default – default attribute, similar to getattr’s default
- Returns
Any, retrieved attribute
-
thoth.lab.utils.
rhas
(obj: Any, attr: str) → bool¶ Recursively check nested attributes of an object.
- Parameters
fhas – callable, function to be used as hasattr
fget – callable, function to be used as getattr
obj – Any, object to check
attr – str, attribute to find declared by dot notation accessor
- Returns
bool, whether the object has the given attribute
-
thoth.lab.utils.
rhasattr
(obj: Any, attr: str) → bool¶ Recursively check nested attributes of an object.
- Parameters
fhas – callable, function to be used as hasattr
fget – callable, function to be used as getattr
obj – Any, object to check
attr – str, attribute to find declared by dot notation accessor
- Returns
bool, whether the object has the given attribute
Module contents¶
Routines for experiments in Thoth not only for Jupyter notebooks.