Skip to content

Commit 17d4a45

Browse files
committed
Uploading of the example files in nomad production successfully tested.
Separate upload script in script folder.
1 parent dd4ec98 commit 17d4a45

File tree

9 files changed

+678
-140
lines changed

9 files changed

+678
-140
lines changed

pyproject.toml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ dependencies = [
3636
"Parent Project" = "https://github.com/FAIRmat-NFDI"
3737

3838
[project.optional-dependencies]
39+
nomad = ["nomad-lab >= 1.4.0"]
40+
3941
dev = [
4042
"mypy",
4143
"ruff>=0.14.0",
@@ -52,6 +54,11 @@ docs = [
5254
"mkdocs-simple-hooks",
5355
]
5456

57+
nomad_api = [
58+
"requests",
59+
"nomad-lab >= 1.4.0",
60+
]
61+
5562
[project.entry-points."pynxtools.reader"]
5663
spm = "pynxtools_spm.reader:SPMReader"
5764

@@ -70,7 +77,7 @@ version_scheme = "no-guess-dev"
7077
local_scheme = "node-and-date"
7178

7279
[tool.ruff]
73-
include = ["src/pynxtools_spm/*.py", "tests/*.py"]
80+
include = ["src/pynxtools_spm/**/*.py", "tests/**/*.py"]
7481
lint.select = [
7582
"E", # pycodestyle
7683
"W", # pycodestyle
@@ -101,3 +108,8 @@ ignore_missing_imports = true
101108
follow_imports = "silent"
102109
no_strict_optional = true
103110
disable_error_code = "import, annotation-unchecked"
111+
112+
[tool.uv]
113+
extra-index-url = [
114+
"https://gitlab.mpcdf.mpg.de/api/v4/projects/2187/packages/pypi/simple",
115+
]

scripts/example_upload_script.py

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
from pynxtools_spm.nomad_uploader.uploader import (
2+
run_uploader_with,
3+
NOMADSettings,
4+
DataProcessingSettings,
5+
)
6+
from pathlib import Path
7+
8+
current_dir = Path(__file__).resolve().parent
9+
project_dir = current_dir.parent
10+
11+
nomad_settings = NOMADSettings(
12+
url_protocol="https",
13+
url_domain="nomad-lab.eu",
14+
url_version="prod/v1/develop/api/v1/",
15+
url="https://nomad-lab.eu/prod/v1/develop/api/v1/",
16+
username="",
17+
password="",
18+
token="",
19+
modify_upload_metadata=True,
20+
publish_to_nomad=False,
21+
)
22+
nanonis = project_dir / "tests/data/nanonis"
23+
24+
total_upload = 3
25+
26+
data_proc_settings = DataProcessingSettings(
27+
raw_file_exts=(
28+
".dat",
29+
".sxm",
30+
),
31+
single_batch_processing_time=total_upload * 90, # seconds
32+
src_dir=nanonis,
33+
# copy_file_elsewhere=False,
34+
dst_dir="",
35+
create_pseudo_file=True,
36+
pseudo_exts=".done",
37+
spm_params_obj_l=[],
38+
sts_eln=nanonis / "sts/version_gen_5e_with_described_nxdata/eln_data.yaml",
39+
sts_config="",
40+
stm_eln=nanonis / "stm/version_gen_5_with_described_nxdata/eln_data.yaml",
41+
stm_config="",
42+
afm_eln=nanonis / "afm/version_gen_4_with_described_nxdata/eln_data.yaml",
43+
afm_config="",
44+
logger_dir=current_dir,
45+
number_of_uploads=total_upload,
46+
file_to_convert_data={
47+
f"{nanonis / 'stm/version_gen_5_with_described_nxdata/Au_mica_2023_Y_A_diPAMY_195.sxm'}": {
48+
"eln": "",
49+
"technique": "stm",
50+
},
51+
f"{nanonis / 'sts/version_gen_5e_with_described_nxdata/STS_nanonis_generic_5e_1.dat'}": {
52+
"eln": "",
53+
"technique": "sts",
54+
},
55+
f"{nanonis / 'stm/version_gen_5_with_described_nxdata/Au_mica_2023_Y_A_diPAMY_195.sxm'}": {
56+
"eln": "",
57+
"technique": "stm",
58+
},
59+
f"{nanonis / 'sts/version_gen_5e_with_described_nxdata/STS_nanonis_generic_5e_1.dat'}": {
60+
"eln": "",
61+
"technique": "sts",
62+
},
63+
f"{nanonis / 'stm/version_gen_5_with_described_nxdata/Au_mica_2023_Y_A_diPAMY_195.sxm'}": {
64+
"eln": "",
65+
"technique": "stm",
66+
},
67+
f"{nanonis / 'sts/version_gen_5e_with_described_nxdata/STS_nanonis_generic_5e_1.dat'}": {
68+
"eln": "",
69+
"technique": "sts",
70+
},
71+
f"{nanonis / 'stm/version_gen_5_with_described_nxdata/Au_mica_2023_Y_A_diPAMY_195.sxm'}": {
72+
"eln": "",
73+
"technique": "stm",
74+
},
75+
f"{nanonis / 'sts/version_gen_5e_with_described_nxdata/STS_nanonis_generic_5e_1.dat'}": {
76+
"eln": "",
77+
"technique": "sts",
78+
},
79+
f"{nanonis / 'stm/version_gen_5_with_described_nxdata/Au_mica_2023_Y_A_diPAMY_195.sxm'}": {
80+
"eln": "",
81+
"technique": "stm",
82+
},
83+
f"{nanonis / 'sts/version_gen_5e_with_described_nxdata/STS_nanonis_generic_5e_1.dat'}": {
84+
"eln": "",
85+
"technique": "sts",
86+
},
87+
f"{nanonis / 'stm/version_gen_5_with_described_nxdata/Au_mica_2023_Y_A_diPAMY_195.sxm'}": {
88+
"eln": "",
89+
"technique": "stm",
90+
},
91+
f"{nanonis / 'sts/version_gen_5e_with_described_nxdata/STS_nanonis_generic_5e_1.dat'}": {
92+
"eln": "",
93+
"technique": "sts",
94+
},
95+
f"{nanonis / 'stm/version_gen_5_with_described_nxdata/Au_mica_2023_Y_A_diPAMY_195.sxm'}": {
96+
"eln": "",
97+
"technique": "stm",
98+
},
99+
f"{nanonis / 'sts/version_gen_5e_with_described_nxdata/STS_nanonis_generic_5e_1.dat'}": {
100+
"eln": "",
101+
"technique": "sts",
102+
},
103+
f"{nanonis / 'stm/version_gen_5_with_described_nxdata/Au_mica_2023_Y_A_diPAMY_195.sxm'}": {
104+
"eln": "",
105+
"technique": "stm",
106+
},
107+
f"{nanonis / 'sts/version_gen_5e_with_described_nxdata/STS_nanonis_generic_5e_1.dat'}": {
108+
"eln": "",
109+
"technique": "sts",
110+
},
111+
},
112+
# metadata = {
113+
# "metadata": {
114+
# "upload_name": upload_name,
115+
# "references": ["https://doi.org/xx.xxxx/xxxxxx"],
116+
# "datasets": dataset_id,
117+
# "embargo_length": 0,
118+
# "coauthors": ["coauthor@affiliation.de"],
119+
# "comment": 'This is a test upload...'
120+
# },
121+
# }
122+
upload_metadata={
123+
"metadata": {
124+
"coauthors": ["cojaddl@physik.hu-berlin.de"],
125+
"upload_name": "test_upload",
126+
}
127+
},
128+
)
129+
130+
if __name__ == "__main__":
131+
run_uploader_with(
132+
nomad_settings=nomad_settings,
133+
data_proc_settings=data_proc_settings,
134+
)

run_uploader.sh renamed to scripts/run_uploader.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
# Stop on error
44
set -e
55

6-
current_dir=$(pwd)
7-
uploader_script="/home/rubel/NOMAD-FAIRmat/nomad-distro-dev-RM/packages/pynxtools-spm/src/pynxtools_spm/nomad_uploader/example_upload_script.py"
8-
venv="/home/rubel/NOMAD-FAIRmat/nomad-distro-dev-RM/.venv"
6+
current_dir=$(dirname $(realpath $0))
7+
echo "Current directory: $current_dir"
8+
uploader_script="$current_dir/example_upload_script.py"
9+
venv="/home/rubel/NOMAD-FAIRmat/GH/pynxtools-spm/.venv"
910
python_3="$venv/bin/python3"
1011
echo "Running uploader script..."
1112
"$python_3" "$uploader_script" > "$current_dir/debug.txt" 2>&1

0 commit comments

Comments
 (0)