Read configuration file correctly (and make it optional)#127
Conversation
WalkthroughThe changes remove the global and class-level constants for the configuration file path, shifting to reading the config file location directly from the environment variable at runtime. The MongoDB connection string in the config file is updated, and the server startup no longer checks for config file existence before running. Changes
Sequence Diagram(s)sequenceDiagram
participant Tester as Test Runner
participant Env as Environment
participant Settings as Settings
participant Server as NodemanServer
Tester->>Env: Set NODEMAN_CONFIG="tests/test.toml"
Tester->>Settings: Instantiate Settings()
Settings->>Env: Read NODEMAN_CONFIG (default "nodeman.toml")
Settings-->>Tester: Settings instance
Tester->>Server: Instantiate NodemanServer with Settings
Possibly related PRs
Poem
Tip ⚡️ Faster reviews with caching
Enjoy the performance boost—your workflow just got faster. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (4)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
nodeman.toml(1 hunks)nodeman/server.py(2 hunks)nodeman/settings.py(1 hunks)tests/test_api.py(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
nodeman/server.py (1)
nodeman/settings.py (3)
InternalCaSettings(69-73)Settings(150-195)StepSettings(60-66)
🔇 Additional comments (5)
nodeman/settings.py (1)
193-193: Good improvement: Making configuration more flexible by using environment variables.The switch to using an environment variable with a default fallback value is a better approach than hardcoding paths. This change makes the application more configurable in different environments.
nodeman.toml (1)
2-2: Database name updated to match application name.Changing from
mongodb://localhost/nodestomongodb://localhost/nodemanprovides better namespace alignment with the application name.tests/test_api.py (2)
3-3: Good: Added os import for environment variable configuration.The import of
osmodule is necessary for setting environment variables in the tests.
36-36: Correctly aligned test configuration with application changes.Setting the environment variable in the test instead of modifying a class attribute is a better approach that matches how the application will use it in production.
nodeman/server.py (1)
20-20: Import statement updated correctly for dependency changes.The import statement has been updated to match the changes in the codebase, removing dependencies that are no longer needed.
3275ab0 to
907f98f
Compare
Summary by CodeRabbit