Skip to content

Add no-auth session manager to romi_run_task CLI#10

Merged
jlegrand62 merged 13 commits into
devfrom
feature/plantdb_auth
May 7, 2026
Merged

Add no-auth session manager to romi_run_task CLI#10
jlegrand62 merged 13 commits into
devfrom
feature/plantdb_auth

Conversation

@jlegrand62
Copy link
Copy Markdown
Member

Summary

This change adds a --no‑auth option to the romi_run_task CLI, allowing the task to run without specifying a username and password.
The goal is to enable the use of NoAuthSessionManager to remove the necessity to set username and password by using the --no-auth option in place of --db-user and --db-password.

To protect production databases, the ROMI_DB_NOAUTH variable defaults to 0 (or can be set in a .env file). When it is 0, the --no‑auth flag is disabled.

Details

  • Environment loading: Load environment variables from <dataset_path>/.env using dotenv_values and merge them into a custom env dictionary.
  • New CLI flag: Add --no-auth CLI flag; when used, ROMI_DB_NOAUTH is set to "1" unless explicitly overridden, allowing testing without DB authentication.
  • Task invocation: Pass the no_auth argument through run_task and to the FSDB constructor, skipping DB login when authentication is disabled and using ROMI_DB_USER / ROMI_DB_PASSWORD otherwise.
  • Import update: Change the dummy_db import to plantdb.commons.test_database.

Miscellaneous

  • Set MPLBACKEND=Agg in the luigi subprocess environment to enforce a non‑interactive Matplotlib backend.
  • Replace occurrences of “associated to” with “associated with” for consistent phrasing.

- Replaced "associated to" with "associated with" across multiple files for consistent phrasing.
- Read `ROMI_DB_NOAUTH` from the environment and pass it as `no_auth` to `FSDB` constructor in `romitask/src/romitask/task.py`
- Perform `db.login` only when `no_auth` is false, using `ROMI_DB_USER` and `ROMI_DB_PASSWORD` environment variables
- Preserve existing behavior by defaulting `no_auth` to `False` when the variable is unset
- Ensure DB connection is still established with `db.connect()` before conditional login
- Import `dotenv_values` and read environment variables from `<dataset_path>/.env`.
- Introduce `--no-auth` CLI flag for testing with automatic admin login.
- Merge dotenv values into a custom `env` dict and set `LUIGI_CONFIG_PARSER`, `LUIGI_CONFIG_PATH`, and default `PYOPENCL_CTX`.
- When `--no-auth` is used, ensure `ROMI_DB_NOAUTH` is set to `"1"` unless explicitly disabled via environment or `.env`.
- Update subprocess call to merge custom `env` with `os.environ` so system‑wide variables overwrite duplicates.
- Pass `no_auth=args.no_auth` to `run_task` invocation.
- Updated `romitask/src/romitask/cli/romi_run_task.py` to include ``no_auth=args.no_auth`` in the `run_task` invocation.
- Extend the `env` dict in `romitask/src/romitask/cli/romi_run_task.py` with `"MPLBACKEND": "Agg"` to enforce a non‑interactive matplotlib backend during task execution.
@jlegrand62 jlegrand62 requested a review from ArthurLuciani2 May 7, 2026 07:55
@jlegrand62 jlegrand62 self-assigned this May 7, 2026
@jlegrand62 jlegrand62 added the enhancement New feature or request label May 7, 2026
jlegrand62 added 7 commits May 7, 2026 10:41
- Replaced "associated to" with "associated with" across multiple files for consistent phrasing.
- Read `ROMI_DB_NOAUTH` from the environment and pass it as `no_auth` to `FSDB` constructor in `romitask/src/romitask/task.py`
- Perform `db.login` only when `no_auth` is false, using `ROMI_DB_USER` and `ROMI_DB_PASSWORD` environment variables
- Preserve existing behavior by defaulting `no_auth` to `False` when the variable is unset
- Ensure DB connection is still established with `db.connect()` before conditional login
- Import `dotenv_values` and read environment variables from `<dataset_path>/.env`.
- Introduce `--no-auth` CLI flag for testing with automatic admin login.
- Merge dotenv values into a custom `env` dict and set `LUIGI_CONFIG_PARSER`, `LUIGI_CONFIG_PATH`, and default `PYOPENCL_CTX`.
- When `--no-auth` is used, ensure `ROMI_DB_NOAUTH` is set to `"1"` unless explicitly disabled via environment or `.env`.
- Update subprocess call to merge custom `env` with `os.environ` so system‑wide variables overwrite duplicates.
- Pass `no_auth=args.no_auth` to `run_task` invocation.
- Updated `romitask/src/romitask/cli/romi_run_task.py` to include ``no_auth=args.no_auth`` in the `run_task` invocation.
- Extend the `env` dict in `romitask/src/romitask/cli/romi_run_task.py` with `"MPLBACKEND": "Agg"` to enforce a non‑interactive matplotlib backend during task execution.
@jlegrand62 jlegrand62 merged commit 60b1604 into dev May 7, 2026
1 check passed
@jlegrand62 jlegrand62 deleted the feature/plantdb_auth branch May 7, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants