Skip to content

Add MVP ELN integration for eLabFTW and Kadi4Mat - #158

Open
linuxrider wants to merge 5 commits into
echemdb:mainfrom
linuxrider:eln-api
Open

Add MVP ELN integration for eLabFTW and Kadi4Mat#158
linuxrider wants to merge 5 commits into
echemdb:mainfrom
linuxrider:eln-api

Conversation

@linuxrider

Copy link
Copy Markdown
Contributor

Introduce unitpackage.eln with a shared BaseELNClient ABC and two backend implementations (ElabFTWClient, KadiClient) that support fetch_entry, fetch_entries, upload_entry, and info operations.

Includes Click CLI (unitpackage elabftw/kadi), TOML-based config profiles, fixture recording infrastructure for replay-based tests, and recorded fixtures from eLabFTW 5.5.14 and Kadi4Mat 1.10.0.

Checklist

  • Added an entry in doc/news/.
  • Added a test for this change.
  • Adapted the documentation for this change.

Introduce unitpackage.eln with a shared BaseELNClient ABC and two
backend implementations (ElabFTWClient, KadiClient) that support
fetch_entry, fetch_entries, upload_entry, and info operations.

Includes Click CLI (unitpackage elabftw/kadi), TOML-based config
profiles, fixture recording infrastructure for replay-based tests,
and recorded fixtures from eLabFTW 5.5.14 and Kadi4Mat 1.10.0.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@CAOShurong

Copy link
Copy Markdown

Independent interoperability check at head 424c5b21005a9fbfa4a7c4ea7eb5c21a4c6c1932 (original base 1332b8907f7e5eb106ea9e0c29958bad56b4a72a):

  • On Windows/Python 3.12 with elabapi-python 5.6.1 and kadi-apy 0.51.0, I replayed the checked-in, GPL-3.0-or-later fixtures from eLabFTW 5.5.14 and Kadi4Mat 1.10.0 through the two actual fetch_entry implementations, without network calls or external archives.
  • The resulting Entry objects were equivalent across the DataFrame, complete field descriptors, resource metadata, and identifier: 3 rows; columns t,E,j; units s,V,A / m2; identifier fixture_test; citation key fixture_test_2026.
  • Both reconstructed CSVs and the recorded source payload have SHA-256 e2660b35fbdf08ca162947aa9fd72fd1d1c6f8e1bd4c6cdb1c52f3e4d87b35e7.
  • Focused recorded-response tests: 25 passed. Full pytest -q --doctest-modules unitpackage: 340 passed, 3 failed; the three failures are the same Windows config_path assertions already visible in Actions, so I did not treat them as a new interoperability finding. The pinned base ran 149 passed and does not contain unitpackage.eln.

Minimal cross-backend comparison using the PR's fixture wiring:

import pandas as pd
from unitpackage.test.eln.test_elabftw import TestFixtureVersions as ElabReplay
from unitpackage.test.eln.test_kadi import TestFixtureVersions as KadiReplay

def field_map(entry):
    values = [f.to_dict() if hasattr(f, "to_dict") else f for f in entry.fields]
    return {f["name"]: f for f in values}

ec, eid = ElabReplay()._wire_client("5.5.14")
kc, record = KadiReplay()._wire_client("1.10.0")
e = ec.fetch_entry(eid)
k = kc.fetch_entry(record.id)
pd.testing.assert_frame_equal(e.df, k.df)
assert field_map(e) == field_map(k)
assert e.resource.custom["metadata"] == k.resource.custom["metadata"]
assert e.identifier == k.identifier == "fixture_test"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants