biothings.cli

Entrypoint for the biothings-cli tool

biothings.cli.main()[source]

The entrypoint for running the BioThings CLI

biothings.cli.setup_logging_configuration(logging_level: Literal[10, 20, 30, 40, 50]) None[source]

Configures the logging based off our environment configuration

biothings.cli.dataplugin

biothings.cli.dataplugin_hub

biothings.cli.utils

Utility functions for the biothings-cli tool

These are semantically separated from the operations in that these functions aide in helping the operations perform a task. Usually anything releated to plugin metadata, job handling, and data manipulation should logically exist here

biothings.cli.utils.clean_dumped_files(data_folder: str | Path, plugin_name: str)[source]

Remove all dumped files by a data plugin in the data folder.

biothings.cli.utils.clean_uploaded_sources(working_dir, plugin_name)[source]

Remove all uploaded sources by a data plugin in the working directory.

biothings.cli.utils.display_inspection_table(source_name: str, mode: str, inspection_mapping: dict, validate: bool = True)[source]
biothings.cli.utils.get_manifest_content(working_dir: str | Path) dict[source]

return the manifest content of the data plugin in the working directory

biothings.cli.utils.get_plugin_name(plugin_name=None, with_working_dir=True)[source]

return a valid plugin name (the folder name contains a data plugin) When plugin_name is provided as None, it use the current working folder. when with_working_dir is True, returns (plugin_name, working_dir) tuple

biothings.cli.utils.get_uploaded_collections(src_db, uploaders)[source]

A helper function to get the uploaded collections in the source database

biothings.cli.utils.get_uploaders(working_dir: Path) List[str][source]

A helper function to get the uploaders from the manifest file in the working directory used in show_uploaded_sources function below

biothings.cli.utils.process_inspect(source_name, mode, limit, merge) dict[source]

Perform inspect for the given source. It’s used in do_inspect function below

biothings.cli.utils.remove_files_in_folder(folder_path)[source]

Remove all files in a folder.

biothings.cli.utils.show_dumped_files(data_folder: str | Path, plugin_name: str) None[source]

A helper function to show the dumped files in the data folder

biothings.cli.utils.show_hubdb_content()[source]

Output hubdb content in a pretty format.

biothings.cli.utils.show_source_build(build_instance: DataBuilder, build_configuration_name: str)[source]

A helper function to show the build information for the plugin source

async biothings.cli.utils.show_source_index(index_name: str, index_manager: IndexManager, elasticsearch_mapping: dict)[source]

A helper function to show the elasticsearch index for the plugin source

biothings.cli.utils.show_uploaded_sources(working_dir, plugin_name)[source]

A helper function to show the uploaded sources from given plugin.

biothings.cli.utils.write_mapping_to_file(output_file: str | Path, mapping: dict) None[source]

Takes the generated mapping data and writes it to a local file

biothings.cli.web_app

class biothings.cli.web_app.BaseHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]

Bases: RequestHandler

set_default_headers()[source]

Override this to set HTTP headers at the beginning of the request.

For example, this is the place to set a custom Server header. Note that setting such headers in the normal flow of request processing may not do what you want, since headers may be reset during error handling.

class biothings.cli.web_app.CLIApplication(db, table_space: List[str], **settings)[source]

Bases: Application

The main application class, which defines the routes and handlers.

class biothings.cli.web_app.DocHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]

Bases: BaseHandler

The handler for the detail view of a document, e.g. /<source>/<doc_id/

async get(slug, item_id)[source]
class biothings.cli.web_app.HomeHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]

Bases: BaseHandler

the handler for the landing page, which lists all available routes

async get()[source]
class biothings.cli.web_app.QueryHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]

Bases: BaseHandler

The handler for return a list of docs matching the query terms passed to “q” parameter e.g. /<source>/?q=<query>

async get(slug)[source]
async biothings.cli.web_app.get_available_routes(db, table_space) Tuple[list, list][source]

return a list available URLs/routes based on the table_space and the actual collections in the database

biothings.cli.web_app.get_example_queries(db, table_space)[source]

Populate example queries for a given table_space

async biothings.cli.web_app.main(host, port, db, table_space)[source]

The main entrypoint for starting and running the cli server