server¶
api¶
- hidebound.server.api.api()[source]¶
 Route to Hidebound API documentation.
- Returns:
 Flassger generated API page.
- Return type:
 html
- hidebound.server.api.create()[source]¶
 Create hidebound data.
- Returns:
 Flask Response instance.
- Return type:
 Response
- hidebound.server.api.delete()[source]¶
 Delete hidebound data.
- Returns:
 Flask Response instance.
- Return type:
 Response
- hidebound.server.api.export()[source]¶
 Export hidebound data.
- Returns:
 Flask Response instance.
- Return type:
 Response
- hidebound.server.api.handle_data_error(error)[source]¶
 Handles errors raise by config validation.
- Parameters:
 error (DataError) – Config validation error.
- Returns:
 DataError response.
- Return type:
 Response
- hidebound.server.api.handle_json_decode_error(error)[source]¶
 Handles key errors.
- Parameters:
 error (JSONDecodeError) – Key error.
- Returns:
 JSONDecodeError response.
- Return type:
 Response
- hidebound.server.api.handle_key_error(error)[source]¶
 Handles key errors.
- Parameters:
 error (KeyError) – Key error.
- Returns:
 KeyError response.
- Return type:
 Response
- hidebound.server.api.handle_type_error(error)[source]¶
 Handles key errors.
- Parameters:
 error (TypeError) – Key error.
- Returns:
 TypeError response.
- Return type:
 Response
- hidebound.server.api.initialize()[source]¶
 Initialize database with given config.
- Returns:
 Flask Response instance.
- Return type:
 Response
- hidebound.server.api.progress()[source]¶
 Get hidebound app progress.
- Returns:
 Flask Response instance.
- Return type:
 Response
- hidebound.server.api.read()[source]¶
 Read database.
- Returns:
 Flask Response instance.
- Return type:
 Response
- hidebound.server.api.search()[source]¶
 Search database with a given SQL query.
- Returns:
 Flask Response instance.
- Return type:
 Response
app¶
- hidebound.server.app.get_app(testing=False)[source]¶
 Creates a Hidebound app.
- Returns:
 Dash app.
- Return type:
 Dash
- hidebound.server.app.on_datatable_update(store)[source]¶
 Updates datatable with read information from store.
- Parameters:
 store (dict) – Store data.
- Returns:
 Dash DataTable.
- Return type:
 DataTable
- hidebound.server.app.on_event(*inputs)[source]¶
 Update Hidebound database instance, and updates store with input data.
- Parameters:
 inputs (tuple) – Input elements.
- Returns:
 Store data.
- Return type:
 dict
- hidebound.server.app.on_get_tab(tab, store)[source]¶
 Serve content for app tabs.
- Parameters:
 tab (str) – Name of tab to render.
store (dict) – Store.
- Returns:
 Response.
- Return type:
 flask.Response
components¶
- hidebound.server.components.get_asset_graph(data)[source]¶
 Creates asset graph data for cytoscape component.
- Parameters:
 data (list[dict]) – List of dicts.
- Raises:
 KeyError – If asset_valid or asset_path keys not found.
- Returns:
 Cytoscape graph.
- Return type:
 Cytoscape
- hidebound.server.components.get_button(title)[source]¶
 Get a html button with a given title.
- Parameters:
 title (str) – Title of button.
- Raises:
 TypeError – If title is not a string.
- Returns:
 Button element.
- Return type:
 Button
- hidebound.server.components.get_config_tab(config)[source]¶
 Get tab element for Hidebound config.
- Parameters:
 config (dict) – Configuration to be displayed.
- Returns:
 List of elements for config tab.
- Return type:
 list
- hidebound.server.components.get_configbar(config)[source]¶
 Get a row of elements used for configuring Hidebound.
- Parameters:
 config (dict) – Configuration to be displayed.
- Returns:
 Div with buttons and JSON editor.
- Return type:
 Div
- hidebound.server.components.get_dash_app(server, seconds=5.0, storage_type='session')[source]¶
 Generate Dash Flask app instance.
- Parameters:
 server (Flask) – Flask instance.
seconds (float, optional) – Time between progress updates. Default: 5.
storage_type (str) – Storage type (used for testing). Default: session.
- Returns:
 Dash app instance.
- Return type:
 Dash
- hidebound.server.components.get_data_tab(query=None)[source]¶
 Get tab element for Hidebound data.
- Parameters:
 query (str, optional) – Query string. Default: None.
- Returns:
 List of elements for data tab.
- Return type:
 list
- hidebound.server.components.get_datatable(data)[source]¶
 Gets a Dash DataTable element using given data. Assumes dict element has all columns of table as keys.
- Parameters:
 data (list[dict]) – List of dicts.
- Returns:
 Table of data.
- Return type:
 DataTable
- hidebound.server.components.get_dropdown(options)[source]¶
 Gets html dropdown element with given options.
- Parameters:
 options (list[str]) – List of options.
- Raises:
 TypeError – If options is not a list.
TypeError – If any option is not a string.
- Returns:
 Dropdown element.
- Return type:
 Dropdown
- hidebound.server.components.get_dummy_elements()[source]¶
 Returns a list of all elements with callbacks so that the client will not throw errors in each tab.
- Returns:
 List of html elements.
- Return type:
 list
- hidebound.server.components.get_key_value_card(data, header=None, id_='key-value-card', sorting=False)[source]¶
 Creates a key-value card using the keys and values from the given data. One key-value pair per row.
- Parameters:
 data (dict) – Dictionary to be represented.
header (str, optional) – Name of header. Default: None.
id (str) – Name of id property. Default: “key-value-card”.
sorting (bool, optional) – Whether to sort the output by key. Default: False.
- Returns:
 Card with key-value child elements.
- Return type:
 Div
extension¶
- class hidebound.server.extension.HideboundExtension(app=None)[source]¶
 Bases:
object- __init__(app=None)[source]¶
 Initialize flask extension.
- Parameters:
 app (flask.Flask, optional) – Flask app.
- _get_config_from_env(app)[source]¶
 Get config from environment variables.
- Parameters:
 app (flask.Flask) – Flask app.
- Returns:
 Database config.
- Return type:
 dict
- _get_config_from_file(filepath)[source]¶
 Get config from envirnment variables or config file.
- Parameters:
 filepath (str or Path) – Filepath of hidebound config.
- Raises:
 FileNotFoundError – If HIDEBOUND_CONFIG_FILEPATH is set to a file that does not end in json, yml or yaml.
- Returns:
 Database config.
- Return type:
 dict
extensions¶
server_tools¶
- class hidebound.server.server_tools.EndPoints[source]¶
 Bases:
objectA convenience class for API endpoints.
- api = 'http://0.0.0.0:8080/api'¶
 
- create = 'http://0.0.0.0:8080/api/create'¶
 
- delete = 'http://0.0.0.0:8080/api/delete'¶
 
- export = 'http://0.0.0.0:8080/api/export'¶
 
- host = '0.0.0.0'¶
 
- init = 'http://0.0.0.0:8080/api/initialize'¶
 
- port = 8080¶
 
- progress = 'http://0.0.0.0:8080/api/progress'¶
 
- read = 'http://0.0.0.0:8080/api/read'¶
 
- search = 'http://0.0.0.0:8080/api/search'¶
 
- update = 'http://0.0.0.0:8080/api/update'¶
 
- workflow = 'http://0.0.0.0:8080/api/workflow'¶
 
- hidebound.server.server_tools.error_to_response(error)[source]¶
 Convenience function for formatting a given exception as a Flask Response.
- Parameters:
 error (Exception) – Error to be formatted.
- Returns:
 Flask response.
- Return type:
 flask.Response
- hidebound.server.server_tools.format_config(config, redact_regex='(_key|_id|_token|url)$', redact_hash=False)[source]¶
 Redacts credentials of config and formats it for display in component.
- Parameters:
 config (dict) – Configuration dictionary.
redact_regex (str, optional) – Regular expression that matches keys, whose values are to be redacted. Default: “(_key|_id|_token|url)$”.
redact_hash (bool, optional) – Whether to redact values with the string “REDACTED” or a hash of the value. Default: False.
- Returns:
 Formatted config.
- Return type:
 OrderedDict
- hidebound.server.server_tools.get_config_error()[source]¶
 Convenience function for returning a config error response.
- Returns:
 Config error.
- Return type:
 Response
- hidebound.server.server_tools.get_connection_error()[source]¶
 Convenience function for returning a database connection error response.
- Returns:
 Connection error.
- Return type:
 Response
- hidebound.server.server_tools.get_initialization_error()[source]¶
 Convenience function for returning a initialization error response.
- Returns:
 Initialization error.
- Return type:
 Response
- hidebound.server.server_tools.get_progress(logpath='/var/log/hidebound/hidebound-progress.log')[source]¶
 Gets current progress state.
- Parameters:
 logpath (str or Path, optional) – Filepath of progress log. Default: PROGRESS_LOG_PATH.
- Returns:
 Progess.
- Return type:
 dict
- hidebound.server.server_tools.get_read_error()[source]¶
 Convenience function for returning a read error response.
- Returns:
 Update error.
- Return type:
 Response
- hidebound.server.server_tools.get_search_error()[source]¶
 Convenience function for returning a search error response.
- Returns:
 Update error.
- Return type:
 Response
- hidebound.server.server_tools.get_update_error()[source]¶
 Convenience function for returning a update error response.
- Returns:
 Update error.
- Return type:
 Response
- hidebound.server.server_tools.parse_json_file_content(raw_content)[source]¶
 Parses JSON file content as supplied by HTML request.
- Parameters:
 raw_content (bytes) – Raw JSON file content.
- Raises:
 ValueError – If header is invalid.
JSONDecodeError – If JSON is invalid.
- Returns:
 JSON content or reponse dict with error.
- Return type:
 dict
- hidebound.server.server_tools.render_template(filename, parameters)[source]¶
 Renders a jinja2 template given by filename with given parameters.
- Parameters:
 filename (str) – Filename of template.
parameters (dict) – Dictionary of template parameters.
- Returns:
 HTML.
- Return type:
 bytes
- hidebound.server.server_tools.request(store, url, params=None, client=<module 'requests' from '/home/ubuntu/pdm/envs/pdm-kVbOHlCT-dev-3.10/lib/python3.10/site-packages/requests/__init__.py'>)[source]¶
 Execute search against database and update store with response. Sets store[‘content’] to response if there is an error.
- Parameters:
 store (dict) – Dash store.
url (str) – API endpoint.
params (dict, optional) – Request paramaters. Default: None.
client (object, optional) – Client. Default: requests module.
- Returns:
 Store.
- Return type:
 dict
- hidebound.server.server_tools.search(store, query, group_by_asset, client=<module 'requests' from '/home/ubuntu/pdm/envs/pdm-kVbOHlCT-dev-3.10/lib/python3.10/site-packages/requests/__init__.py'>)[source]¶
 Execute search against database and update given store with response.
- Parameters:
 store (dict) – Dash store.
query (str) – Query string.
group_by_asset (bool) – Whether to group the search by asset.
client (object, optional) – Client. Default: requests module.
- Returns:
 Store.
- Return type:
 dict