Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eLabFTW integration via Galaxy file source #19319

Open
wants to merge 11 commits into
base: dev
Choose a base branch
from
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
19 changes: 11 additions & 8 deletions lib/galaxy/files/sources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def write_from(
native_path: str,
user_context: "OptionalUserContext" = None,
opts: Optional[FilesSourceOptions] = None,
):
) -> str:
"""Write file at native path to target_path (relative to uri root).

:param target_path: url of the target file to write to within the filesource. e.g. `gxfiles://myftp1/myfile.txt`
Expand All @@ -231,6 +231,9 @@ def write_from(
:type user_context: _type_, optional
:param opts: A set of options to exercise additional control over the write_from method. Filesource specific, defaults to None
:type opts: Optional[FilesSourceOptions], optional
:return: Actual url of the written file, fixed by the service backing the FileSource. May differ from the target
path.
:rtype: str
"""

@abc.abstractmethod
Expand Down Expand Up @@ -296,7 +299,7 @@ def get_uri_root(self) -> str:
"""Return a prefix for the root (e.g. gxfiles://prefix/)."""

@abc.abstractmethod
def list(
async def list(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't change this for existing interfaces. You can add a <operation>_async method where needed. We can't do blocking IO in async calls, but every plugin apart from yours will make blocking calls.

self,
path="/",
recursive=False,
Expand Down Expand Up @@ -443,7 +446,7 @@ def _serialization_props(self, user_context: "OptionalUserContext" = None) -> Fi
Used in to_dict method if for_serialization is True.
"""

def list(
async def list(
self,
path="/",
recursive=False,
Expand All @@ -467,9 +470,9 @@ def list(
if offset is not None and offset < 0:
raise RequestParameterInvalidException("Offset must be greater than or equal to 0.")

return self._list(path, recursive, user_context, opts, limit, offset, query)
return await self._list(path, recursive, user_context, opts, limit, offset, query)

def _list(
async def _list(
self,
path="/",
recursive=False,
Expand Down Expand Up @@ -511,10 +514,10 @@ def write_from(
native_path: str,
user_context: "OptionalUserContext" = None,
opts: Optional[FilesSourceOptions] = None,
):
) -> str:
self._ensure_writeable()
self._check_user_access(user_context)
self._write_from(target_path, native_path, user_context=user_context, opts=opts)
return self._write_from(target_path, native_path, user_context=user_context, opts=opts) or target_path

@abc.abstractmethod
def _write_from(
Expand All @@ -523,7 +526,7 @@ def _write_from(
native_path: str,
user_context: "OptionalUserContext" = None,
opts: Optional[FilesSourceOptions] = None,
):
) -> Optional[str]:
pass

def realize_to(
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/files/sources/_pyfilesystem2.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __init__(self, **kwd: Unpack[FilesSourceProperties]):
def _open_fs(self, user_context: OptionalUserContext = None, opts: Optional[FilesSourceOptions] = None) -> FS:
"""Subclasses must instantiate a PyFilesystem2 handle for this file system."""

def _list(
async def _list(
self,
path="/",
recursive=False,
Expand Down
Loading
Loading