External Data Sources


It is possible for an application on BioLib to connect to external data sources.

Hosts need to be declared by adding an array of allowed hosts under the remote_hosts tag in the .biolib/config.yml file:

remote_hosts:
    - 'some.host.com'
    - 'https://some.other.host.com'

This will allow your application to make an external connection to all sites under these domains. Attempts to connect to a host which not in this list will result in the following error:

BioLibError: Failed to execute module: main

BioLibError: Fetch from external data source failed:
Requested host (some.host.com) is not in 'allowed' list.

The creator of an application that calls external hosts will be able to run the application straight away. To use a new external host, that is not currently used by an existing BioLib app, the host needs to be added to the BioLib database. To do this, contact us here.

Example

If for example, a Python script fetches some data from some.host.com via the module requests:

# __main__.py
import requests
data = requests.get("some.host.com")

Then the following lines should be included in the .biolib/config.yml file:

biolib_version: 1
description_file: README.md
remote_hosts:
    - 'som.host.com'
modules:
    - '__main__'