From 9dc5c34e0a5812dcef814a3d3e0d5a25c6d9e092 Mon Sep 17 00:00:00 2001 From: Jonathan Legrand Date: Wed, 5 Feb 2025 08:23:23 +0100 Subject: [PATCH] Add script to manage metadata for database scans This script connects to the database, retrieves scans, and updates their metadata for improved classification. --- scripts/add_metadata_to_scan.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 scripts/add_metadata_to_scan.py diff --git a/scripts/add_metadata_to_scan.py b/scripts/add_metadata_to_scan.py new file mode 100644 index 0000000..9a8ab70 --- /dev/null +++ b/scripts/add_metadata_to_scan.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +Metadata Management for Database Scans + +This module provides functionality for adding metadata to scans in a database. + +Key Features: +- Connects to a database using the `FSDB` module. +- Retrieves all available scans from the database. +- Adds or updates metadata to scans for better classification and organization. +- Provides an easy-to-use method for specifying metadata, such as ownership and project details, in bulk or customized workflows. +""" + +import os + +from plantdb.fsdb import FSDB +from plantdb.fsdb_tools import add_metadata_to_scan + +path = os.environ.get('ROMI_DB', None) + +if path is None: + raise ValueError('Environment variable ROMI_DB not set.') + +db = FSDB(path) +db.connect("anonymous") + +for scan in db.get_scans(): + new_md = {"owner": "test", "project": "test"} + add_metadata_to_scan(db, scan, metadata=new_md) \ No newline at end of file