-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0 parents
commit 43106c7
Showing
18 changed files
with
1,463 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
IMPORTANT: Base your PR off the 'dev' branch and target that branch. | ||
|
||
Also please note that working on a PR doesn't automatically means that your code will be merged. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: Lint | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: psf/black@stable | ||
with: | ||
src: "./any2eln |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,201 @@ | ||
# Created by https://www.toptal.com/developers/gitignore/api/python,vim | ||
# Edit at https://www.toptal.com/developers/gitignore?templates=python,vim | ||
|
||
### Python ### | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
cover/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
.pybuilder/ | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
# For a library or package, you might want to ignore these files since the code is | ||
# intended to run in multiple environments; otherwise, check them in: | ||
# .python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# poetry | ||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. | ||
# This is especially recommended for binary packages to ensure reproducibility, and is more | ||
# commonly ignored for libraries. | ||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control | ||
#poetry.lock | ||
|
||
# pdm | ||
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. | ||
#pdm.lock | ||
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it | ||
# in version control. | ||
# https://pdm.fming.dev/#use-with-ide | ||
.pdm.toml | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# pytype static type analyzer | ||
.pytype/ | ||
|
||
# Cython debug symbols | ||
cython_debug/ | ||
|
||
# PyCharm | ||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can | ||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore | ||
# and can be added to the global gitignore or merged into this file. For a more nuclear | ||
# option (not recommended) you can uncomment the following to ignore the entire idea folder. | ||
#.idea/ | ||
|
||
### Python Patch ### | ||
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration | ||
poetry.toml | ||
|
||
# ruff | ||
.ruff_cache/ | ||
|
||
# LSP config files | ||
pyrightconfig.json | ||
|
||
### Vim ### | ||
# Swap | ||
[._]*.s[a-v][a-z] | ||
!*.svg # comment out if you don't need vector files | ||
[._]*.sw[a-p] | ||
[._]s[a-rt-v][a-z] | ||
[._]ss[a-gi-z] | ||
[._]sw[a-p] | ||
|
||
# Session | ||
Session.vim | ||
Sessionx.vim | ||
|
||
# Temporary | ||
.netrwhist | ||
*~ | ||
# Auto-generated tag files | ||
tags | ||
# Persistent undo | ||
[._]*.un~ | ||
|
||
# End of https://www.toptal.com/developers/gitignore/api/python,vim | ||
local.env | ||
export-* | ||
# used in dev | ||
entries.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# any2eln changelog | ||
|
||
## any2eln 0.1.0 - unreleased |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Developer documentation | ||
|
||
## Run locally | ||
|
||
### Install | ||
|
||
~~~bash | ||
git clone https://gitub.com/TheELNConsortium/any2eln | ||
cd any2eln | ||
python -m venv venv | ||
source venv/bin/activate | ||
poetry install | ||
~~~ | ||
|
||
### Usage | ||
|
||
~~~bash | ||
source local.env | ||
python any2eln | ||
~~~ | ||
|
||
### Api doc | ||
|
||
https://labfolder.labforward.app/api/v2/docs/development.html | ||
|
||
### Using curl | ||
|
||
First, login to get a TOKEN | ||
|
||
~~~bash | ||
curl -X POST -H 'Content-Type: application/json' -d '{"user":"[email protected]", "password": "secr3t"}' https://labfolder.labforward.app/api/v2/auth/login | ||
~~~ | ||
|
||
and copy token in some env var like T. Then: | ||
|
||
~~~bash | ||
curl -H "Authorization: Bearer $T" "https://labfolder.labforward.app/api/v2/templates/26333?expand=entry" | ||
~~~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Nicolas CARPI | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Description | ||
|
||
**any2eln** is a tool to extract data from any Electronic Laboratory Notebook (ELN) software, to a `.eln` archive. | ||
|
||
This `.eln` archive can then easily be re-imported in another ELN. | ||
|
||
# Supported sources | ||
|
||
* [Labfolder](#labfolder-module) (functional) | ||
* Labguru (coming soon) | ||
* Scinote (coming soon) | ||
* Benchling (coming soon) | ||
|
||
# Installation | ||
|
||
~~~ | ||
git clone https://github.com/TheELNConsortium/any2eln | ||
cd any2eln | ||
python -m venv venv | ||
source venv/bin/activate | ||
poetry install | ||
~~~ | ||
|
||
# Usage | ||
|
||
~~~ | ||
python any2eln --help | ||
~~~ | ||
|
||
# Labfolder module | ||
|
||
## Description | ||
|
||
This module allows you to extract all your data from a Labfolder.com account. It goes through all the entries and saves them per author as `.eln` archives. Using this module requires an account on Labfolder.com website. | ||
|
||
The `DATA` elements are converted as `.csv` sheet by sheet, when possible, and the full `.json` metadata is also saved alongside. | ||
|
||
## Disclaimer | ||
|
||
This project is not affiliated with Labfolder software or Labforward GmbH. It simply leverages the [publicly documented API](https://labfolder.labforward.app/api/v2/docs/development.html#notebook-entries) to add a feature: export everything as `.eln`. | ||
|
||
## Usage | ||
|
||
~~~ | ||
python any2eln --src labfolder | ||
~~~ | ||
|
||
The exported data will be saved in the current directory in a folder named `export-Y-m-d-H-M-s`. | ||
|
||
For a more verbose output, add ``DEV=1`` to your execution environment. | ||
|
||
## Caveats | ||
|
||
If there is an error downloading a file for some reason, the error will be logged but the script will continue. Use verbose output (``DEV=1``) to have more information logged. | ||
|
||
# License | ||
|
||
This piece of software is under [MIT license](./LICENSE). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
See https://www.deltablot.com/security/ |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# TheELNConsortium/any2eln | ||
# © 2024 Nicolas CARPi @ Deltablot | ||
# License MIT | ||
import argparse | ||
|
||
from any2eln.labfolder.labfolder import Labfolder | ||
from any2eln.utils.utils import env_or_ask | ||
|
||
|
||
def main(): | ||
sources = ['labfolder', 'labguru', 'scinote', 'benchling'] | ||
parser = argparse.ArgumentParser(description='any2eln') | ||
parser.add_argument('--src', required=True, help='source service you want to export from', choices=sources) | ||
parser.add_argument('--out_dir', required=False, help='output directory', default='.') | ||
args = parser.parse_args() | ||
|
||
if (args.src == 'labfolder'): | ||
username = env_or_ask('LABFOLDER_USERNAME', 'Your Labfolder username or email: ') | ||
password = env_or_ask('LABFOLDER_PASSWORD', 'Your Labfolder password: ') | ||
lf = Labfolder(username, password, out_dir=args.out_dir) | ||
lf.extract() | ||
else: | ||
print('Not implemented.') | ||
|
||
if __name__ == "__main__": | ||
main() |
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# TheELNConsortium/any2eln | ||
# © 2024 Nicolas CARPi @ Deltablot | ||
# License MIT | ||
|
||
from datetime import datetime | ||
from typing import Any | ||
|
||
def get_crate_metadata() -> dict[str, Any]: | ||
crate_metadata: dict[str, Any] = {} | ||
crate_metadata['@context'] = 'https://w3id.org/ro/crate/1.1/context' | ||
crate_metadata['@graph'] = [] | ||
|
||
crate_node: dict[str, Any] = {} | ||
crate_node['@id'] = 'ro-crate-metadata.json' | ||
crate_node['@type'] = 'CreativeWork' | ||
crate_node['about'] = {'@id': './'} | ||
crate_node['conformsTo'] = {'@id': 'https://w3id.org/ro/crate/1.1'} | ||
crate_node['dateCreated'] = datetime.now().strftime('%Y-%m-%dT%H:%M:%S%z') | ||
crate_node['version'] = '1.0' | ||
|
||
crate_metadata['@graph'].append(crate_node) | ||
return crate_metadata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# TheELNConsortium/any2eln | ||
# © 2024 Nicolas CARPi @ Deltablot | ||
# License MIT | ||
import os | ||
|
||
|
||
def env_or_ask(envname: str, prompt: str) -> str: | ||
"""Use env variable if it is set or ask the user""" | ||
res = os.getenv(envname) | ||
if res is not None: | ||
return res | ||
return input(prompt) | ||
|
||
|
||
def debug(line: str) -> None: | ||
"""Only print something if DEV=1 in env""" | ||
if os.getenv('DEV') == '1': | ||
print(line) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export LABFOLDER_USERNAME=you@example.com | ||
export LABFOLDER_PASSWORD='secr3t' | ||
export DEV=0 |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[tool.poetry] | ||
name = "any2eln" | ||
version = "0.1.0" | ||
description = "Tool to transfer data from ELN to .eln" | ||
authors = ["Nicolas CARPi <noreply@deltablot.com>"] | ||
readme = "README.md" | ||
packages = [{include = "any2eln"}] | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.11" | ||
requests = "^2.31.0" | ||
tqdm = "^4.66.1" | ||
pandas = "^2.1.4" | ||
|
||
[tool.poetry.group.dev.dependencies] | ||
mypy = "^1.8.0" | ||
black = "^23.12.1" | ||
isort = "^5.13.2" | ||
types-requests = "^2.31.0.20240106" | ||
types-tqdm = "^4.66.0.20240106" | ||
pandas-stubs = "^2.1.4.231227" | ||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
build-backend = "poetry.core.masonry.api" | ||
|
||
[tool.black] | ||
line-length = 120 | ||
target-version = ['py311'] | ||
skip-string-normalization = true |