Refactor cleaning task and improve FSDB authentication#9
Merged
Conversation
- 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactor
Cleantask inromitask/task.py:keep_pipeline_cfgparameter to optionally retain thepipeline.tomlbackup._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.ask_confirmationfromromitask.utils.keep_metadata, logging, and docstrings.Refactor database usage:
db.connect(unsafe=True)calls to safedb.connect().Update import paths:
plantdb.server.core.utils.compute_fileset_matchesinstead of the REST API module.plantdb.commons.fsdb.FSDBwithplantdb.commons.fsdb.core.FSDBthroughout the project.Improve fileset creation error handling:
FilesetExistsError(imported fromplantdb.commons.fsdb.exceptions) instead of a genericValueError.Add environment‑based FSDB authentication and CLI support:
ROMI_DB_USERandROMI_DB_PASSWORDenvironment variables for login.--db-userand--db-passwordCLI arguments inromi_run_task.py.