Skip to content

Conversation

@faganihajizada
Copy link
Contributor

Summary

RacksDB is marked as an optional dependency in pyproject.toml under the [agent] extra, but the code has unconditional imports at the module level:

from racksdb.errors import RacksDBSchemaError, RacksDBFormatError
from racksdb.web.app import RacksDBWebBlueprint

This causes ModuleNotFoundError when running the agent without RacksDB installed.

Solution

This PR makes RacksDB imports conditional using the existing werkzeug optional import pattern found in the codebase (slurmweb/apps/agent.py):

  • Module-level try/except: Wrap RacksDB imports in try/except ModuleNotFoundError block
  • Stub exception classes: Provide stub classes to satisfy Python's exception handling requirements
  • Configuration validation: Fail early with clear error message if RacksDB is enabled but not installed
  • Graceful fallbacks: Version display shows "N/A (not installed)" when RacksDB is unavailable

Testing

  • All tests pass with RacksDB mocked as available
  • Agent starts successfully without RacksDB when racksdb.enabled=false
  • Clear error message when racksdb.enabled=true but RacksDB not installed
  • Deployed and tested

@faganihajizada faganihajizada force-pushed the feat/racksdb-optional-dependency branch 3 times, most recently from 5712689 to 199312a Compare December 10, 2025 16:01
@faganihajizada
Copy link
Contributor Author

faganihajizada commented Dec 10, 2025

@rezib this one is ready for review. thank you!

@rezib rezib self-assigned this Dec 10, 2025
Copy link
Contributor

@rezib rezib left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @faganihajizada for this PR! I have a few comments and a question: how do you manage to install Slurm-web without RacksDB in your case? You're not making RacksDB an optional dependency in pyproject.toml. RPM and deb packages have a strong dependency on RacksDB. What's your plan?

@faganihajizada
Copy link
Contributor Author

Thank you @faganihajizada for this PR! I have a few comments and a question: how do you manage to install Slurm-web without RacksDB in your case? You're not making RacksDB an optional dependency in pyproject.toml. RPM and deb packages have a strong dependency on RacksDB. What's your plan?

Thanks for review @rezib

In our case, we're building Docker containers for Kubernetes deployments. In our Dockerfile, instead of pip install .[agent] we do pip install ClusterShell prometheus-client redis requests ....

This allows us to install the agent dependencies individually while excluding RacksDB from our container images. My goal here is to keep traditional installations with pip install .[agent] continue to work exactly as before, including RPM/deb packages.

I am planning to contribute and help you with container images and helm charts for k8s deployments if you are interested.

@rezib
Copy link
Contributor

rezib commented Dec 11, 2025

In our case, we're building Docker containers for Kubernetes deployments. In our Dockerfile, instead of pip install .[agent] we do pip install ClusterShell prometheus-client redis requests ....

This allows us to install the agent dependencies individually while excluding RacksDB from our container images. My goal here is to keep traditional installations with pip install .[agent] continue to work exactly as before, including RPM/deb packages.

OK thanks for these explanations!

I am planning to contribute and help you with container images and helm charts for k8s deployments if you are interested.

Oh yes, of course!

@faganihajizada faganihajizada force-pushed the feat/racksdb-optional-dependency branch 2 times, most recently from 663224c to 1fd8e89 Compare December 15, 2025 11:06
@faganihajizada faganihajizada force-pushed the feat/racksdb-optional-dependency branch from 1fd8e89 to 81ed32f Compare December 15, 2025 12:17
@faganihajizada faganihajizada requested a review from rezib December 15, 2025 12:19
@rezib rezib force-pushed the feat/racksdb-optional-dependency branch from 81ed32f to 7f1840a Compare December 15, 2025 19:36
Move RacksDB imports inside conditional blocks using lazy loading pattern,
allowing the agent to run without RacksDB installed when racksdb.enabled
is false.

This enables minimal agent deployments where RacksDB features are not
needed, reducing container image size and dependencies.

Signed-off-by: Rémi Palancher <[email protected]>
@rezib rezib force-pushed the feat/racksdb-optional-dependency branch from 7f1840a to 7406f7f Compare December 15, 2025 19:37
@rezib rezib merged commit e54f599 into rackslab:main Dec 15, 2025
16 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Dec 15, 2025
@rezib
Copy link
Contributor

rezib commented Dec 15, 2025

Thank you @faganihajizada for this contribution!

@faganihajizada faganihajizada deleted the feat/racksdb-optional-dependency branch December 16, 2025 08:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants