Skip to content

Commit

Permalink
Add script to manage metadata for database scans
Browse files Browse the repository at this point in the history
This script connects to the database, retrieves scans, and updates their metadata for improved classification.
  • Loading branch information
jlegrand62 committed Feb 5, 2025
1 parent 66186f6 commit 9dc5c34
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions scripts/add_metadata_to_scan.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 9dc5c34

Please sign in to comment.