External Data Sources
Applications on BioLib can connect to external data sources, if hosts are appropriately. Hosts are 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 allows your application to make an external connection to all sites under these domains. Attempts to connect to a host not included 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: 2
remote_hosts:
- 'some.host.com'
Still have a question?
If you have any questions that you can't find an answer to above, please reach out to the BioLib community.