biothings.hub.dataplugin
biothings.hub.dataplugin.assistant
- class biothings.hub.dataplugin.assistant.BaseAssistant(url: str, plugin_name: str | None = None, src_folder: str | Path | None = None)[source]
Bases:
ABC- data_plugin_manager = None
- dumper_manager = None
- handle()[source]
Access self.url and do whatever is necessary to bring code to life within the hub… (hint: that may involve creating a dumper on-the-fly and register that dumper to a manager…)
- keylookup = None
- property loader
Return loader object able to interpret plugin’s folder content
- loaders = {'advanced': <class 'biothings.hub.dataplugin.loaders.loader.AdvancedPluginLoader'>, 'manifest': <class 'biothings.hub.dataplugin.loaders.loader.ManifestBasedPluginLoader'>}
- abstract property plugin_name: str
Return plugin name, parsed from self.url and set self._src_folder as path to folder containing dataplugin source code
- plugin_type = None
- uploader_manager = None
- class biothings.hub.dataplugin.assistant.GithubAssistant(url: str, plugin_name: str | None = None, src_folder: str | Path | None = None)[source]
Bases:
BaseAssistant- property plugin_name
Return plugin name, parsed from self.url and set self._src_folder as path to folder containing dataplugin source code
- plugin_type = 'github'
- class biothings.hub.dataplugin.assistant.LocalAssistant(url: str, plugin_name: str | None = None, src_folder: str | Path | None = None)[source]
Bases:
BaseAssistant- property plugin_name
We attempt to derive the plugin name from the url as we expect the URL (for local plugins) to follow the structure local://<pluginname>
Formats local://pluginname so it’s in hostname. (we leverage urlsplit over urlparse due to lack of need for parameter parsing) https://docs.python.org/3/library/urllib.parse.html#structured-parse-results
If we discover a subdirectory we raise an error for moment due to lack of subdirectory support at the moment for our pathing
This can be verified by checking the path value from the SplitResult
url -> local://plugin-name Supported: > ParseResult(scheme=’local’, netloc=’plugin-name’, path=’’, params=’’, query=’’, fragment=’’)
url -> local://sub-directory/plugin-name Unsupported: > ParseResult(scheme=’local’, netloc=’plugin-name’, path=’sub-directory’, params=’’, query=’’, fragment=’’)
- plugin_type = 'local'
biothings.hub.dataplugin.manager
- class biothings.hub.dataplugin.manager.AssistantManager(data_plugin_manager, dumper_manager, uploader_manager, keylookup=None, default_export_folder='hub/dataload/sources', *args, **kwargs)[source]
Bases:
BaseSourceManager- configure(klasses=[<class 'biothings.hub.dataplugin.assistant.GithubAssistant'>, <class 'biothings.hub.dataplugin.assistant.LocalAssistant'>])[source]
- export(plugin_name, folder=None, what=['dumper', 'uploader', 'mapping'], purge=False)[source]
Export generated code for a given plugin name, in given folder (or use DEFAULT_EXPORT_FOLDER if None). Exported information can be: - dumper: dumper class generated from the manifest - uploader: uploader class generated from the manifest - mapping: mapping generated from inspection or from the manifest If “purge” is true, any existing folder/code will be deleted first, otherwise, will raise an error if some folder/files already exist.
- load(autodiscover: bool = True)[source]
Load plugins registered in internal Hub database and generate/register dumpers & uploaders accordingly. If autodiscover is True, also search DATA_PLUGIN_FOLDER for existing plugin directories not registered yet in the database, and register them automatically.
- class biothings.hub.dataplugin.manager.DataPluginManager(job_manager: JobManager, poll_schedule=None, datasource_path: str | Path = None)[source]
Bases:
DumperManager