The scingestor
python package provides a support for scripts which ingest Datasets and OrigDatablocks into the SciCat metadata server.
SciCat Dataset ingestor server ingests scan metadata just after a scan is finished. It can be executed by
scicat_dataset_ingestor -c ~/.scingestor.yaml
The configuration written in YAML can contain the following variables
"http://localhost:3000/api/v3"
None
[]
""
""
"ingestor"
""
"no"
, "patch"
, "create"
, "mixed"
) , default: "patch"
False
["/gpfs/current/scratch_bl", "/gpfs/current/processed", "/gpfs/current/shared"]
None
["P"]
None
-1
False
True
False
None
".scan.json"
".origdatablock.json"
".attachment.json"
True
False
False
"beamtime-metadata-"
".json"
"{proposalid}.{beamtimeid}"
"scicat-datasets-{beamtimeid}.lst"
"scicat-ingested-datasets-{beamtimeid}.lst"
"nxsfileinfo metadata -k4 -o {metapath}/{scanname}{scanpostfix} --id-format {idpattern} -b {beamtimefile} -p {beamtimeid}/{scanname} -w {ownergroup} -c {accessgroups} {mastefile}"
"nxsfileinfo metadata -k4 -o {metapath}/{scanname}{scanpostfix} --id-format {idpattern} -c {accessgroups} -w {ownergroup} -b {beamtimefile} -p {beamtimeid}/{scanname}"
"nxsfileinfo origdatablock -s *.pyc,*{datablockpostfix},*{scanpostfix},*~ -p {pidprefix}{beamtimeid}/{scanname} -w {ownergroup} -c {accessgroups} -o {metapath}/{scanname}{datablockpostfix} "
"nxsfileinfo origdatablock -s *.pyc,*{datablockpostfix},*{scanpostfix},*~ -w {ownergroup} -c {accessgroups} -p {pidprefix}{beamtimeid}/{scanname} "
" {scanpath}/{scanname} "
"nxsfileinfo attachment -w {ownergroup} -c {accessgroups} -o {metapath}/{scanname}{attachmentpostfix} {plotfile} "
"nxsfileinfo groupmetadata {lastmeasurement} -m {metapath}/{scanname}{scanpostfix} -d {metapath}/{scanname}{datablockpostfix} -a {metapath}/{scanname}{attachmentpostfix} -p {beamtimeid}/{lastmeasurement} -f -k4 "
""
False
False
False
False
False
False
" --group-map-file {groupmapfile} "
" --raw "
True
["png", "nxs", "h5", "ndf", "nx", "fio"]
["nxs", "h5", "ndf", "nx", "fio"]
" -x {chmod} "
" -r {relpath} "
" --oned "
" --max-oned-size {maxonedsize} "
" --override "
" -n {hiddenattributes} "
"nexdatas_source,nexdatas_strategy,units"
" -s {signals} "
" -e {axes} "
" -m {frame} "
""
""
""
True
False
True
False
False
" --add-empty-units "
True
None
" --copy-map-file {copymapfile} "
1.0
0.1
5.0
100
1000
1000
{"Content-Type": "application/json", "Accept": "application/json"}
"Datasets"
"Proposals"
"OrigDatablocks"
"Datasets/{pid}/Attachments"
"Users/login"
False
["techniques", "classification", "createdBy", "updatedBy", "datasetlifecycle", "numberOfFiles", "size", "createdAt", "updatedAt", "history", "creationTime", "version", "scientificMetadata", "endTime"]
e.g.
beamtime_dirs:
- "{homepath}/gpfs/current"
- "{homepath}/gpfs/commissioning"
scicat_url: http://localhost:3000/api/v3
ingestor_credential_file: "{homepath}/gpfs/pwd"
The datasets_filename_pattern, ingested_datasets_filename_pattern and ingestor_var_dir can contain the {beamtimeid} and {hostname} keywords, e.g. "scicat-ingested-datasets-{beamtimeid}.lst"
or "scicat-ingested-datasets-{hostname}-{beamtimeid}.lst"
which is instantiated during the ingestor execution.
The beamtime_dirs, beamtime_base_dir, ingestor_var_dir, ingestor_credential_file, scandir_blacklist can contain the {homepath} keyword.
Similarly, file_dataset_metadata_generator, dataset_metadata_generator, datablock_metadata_generator, datablock_metadata_stream_generator, datablock_metadata_generator_scanpath_postfix, attachment_metadata_generator, chmod_generator_switch, relative_path_generator_switch can contain the following keywords: {beamtimeid} , {scanname}, {chmod}, {scanpath}, {metapath}, {relpath}, {beamtimeid}, {beamline}, {pidprefix}, {beamtimefile}, {scanpostfix}, {datablockpostfix}, {ownergroup}, {accessgroups}, {hostname}, {homepath}, {hiddenattributes}, {ext}, "{masterfile}", "{plotfile}", "{masterscanname}", "{entryname}"
The "{masterfile}" is either equal to "{scanpath}/{scanname}.{ext}" or "{scanpath}/{scanname}/{scanname}.{ext}". Also the "{plotfile}" is either equal to "{scanpath}/{scanname}.{plotext}" or "{scanpath}/{scanname}/{scanname}.{plotext}".
Re-ingestion script for SciCat Datasets and OrigDatablocks is usually launched at the end of the beamtime.
scicat_dataset_ingest -c ~/.scingestor.yaml
Its configuration written YAML like for scicat_dataset_ingestor
General ingestion script for SciCat Models could be used for manual scicat model ingestion, e.g. Sample, Instrument or DerivedDataset.
scicat_ingest -m Samples -c ~/.scingestor.yaml ./metadata.json
Its configuration written YAML like for scicat_dataset_ingestor
The code from https://github.com/jkotan/scingestor can be built with
python3 setup.py install
To build the documentation use
python3 setup.py build_sphinx
The resulting documentation can be found below build/sphinx/html
in the root
directory of the source distribution.
Finally, the package can be tested using
python3 -m pytest test
The code can be installed in your conda environment by
conda create -n myenv python=3.9
conda activate myenv
pip install inotifyx-py3
pip install scingestor
or in your pip environment by
python3 -m venv myvenv
. myvenv/bin/activate
pip install inotifyx-py3
pip install scingestor
Debian bookworm
, bullseye
, buster
or Ubuntu lunar
, jammy
, focal
packages can be found in the HDRI repository.
To install the debian packages, add the PGP repository key
sudo su
curl -s http://repos.pni-hdri.de/debian_repo.pub.gpg | gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/debian-hdri-repo.gpg --import
chmod 644 /etc/apt/trusted.gpg.d/debian-hdri-repo.gpg
and then download the corresponding source list, e.g.
for bookworm
cd /etc/apt/sources.list.d
wget http://repos.pni-hdri.de/bookworm-pni-hdri.list
or jammy
cd /etc/apt/sources.list.d
wget http://repos.pni-hdri.de/jammy-pni-hdri.list
respectively.
Finally,
apt-get update
apt-get install python3-scingestor
The scicat ingestor triggers its actions on append a new line in the dataset list file. The dataset list file is located in the scan directory and its filename is defined by datasets_filename_pattern variable, i.e. by default "scicat-datasets-{beamtimeid}.lst".
By default the scan dataset metadata are fetched from the corresponding the master file with its filename given by \<scanname>.\<ext> where usually \<ext> is nxs
or fio
. The detector files related to the particular scan are placed in the \<scanname> subdirectory and they are added to the scan origindatablock.
A separete line in the dataset list file may contain
myscan_00012
myscan_00012:1702988846.0770347
myscan_00012 pilatus1 lambda
myscan::/scan12;myscan_00012
__command__ start mycalib6
__command__ stop
The __command__ start \<measurement\>
and __command__ stop
allow to pass information to scicat ingestor which scan datasets should be grouped into the measurement dataset, i.e. by default of scan datasets between start and stop commands are grouped to the one measurement.
The config/scmacros.py module provides sardana macros which help to start/stop the measurement
Setting the SciCatAutoGrouping sardana environment variable to True
we can switch on the autogrouping mode. In this mode scan metadata is grouped automatically into the measurement dataset and the measurement dataset updated after each scan. The name of measurement is taken from the base scanname after removing ScanID, e.g. for <scanname>
= "mycalib2_00012" the measurement name is "mycalib2"