Skip to content

Refactor cleaning task and improve FSDB authentication#9

Merged
jlegrand62 merged 7 commits into
devfrom
feature/plantdb_auth
Apr 1, 2026
Merged

Refactor cleaning task and improve FSDB authentication#9
jlegrand62 merged 7 commits into
devfrom
feature/plantdb_auth

Conversation

@jlegrand62
Copy link
Copy Markdown
Member

  • Refactor Clean task in romitask/task.py:

    • Add keep_pipeline_cfg parameter to optionally retain the pipeline.toml backup.
    • Introduce several helper methods (_merge_metadata_keep_list, _filesets_to_remove, _delete_filesets, _clean_images_metadata, _clean_orphan_json_files, _clean_orphan_directories, _remove_pipeline_backup, _confirm) for clearer, test‑able logic.
    • Replace inline confirmation with ask_confirmation from romitask.utils.
    • Update imports, type annotation for keep_metadata, logging, and docstrings.
  • Refactor database usage:

    • Switch all db.connect(unsafe=True) calls to safe db.connect().
  • Update import paths:

    • Use plantdb.server.core.utils.compute_fileset_matches instead of the REST API module.
    • Replace plantdb.commons.fsdb.FSDB with plantdb.commons.fsdb.core.FSDB throughout the project.
    • Adjust dummy DB imports and Jupyter notebooks accordingly.
  • Improve fileset creation error handling:

    • Catch FilesetExistsError (imported from plantdb.commons.fsdb.exceptions) instead of a generic ValueError.
  • Add environment‑based FSDB authentication and CLI support:

    • Read ROMI_DB_USER and ROMI_DB_PASSWORD environment variables for login.
    • Introduce --db-user and --db-password CLI arguments in romi_run_task.py.
    • Ensure credentials are passed to the runtime environment.

jlegrand62 and others added 7 commits January 30, 2026 15:07
- Updated `task.py` to handle FSDB authentication using `ROMI_DB_USER` and `ROMI_DB_PASSWORD` environment variables.
- Added CLI arguments to allow passing `--db-user` and `--db-password` for FSDB login in `romi_run_task.py`.
- Ensured that database credentials from CLI or environment variables are passed to the runtime environment in `run_task`.
- Adjusted imports in `romi_run_task.py` for consistency and readability.
Description:
- Replaced all occurrences of `from plantdb.commons.fsdb import FSDB` with `from plantdb.commons.fsdb.core import FSDB` in multiple files.
- Adjusted dummy FSDB imports in test and task files to use `from plantdb.commons.test_database import dummy_db`.
- Updated Jupyter notebooks to reflect the new import paths.
- Ensured compatibility of downstream modules, scripts, and tasks with updated imports.
…`ValueError`

- Import `FilesetExistsError` from `plantdb.commons.fsdb.exceptions` in `romitask/src/romitask/task.py`.
- Update the `try/except` block when creating a fileset to catch `FilesetExistsError` and fallback to `fs_target.get()` for existing filesets.
…ated imports

Signed-off-by: Arthur Luciani <arthur.luciani@ens-lyon.fr>
- Replaced `db.connect(unsafe=True)` with `db.connect()` across multiple files for safer database connections.
- Updated import path for `compute_fileset_matches` to use `plantdb.server.core.utils` instead of `plantdb.server.rest_api`.
- Fixed incorrect use of `sparse_pcd` for dense point cloud arrays in `plant3dvision/colmap.py`.
- Added `keep_pipeline_cfg` parameter to control removal of the `pipeline.toml` backup.
- Introduced helper methods (`_merge_metadata_keep_list`, `_filesets_to_remove`, `_delete_filesets`, `_clean_images_metadata`, `_clean_orphan_json_files`, `_clean_orphan_directories`, `_remove_pipeline_backup`, `_confirm`) to modularize cleaning logic and simplify testing.
- Replaced inline confirmation handling with `ask_confirmation` from `romitask.utils`.
- Updated imports to include `Iterable` and the new `ask_confirmation` helper.
- Fixed type annotation for `keep_metadata` (`luigi.listParameter`).
- Streamlined metadata whitelist creation using the new helper.
- Simplified fileset deletion and orphan metadata cleanup using the new static helpers.
- Added optional pipeline backup removal controlled by `keep_pipeline_cfg`.
- Improved logging messages and docstrings throughout the cleaning workflow.
@jlegrand62 jlegrand62 merged commit db1e7b8 into dev Apr 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants