Skip to content

Commit

Permalink
Implement a file source to integrate Galaxy with eLabFTW
Browse files Browse the repository at this point in the history
eLabFTW [1] revolves around the concepts of experiment [2] and resource [3]. Experiments and resources can have files attached to them. To get a quick overview, try out the live demo [4]. The scope of this implementation is exporting data from and importing data to eLabFTW as file attachments of already existing experiments and resources. Each user can configure their preferred eLabFTW instance entering its URL and an API Key.

File sources reference files via a URI, while eLabFTW uses auto-incrementing positive integers. For more details read #18665 [5]. This leads to the need to declare a mapping between said identifiers and Galaxy URIs.

Those take the form `elabftw://demo.elabftw.net/entity_type/entity_id/attachment_id`, where:
- `entity_type` is either 'experiments' or 'resources'
- entity_id` is the id (an integer in string form) of an experiment or resource
- `attachment_id` is the id (an integer in string form) of an attachment

This implementation uses both `aiohttp` and the `requests` libraries as underlying mechanisms to communicate with eLabFTW via its REST API [6]. A significant limitation of the implementation is that, due to the fact that the API does not have an endpoint that can list attachments for several experiments and/or resources with a single request, when listing the root directory or an entity type _recursively_, a list of entities has to be fetched first, then to fetch the information on their attachments, a separate request has to be sent _for each one_ of them. The `aiohttp` library makes it bearable to recursively browse instances with up to ~500 experiments or resources with attachments by sending them concurrently, but ultimately solving the problem would require changes to the API from the eLabFTW side.

References:
- [1] https://www.elabftw.net/
- [2] https://doc.elabftw.net/user-guide.html#experiments
- [3] https://doc.elabftw.net/user-guide.html#resources
- [4] https://demo.elabftw.net
- [5] #18665
- [6] https://doc.elabftw.net/api/v2
  • Loading branch information
kysrpex committed Dec 12, 2024
1 parent f8f5976 commit 84c9393
Show file tree
Hide file tree
Showing 4 changed files with 969 additions and 0 deletions.
1 change: 1 addition & 0 deletions client/src/utils/upload-payload.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const URI_PREFIXES = [
"drs://",
"invenio://",
"zenodo://",
"elabftw://",
];

export function isUrl(content) {
Expand Down
8 changes: 8 additions & 0 deletions lib/galaxy/config/sample/file_sources_conf.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,11 @@
access_token: ${user.preferences['onedata|access_token']}
onezone_domain: ${user.preferences['onedata|onezone_domain']}
disable_tls_certificate_validation: ${user.preferences['onedata|disable_tls_certificate_validation']}

- type: elabftw
id: elabftw
label: eLabFTW
doc: Import/export files from an eLabFTW instance.
api_key: ${user.user_vault.read_secret('preferences/elabftw/api_key')}
writable: true
endpoint: ${user.preferences['elabftw|endpoint']}
14 changes: 14 additions & 0 deletions lib/galaxy/config/sample/user_preferences_extra_conf.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,17 @@ preferences:
type: boolean
required: False
value: False

# Used in file_sources_conf.yml
elabftw:
description: Your eLabFTW Integration Settings
inputs:
- name: api_key
label: API key
type: secret
store: vault # Requires setting up vault_config_file in your galaxy.yml
required: True
- name: endpoint
label: URL of the eLabFTW instance you want to access
type: text
required: True
Loading

0 comments on commit 84c9393

Please sign in to comment.