elabftw-toolkit 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. elabftw_toolkit-0.1.1/LICENSE +201 -0
  2. elabftw_toolkit-0.1.1/PKG-INFO +191 -0
  3. elabftw_toolkit-0.1.1/README.md +148 -0
  4. elabftw_toolkit-0.1.1/pyproject.toml +80 -0
  5. elabftw_toolkit-0.1.1/setup.cfg +4 -0
  6. elabftw_toolkit-0.1.1/src/elabftw_toolkit/__init__.py +62 -0
  7. elabftw_toolkit-0.1.1/src/elabftw_toolkit/_compat.py +132 -0
  8. elabftw_toolkit-0.1.1/src/elabftw_toolkit/_http.py +144 -0
  9. elabftw_toolkit-0.1.1/src/elabftw_toolkit/benten_schema.py +696 -0
  10. elabftw_toolkit-0.1.1/src/elabftw_toolkit/categories.py +138 -0
  11. elabftw_toolkit-0.1.1/src/elabftw_toolkit/client.py +1717 -0
  12. elabftw_toolkit-0.1.1/src/elabftw_toolkit/common.py +1580 -0
  13. elabftw_toolkit-0.1.1/src/elabftw_toolkit/data/benten_schema.json +1822 -0
  14. elabftw_toolkit-0.1.1/src/elabftw_toolkit/dataframe.py +119 -0
  15. elabftw_toolkit-0.1.1/src/elabftw_toolkit/experiments.py +970 -0
  16. elabftw_toolkit-0.1.1/src/elabftw_toolkit/fields.py +307 -0
  17. elabftw_toolkit-0.1.1/src/elabftw_toolkit/files.py +1213 -0
  18. elabftw_toolkit-0.1.1/src/elabftw_toolkit/find.py +351 -0
  19. elabftw_toolkit-0.1.1/src/elabftw_toolkit/html_tables.py +1413 -0
  20. elabftw_toolkit-0.1.1/src/elabftw_toolkit/images.py +520 -0
  21. elabftw_toolkit-0.1.1/src/elabftw_toolkit/items.py +1095 -0
  22. elabftw_toolkit-0.1.1/src/elabftw_toolkit/links.py +436 -0
  23. elabftw_toolkit-0.1.1/src/elabftw_toolkit/maiml.py +623 -0
  24. elabftw_toolkit-0.1.1/src/elabftw_toolkit/mcp_server.py +485 -0
  25. elabftw_toolkit-0.1.1/src/elabftw_toolkit/metadata_utils.py +770 -0
  26. elabftw_toolkit-0.1.1/src/elabftw_toolkit/permissions.py +1495 -0
  27. elabftw_toolkit-0.1.1/src/elabftw_toolkit/plan.py +499 -0
  28. elabftw_toolkit-0.1.1/src/elabftw_toolkit/record.py +94 -0
  29. elabftw_toolkit-0.1.1/src/elabftw_toolkit/schema.py +738 -0
  30. elabftw_toolkit-0.1.1/src/elabftw_toolkit/search.py +559 -0
  31. elabftw_toolkit-0.1.1/src/elabftw_toolkit/statuses.py +131 -0
  32. elabftw_toolkit-0.1.1/src/elabftw_toolkit/steps.py +475 -0
  33. elabftw_toolkit-0.1.1/src/elabftw_toolkit/tags.py +569 -0
  34. elabftw_toolkit-0.1.1/src/elabftw_toolkit/teams.py +133 -0
  35. elabftw_toolkit-0.1.1/src/elabftw_toolkit/templates.py +685 -0
  36. elabftw_toolkit-0.1.1/src/elabftw_toolkit.egg-info/PKG-INFO +191 -0
  37. elabftw_toolkit-0.1.1/src/elabftw_toolkit.egg-info/SOURCES.txt +50 -0
  38. elabftw_toolkit-0.1.1/src/elabftw_toolkit.egg-info/dependency_links.txt +1 -0
  39. elabftw_toolkit-0.1.1/src/elabftw_toolkit.egg-info/entry_points.txt +2 -0
  40. elabftw_toolkit-0.1.1/src/elabftw_toolkit.egg-info/requires.txt +18 -0
  41. elabftw_toolkit-0.1.1/src/elabftw_toolkit.egg-info/top_level.txt +1 -0
  42. elabftw_toolkit-0.1.1/tests/test_benten_schema.py +191 -0
  43. elabftw_toolkit-0.1.1/tests/test_client.py +330 -0
  44. elabftw_toolkit-0.1.1/tests/test_compat.py +88 -0
  45. elabftw_toolkit-0.1.1/tests/test_find.py +171 -0
  46. elabftw_toolkit-0.1.1/tests/test_maiml.py +110 -0
  47. elabftw_toolkit-0.1.1/tests/test_maiml_check.py +96 -0
  48. elabftw_toolkit-0.1.1/tests/test_maiml_read.py +65 -0
  49. elabftw_toolkit-0.1.1/tests/test_mcp_server.py +112 -0
  50. elabftw_toolkit-0.1.1/tests/test_plan.py +226 -0
  51. elabftw_toolkit-0.1.1/tests/test_schema.py +292 -0
  52. elabftw_toolkit-0.1.1/tests/test_utils.py +433 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Japan Synchrotron Radiation Research Institute (JASRI) and Takahiro Matsumoto
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,191 @@
1
+ Metadata-Version: 2.4
2
+ Name: elabftw-toolkit
3
+ Version: 0.1.1
4
+ Summary: A Python toolkit for automating and standardizing eLabFTW API workflows
5
+ Author-email: Takahiro Matsumoto <matumot@jasri.jp>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/jasri-jp/elabftw-toolkit
8
+ Project-URL: Documentation, https://jasri-jp.github.io/elabftw-toolkit/
9
+ Project-URL: Repository, https://github.com/jasri-jp/elabftw-toolkit.git
10
+ Project-URL: Issues, https://github.com/jasri-jp/elabftw-toolkit/issues
11
+ Keywords: eLabFTW,ELN,electronic lab notebook,MaiML,synchrotron,research data management,MCP
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Natural Language :: English
15
+ Classifier: Natural Language :: Japanese
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3 :: Only
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Topic :: Scientific/Engineering
24
+ Requires-Python: >=3.10
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: elabapi-python
28
+ Requires-Dist: pandas
29
+ Requires-Dist: python-dotenv
30
+ Requires-Dist: requests
31
+ Requires-Dist: beautifulsoup4
32
+ Requires-Dist: pillow
33
+ Requires-Dist: urllib3
34
+ Requires-Dist: ipython
35
+ Provides-Extra: maiml
36
+ Requires-Dist: pymaiml<2.0,>=1.0; extra == "maiml"
37
+ Provides-Extra: mcp
38
+ Requires-Dist: mcp>=1.0; extra == "mcp"
39
+ Provides-Extra: benten
40
+ Requires-Dist: pyyaml; extra == "benten"
41
+ Requires-Dist: openpyxl; extra == "benten"
42
+ Dynamic: license-file
43
+
44
+ # elabftw-toolkit
45
+
46
+ eLabFTW の実験ノート(Experiment)と Resource / Database item を Python から操作するための、非公式の toolkit です。
47
+ テンプレートからの作成、項目の読み書き、ファイルの添付、リンク、権限、lock などのよくある作業を、短いスクリプトで書けます。
48
+
49
+ **📖 ドキュメント(利用者ガイド・チートシート・レシピ集): https://jasri-jp.github.io/elabftw-toolkit/**
50
+
51
+ [English](https://github.com/jasri-jp/elabftw-toolkit/blob/main/README_en.md) / [利用者ガイド](https://jasri-jp.github.io/elabftw-toolkit/manual/01) / [ドキュメントサイト](https://jasri-jp.github.io/elabftw-toolkit/)
52
+
53
+ > eLabFTW 本体・公式 SDK とは別のプロジェクトです。eLabFTW のバージョンや設定によって動きが変わることがあるので、本番で使う前に検証用の entry で試してください。
54
+
55
+ ## できること
56
+
57
+ - **作る**:テンプレートから実験ノートや Resource item を作る(本文・項目・Steps・権限を引き継ぐ)
58
+ - **読む・書く**:項目の値を `entry.fields["purity"]` のように dict と同じ感覚で扱う
59
+ - **探す**:一覧を表 (DataFrame) で、全件を JSON で取得する。条件検索や title での検索もできる
60
+ - **添付する**:ファイルの添付(同じファイルは飛ばす)、一括ダウンロード、本文への画像の追加、PDF / ELN / JSON での書き出し
61
+ - **つなぐ・管理する**:entry どうしのリンク、タグ、権限、lock とタイムスタンプ、本文の表と Steps
62
+ - **安全に書き込む**:書き込まずに試す(dry_run)、スキーマでの確認、二重登録の防止、変更者の記録
63
+ - **書き出す**:MaiML(JIS K 0200)形式への書き出し(追加インストールが必要)
64
+
65
+ ## インストール
66
+
67
+ Python 3.10 以上が必要です。
68
+
69
+ ```bash
70
+ python -m pip install elabftw-toolkit # 基本
71
+ python -m pip install "elabftw-toolkit[maiml]" # MaiML への書き出しも使う場合
72
+ python -m pip install "elabftw-toolkit[mcp]" # MCP サーバー(Claude Desktop など)も使う場合
73
+ python -m pip install "elabftw-toolkit[benten]" # BENTEN のメタデータ(YAML・Excel)も扱う場合
74
+ ```
75
+
76
+ 開発する場合(ソースを直しながら使う)は、clone して editable install にします。
77
+
78
+ ```bash
79
+ git clone https://github.com/jasri-jp/elabftw-toolkit.git
80
+ cd elabftw-toolkit
81
+ python -m pip install -e ".[maiml,mcp,benten]"
82
+ ```
83
+
84
+ ## 設定
85
+
86
+ eLabFTW の接続先と API key を環境変数で指定します。
87
+
88
+ ```bash
89
+ ELABFTW_HOST_URL="https://your-elabftw.example.jp"
90
+ ELABFTW_API_KEY="your-api-key"
91
+ ```
92
+
93
+ - API key をファイルに置くときは、`ELABFTW_API_KEY` の代わりに `ELABFTW_KEY_FILE="/path/to/api_key.txt"` を使います。
94
+ - `.env` ファイルは自動では読みません。使うときは先に `from dotenv import load_dotenv; load_dotenv()` を呼びます。
95
+ - 引数での指定や SSL の設定は [1. はじめに](https://jasri-jp.github.io/elabftw-toolkit/manual/01) を見てください。
96
+
97
+ ## 5 分で試す
98
+
99
+ ```python
100
+ import elabftw_toolkit
101
+
102
+ elab = elabftw_toolkit.client("your-team-name")
103
+
104
+ # 試料を title で探して開く
105
+ sample = elab.items.find("TEST_SAMPLE", category_title="試料")
106
+ entry = elab.items.entry(sample.id)
107
+
108
+ # 項目を読む・書く
109
+ print(entry.fields["purity"])
110
+ entry.fields.update({"purity": "99.9%", "form": "粉末"})
111
+
112
+ # lock されていても、一時的に外して書き換える(終わったら元に戻る)
113
+ with entry.unlocked():
114
+ entry.fields["purity"] = "99.99%"
115
+
116
+ # ファイルを添付する(同じファイルがあれば飛ばす)
117
+ entry.files.upload("coa.pdf")
118
+
119
+ # テンプレートから実験ノートを作り、試料とつなぐ
120
+ exp_id = elab.experiments.init(
121
+ title="2026T0001-XAFS-TEST_SAMPLE",
122
+ template_name="計測試験",
123
+ category_id=elab.experiments.categories.id("計測"),
124
+ )
125
+ elab.experiments.entry(exp_id).set_item_field_and_link(
126
+ field_name="sample_id", item_title="TEST_SAMPLE", item_category_title="試料",
127
+ )
128
+ ```
129
+
130
+ `"試料"`・`"計測"`・`"計測試験"` などの名前は例です。お使いの eLabFTW の設定に合わせてください。
131
+
132
+ ## 利用者ガイド
133
+
134
+ | やりたいこと | ページ |
135
+ | --- | --- |
136
+ | 使い始める | [1. はじめに](https://jasri-jp.github.io/elabftw-toolkit/manual/01)、[12. トラブルシューティング](https://jasri-jp.github.io/elabftw-toolkit/manual/12) |
137
+ | 読む・探す | [2. entry と項目](https://jasri-jp.github.io/elabftw-toolkit/manual/02)、[3. 一覧と検索](https://jasri-jp.github.io/elabftw-toolkit/manual/03) |
138
+ | 作る・添付する・つなぐ | [4. 作成とテンプレート](https://jasri-jp.github.io/elabftw-toolkit/manual/04)、[5. 添付ファイルと画像](https://jasri-jp.github.io/elabftw-toolkit/manual/05)、[6. リンクとタグ](https://jasri-jp.github.io/elabftw-toolkit/manual/06) |
139
+ | 権限・lock・本文の表 | [7. 権限](https://jasri-jp.github.io/elabftw-toolkit/manual/07)、[8. lock とタイムスタンプ](https://jasri-jp.github.io/elabftw-toolkit/manual/08)、[9. HTML の表と Steps](https://jasri-jp.github.io/elabftw-toolkit/manual/09) |
140
+ | まとめて処理する・書き出す | [11. よくある作業の手順集](https://jasri-jp.github.io/elabftw-toolkit/manual/11)、[10. MaiML への書き出し](https://jasri-jp.github.io/elabftw-toolkit/manual/10) |
141
+ | 安全に書き込む | [15. 確かめと計画](https://jasri-jp.github.io/elabftw-toolkit/manual/15) |
142
+ | 関数を調べる・古いスクリプトを直す | [14. API 一覧](https://jasri-jp.github.io/elabftw-toolkit/manual/14) |
143
+ | 開発に参加する | [13. テストと開発](https://jasri-jp.github.io/elabftw-toolkit/manual/13) |
144
+ | Claude などの AI から使う・AI と一緒に作る | [16. MCP サーバー](https://jasri-jp.github.io/elabftw-toolkit/manual/16)、[17. AI と一緒に作る](https://jasri-jp.github.io/elabftw-toolkit/manual/17) |
145
+
146
+ ## ドキュメントサイト
147
+
148
+ 公開版: **https://jasri-jp.github.io/elabftw-toolkit/** (`main` に push すると GitHub Actions で作り直されます。`.github/workflows/docs.yml`)
149
+
150
+ 同じガイドを、はじめての方向けの説明・チートシート・レシピと一緒にブラウザで読めます([VitePress](https://vitepress.dev/)、[Node.js](https://nodejs.org/) が要る)。
151
+
152
+ ```bash
153
+ npm install
154
+ npm run dev # ガイドを取り込んで http://localhost:5173 で開く
155
+ npm run build # docs/.vitepress/dist/ に HTML を書き出す
156
+ ```
157
+
158
+ Windows では **`docs_preview.bat` をダブルクリック**すると、原稿を取り込んでブラウザで開きます(Node.js が要る)。
159
+ Google Drive などの同期フォルダの中でも動くように、サイトを `%USERPROFILE%\.cache\elabftw-toolkit-docs` に写して、そこで動かします
160
+ (初回だけ VitePress を入れるので少し時間がかかる)。原稿を直したら、もう一度ダブルクリックしてください。
161
+
162
+ | 内容 | 置き場所 |
163
+ | --- | --- |
164
+ | 利用者ガイドの原稿(日本語・英語) | `docs/ja`・`docs/en`(章の順は `mkdocs.yml`) |
165
+ | トップページ・はじめての方へ・チートシート・レシピ集 | `docs/index.md`・`docs/guide/`・`docs/recipes/`・`docs/en/index.md`・`docs/en/guide/` |
166
+ | 図・画像 | `docs/public/` |
167
+ | サイトの設定 | `docs/.vitepress/` |
168
+
169
+ `scripts/sync-manual.mjs` が原稿を章番号の URL(`/manual/04`、`/en/manual/04`)に写し、`examples/` の見本をダウンロードできるように置きます(どちらも生成物なので git には入れない)。
170
+ Google Drive などの同期フォルダの中では `node_modules` のリンクを作れず、`npm run dev` / `build` が失敗します。そのときは `docs_preview.bat` を使うか、同期の外に写して動かしてください。
171
+
172
+ ## テスト
173
+
174
+ ```bash
175
+ python -m pip install -e ".[maiml]" pytest
176
+ pytest # eLabFTW には接続しない
177
+ ```
178
+
179
+ `tests/live/` は実サーバーに書き込む確認用スクリプトで、`pytest` では実行しません。詳しくは [13. テストと開発](https://jasri-jp.github.io/elabftw-toolkit/manual/13) を見てください。
180
+
181
+ ## ライセンス
182
+
183
+ Apache License 2.0([LICENSE](https://github.com/jasri-jp/elabftw-toolkit/blob/main/LICENSE))
184
+
185
+ このライブラリは eLabFTW の REST API を使うための補助ライブラリとして独自に実装したものです。eLabFTW のサーバー側のソースコードは含まず、改変・再配布もしていません。eLabFTW API の Python クライアント `elabapi-python`(MIT License)と組み合わせて使います。
186
+
187
+ 設計と利用例の検討では、NAIST の eLabFTW 関連リポジトリ [naist-eln/eln](https://github.com/naist-eln/eln) を参考にしましたが、コードをそのまま複製したものではありません。なお、NAIST のリポジトリの `API/` には GNU Affero General Public License v3.0(AGPL-3.0)のライセンスファイルが含まれています。
188
+
189
+ ---
190
+
191
+ Copyright 2026 Japan Synchrotron Radiation Research Institute (JASRI) and Takahiro Matsumoto
@@ -0,0 +1,148 @@
1
+ # elabftw-toolkit
2
+
3
+ eLabFTW の実験ノート(Experiment)と Resource / Database item を Python から操作するための、非公式の toolkit です。
4
+ テンプレートからの作成、項目の読み書き、ファイルの添付、リンク、権限、lock などのよくある作業を、短いスクリプトで書けます。
5
+
6
+ **📖 ドキュメント(利用者ガイド・チートシート・レシピ集): https://jasri-jp.github.io/elabftw-toolkit/**
7
+
8
+ [English](https://github.com/jasri-jp/elabftw-toolkit/blob/main/README_en.md) / [利用者ガイド](https://jasri-jp.github.io/elabftw-toolkit/manual/01) / [ドキュメントサイト](https://jasri-jp.github.io/elabftw-toolkit/)
9
+
10
+ > eLabFTW 本体・公式 SDK とは別のプロジェクトです。eLabFTW のバージョンや設定によって動きが変わることがあるので、本番で使う前に検証用の entry で試してください。
11
+
12
+ ## できること
13
+
14
+ - **作る**:テンプレートから実験ノートや Resource item を作る(本文・項目・Steps・権限を引き継ぐ)
15
+ - **読む・書く**:項目の値を `entry.fields["purity"]` のように dict と同じ感覚で扱う
16
+ - **探す**:一覧を表 (DataFrame) で、全件を JSON で取得する。条件検索や title での検索もできる
17
+ - **添付する**:ファイルの添付(同じファイルは飛ばす)、一括ダウンロード、本文への画像の追加、PDF / ELN / JSON での書き出し
18
+ - **つなぐ・管理する**:entry どうしのリンク、タグ、権限、lock とタイムスタンプ、本文の表と Steps
19
+ - **安全に書き込む**:書き込まずに試す(dry_run)、スキーマでの確認、二重登録の防止、変更者の記録
20
+ - **書き出す**:MaiML(JIS K 0200)形式への書き出し(追加インストールが必要)
21
+
22
+ ## インストール
23
+
24
+ Python 3.10 以上が必要です。
25
+
26
+ ```bash
27
+ python -m pip install elabftw-toolkit # 基本
28
+ python -m pip install "elabftw-toolkit[maiml]" # MaiML への書き出しも使う場合
29
+ python -m pip install "elabftw-toolkit[mcp]" # MCP サーバー(Claude Desktop など)も使う場合
30
+ python -m pip install "elabftw-toolkit[benten]" # BENTEN のメタデータ(YAML・Excel)も扱う場合
31
+ ```
32
+
33
+ 開発する場合(ソースを直しながら使う)は、clone して editable install にします。
34
+
35
+ ```bash
36
+ git clone https://github.com/jasri-jp/elabftw-toolkit.git
37
+ cd elabftw-toolkit
38
+ python -m pip install -e ".[maiml,mcp,benten]"
39
+ ```
40
+
41
+ ## 設定
42
+
43
+ eLabFTW の接続先と API key を環境変数で指定します。
44
+
45
+ ```bash
46
+ ELABFTW_HOST_URL="https://your-elabftw.example.jp"
47
+ ELABFTW_API_KEY="your-api-key"
48
+ ```
49
+
50
+ - API key をファイルに置くときは、`ELABFTW_API_KEY` の代わりに `ELABFTW_KEY_FILE="/path/to/api_key.txt"` を使います。
51
+ - `.env` ファイルは自動では読みません。使うときは先に `from dotenv import load_dotenv; load_dotenv()` を呼びます。
52
+ - 引数での指定や SSL の設定は [1. はじめに](https://jasri-jp.github.io/elabftw-toolkit/manual/01) を見てください。
53
+
54
+ ## 5 分で試す
55
+
56
+ ```python
57
+ import elabftw_toolkit
58
+
59
+ elab = elabftw_toolkit.client("your-team-name")
60
+
61
+ # 試料を title で探して開く
62
+ sample = elab.items.find("TEST_SAMPLE", category_title="試料")
63
+ entry = elab.items.entry(sample.id)
64
+
65
+ # 項目を読む・書く
66
+ print(entry.fields["purity"])
67
+ entry.fields.update({"purity": "99.9%", "form": "粉末"})
68
+
69
+ # lock されていても、一時的に外して書き換える(終わったら元に戻る)
70
+ with entry.unlocked():
71
+ entry.fields["purity"] = "99.99%"
72
+
73
+ # ファイルを添付する(同じファイルがあれば飛ばす)
74
+ entry.files.upload("coa.pdf")
75
+
76
+ # テンプレートから実験ノートを作り、試料とつなぐ
77
+ exp_id = elab.experiments.init(
78
+ title="2026T0001-XAFS-TEST_SAMPLE",
79
+ template_name="計測試験",
80
+ category_id=elab.experiments.categories.id("計測"),
81
+ )
82
+ elab.experiments.entry(exp_id).set_item_field_and_link(
83
+ field_name="sample_id", item_title="TEST_SAMPLE", item_category_title="試料",
84
+ )
85
+ ```
86
+
87
+ `"試料"`・`"計測"`・`"計測試験"` などの名前は例です。お使いの eLabFTW の設定に合わせてください。
88
+
89
+ ## 利用者ガイド
90
+
91
+ | やりたいこと | ページ |
92
+ | --- | --- |
93
+ | 使い始める | [1. はじめに](https://jasri-jp.github.io/elabftw-toolkit/manual/01)、[12. トラブルシューティング](https://jasri-jp.github.io/elabftw-toolkit/manual/12) |
94
+ | 読む・探す | [2. entry と項目](https://jasri-jp.github.io/elabftw-toolkit/manual/02)、[3. 一覧と検索](https://jasri-jp.github.io/elabftw-toolkit/manual/03) |
95
+ | 作る・添付する・つなぐ | [4. 作成とテンプレート](https://jasri-jp.github.io/elabftw-toolkit/manual/04)、[5. 添付ファイルと画像](https://jasri-jp.github.io/elabftw-toolkit/manual/05)、[6. リンクとタグ](https://jasri-jp.github.io/elabftw-toolkit/manual/06) |
96
+ | 権限・lock・本文の表 | [7. 権限](https://jasri-jp.github.io/elabftw-toolkit/manual/07)、[8. lock とタイムスタンプ](https://jasri-jp.github.io/elabftw-toolkit/manual/08)、[9. HTML の表と Steps](https://jasri-jp.github.io/elabftw-toolkit/manual/09) |
97
+ | まとめて処理する・書き出す | [11. よくある作業の手順集](https://jasri-jp.github.io/elabftw-toolkit/manual/11)、[10. MaiML への書き出し](https://jasri-jp.github.io/elabftw-toolkit/manual/10) |
98
+ | 安全に書き込む | [15. 確かめと計画](https://jasri-jp.github.io/elabftw-toolkit/manual/15) |
99
+ | 関数を調べる・古いスクリプトを直す | [14. API 一覧](https://jasri-jp.github.io/elabftw-toolkit/manual/14) |
100
+ | 開発に参加する | [13. テストと開発](https://jasri-jp.github.io/elabftw-toolkit/manual/13) |
101
+ | Claude などの AI から使う・AI と一緒に作る | [16. MCP サーバー](https://jasri-jp.github.io/elabftw-toolkit/manual/16)、[17. AI と一緒に作る](https://jasri-jp.github.io/elabftw-toolkit/manual/17) |
102
+
103
+ ## ドキュメントサイト
104
+
105
+ 公開版: **https://jasri-jp.github.io/elabftw-toolkit/** (`main` に push すると GitHub Actions で作り直されます。`.github/workflows/docs.yml`)
106
+
107
+ 同じガイドを、はじめての方向けの説明・チートシート・レシピと一緒にブラウザで読めます([VitePress](https://vitepress.dev/)、[Node.js](https://nodejs.org/) が要る)。
108
+
109
+ ```bash
110
+ npm install
111
+ npm run dev # ガイドを取り込んで http://localhost:5173 で開く
112
+ npm run build # docs/.vitepress/dist/ に HTML を書き出す
113
+ ```
114
+
115
+ Windows では **`docs_preview.bat` をダブルクリック**すると、原稿を取り込んでブラウザで開きます(Node.js が要る)。
116
+ Google Drive などの同期フォルダの中でも動くように、サイトを `%USERPROFILE%\.cache\elabftw-toolkit-docs` に写して、そこで動かします
117
+ (初回だけ VitePress を入れるので少し時間がかかる)。原稿を直したら、もう一度ダブルクリックしてください。
118
+
119
+ | 内容 | 置き場所 |
120
+ | --- | --- |
121
+ | 利用者ガイドの原稿(日本語・英語) | `docs/ja`・`docs/en`(章の順は `mkdocs.yml`) |
122
+ | トップページ・はじめての方へ・チートシート・レシピ集 | `docs/index.md`・`docs/guide/`・`docs/recipes/`・`docs/en/index.md`・`docs/en/guide/` |
123
+ | 図・画像 | `docs/public/` |
124
+ | サイトの設定 | `docs/.vitepress/` |
125
+
126
+ `scripts/sync-manual.mjs` が原稿を章番号の URL(`/manual/04`、`/en/manual/04`)に写し、`examples/` の見本をダウンロードできるように置きます(どちらも生成物なので git には入れない)。
127
+ Google Drive などの同期フォルダの中では `node_modules` のリンクを作れず、`npm run dev` / `build` が失敗します。そのときは `docs_preview.bat` を使うか、同期の外に写して動かしてください。
128
+
129
+ ## テスト
130
+
131
+ ```bash
132
+ python -m pip install -e ".[maiml]" pytest
133
+ pytest # eLabFTW には接続しない
134
+ ```
135
+
136
+ `tests/live/` は実サーバーに書き込む確認用スクリプトで、`pytest` では実行しません。詳しくは [13. テストと開発](https://jasri-jp.github.io/elabftw-toolkit/manual/13) を見てください。
137
+
138
+ ## ライセンス
139
+
140
+ Apache License 2.0([LICENSE](https://github.com/jasri-jp/elabftw-toolkit/blob/main/LICENSE))
141
+
142
+ このライブラリは eLabFTW の REST API を使うための補助ライブラリとして独自に実装したものです。eLabFTW のサーバー側のソースコードは含まず、改変・再配布もしていません。eLabFTW API の Python クライアント `elabapi-python`(MIT License)と組み合わせて使います。
143
+
144
+ 設計と利用例の検討では、NAIST の eLabFTW 関連リポジトリ [naist-eln/eln](https://github.com/naist-eln/eln) を参考にしましたが、コードをそのまま複製したものではありません。なお、NAIST のリポジトリの `API/` には GNU Affero General Public License v3.0(AGPL-3.0)のライセンスファイルが含まれています。
145
+
146
+ ---
147
+
148
+ Copyright 2026 Japan Synchrotron Radiation Research Institute (JASRI) and Takahiro Matsumoto
@@ -0,0 +1,80 @@
1
+ [project]
2
+ name = "elabftw-toolkit"
3
+ version = "0.1.1"
4
+ description = "A Python toolkit for automating and standardizing eLabFTW API workflows"
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ license = "Apache-2.0"
8
+ authors = [
9
+ { name = "Takahiro Matsumoto", email = "matumot@jasri.jp" }
10
+ ]
11
+ keywords = ["eLabFTW", "ELN", "electronic lab notebook", "MaiML", "synchrotron", "research data management", "MCP"]
12
+ classifiers = [
13
+ "Development Status :: 3 - Alpha",
14
+ "Intended Audience :: Science/Research",
15
+ "Natural Language :: English",
16
+ "Natural Language :: Japanese",
17
+ "Operating System :: OS Independent",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3 :: Only",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Programming Language :: Python :: 3.13",
24
+ "Topic :: Scientific/Engineering",
25
+ ]
26
+ dependencies = [
27
+ "elabapi-python",
28
+ "pandas",
29
+ "python-dotenv",
30
+ "requests",
31
+ "beautifulsoup4",
32
+ "pillow",
33
+ "urllib3",
34
+ "ipython",
35
+ ]
36
+
37
+ [project.urls]
38
+ Homepage = "https://github.com/jasri-jp/elabftw-toolkit"
39
+ Documentation = "https://jasri-jp.github.io/elabftw-toolkit/"
40
+ Repository = "https://github.com/jasri-jp/elabftw-toolkit.git"
41
+ Issues = "https://github.com/jasri-jp/elabftw-toolkit/issues"
42
+
43
+ [project.optional-dependencies]
44
+ maiml = [
45
+ "pymaiml>=1.0,<2.0",
46
+ ]
47
+ mcp = [
48
+ "mcp>=1.0",
49
+ ]
50
+ benten = [
51
+ "pyyaml",
52
+ "openpyxl",
53
+ ]
54
+
55
+ [project.scripts]
56
+ elabftw-mcp = "elabftw_toolkit.mcp_server:main"
57
+
58
+ [tool.pytest.ini_options]
59
+ # tests/live/ は実際の eLabFTW サーバーに書き込むスクリプトなので pytest では集めない
60
+ testpaths = ["tests"]
61
+ # 入れた写し(site-packages)ではなく、手元の src を確かめる
62
+ pythonpath = ["src"]
63
+ addopts = ["--ignore=tests/live"]
64
+
65
+ [tool.ruff.lint]
66
+ # python -m pip install ruff のあと ruff check src tests で確かめる
67
+ select = ["F", "B", "E9", "W6", "UP", "I", "PIE", "RUF100"]
68
+ # B023: ループ内で作ってその場で呼ぶ関数(SDK の版で違うメソッド名・引数を順に試す処理)
69
+ # B905: zip() の長さ違いは既存の動きのまま(strict を付けると例外になる)
70
+ ignore = ["B023", "B905"]
71
+
72
+ [tool.setuptools.packages.find]
73
+ where = ["src"]
74
+
75
+ [tool.setuptools.package-data]
76
+ elabftw_toolkit = ["data/*.json"]
77
+
78
+ [build-system]
79
+ requires = ["setuptools>=68", "wheel"]
80
+ build-backend = "setuptools.build_meta"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+