[MNT] Change default value of NB_ENABLE_AUTH to False #530#533
[MNT] Change default value of NB_ENABLE_AUTH to False #530#533alyssadai merged 1 commit intoneurobagel:mainfrom
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideChanges the default for the NB_ENABLE_AUTH environment setting so that authentication is disabled by default unless explicitly enabled via configuration. Class diagram for updated Settings auth configurationclassDiagram
class Settings {
bool return_agg (NB_RETURN_AGG, default True)
int min_cell_size (NB_MIN_CELL_SIZE, default 0)
bool auth_enabled (NB_ENABLE_AUTH, default False)
str client_id (NB_QUERY_CLIENT_ID, default None)
str config (NB_CONFIG)
}
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Ready for review, @alyssadai ! As mentioned in the description, I verified this manually because of local environment issues with legacy pandas versions on Python 3.12. Please let me know if there's anything else needed! |
alyssadai
left a comment
There was a problem hiding this comment.
Hi @sejalpunwatkar, thanks for the PR! To verify the new default value of NB_ENABLE_AUTH/auth_enabled, could you please review the existing tests in the repo and update any relevant ones as necessary?
Also:
I verified this manually because of local environment issues with legacy pandas versions on Python 3.12.
Can you elaborate on the specific error or issue you're having when setting up a development environment (e.g., with pip install -r requirements.txt)? Or even better, open a bug report so that we can reproduce your issue!
|
Hi @alyssadai ! |
|
Hi @sejalpunwatkar, as shown by the failing check, not all our tests are not all passing in CI - you can see the currently failing tests here: https://github.com/neurobagel/api/actions/runs/22391907731/job/65038713812?pr=533 As noted in the README, to run the full test suite for the repo locally (which is recommended for any local changes), you should run: or simply Could you please review the failing test and update the PR accordingly? Let me know if anything is unclear. Re: the Python 3.12 |
|
Hi @alyssadai , I’ve pushed the changes for #530 to change NB_ENABLE_AUTH to False by default. |
3ed331b to
2516d3c
Compare
There was a problem hiding this comment.
Hi @sejalpunwatkar, your latest commits introduce some changes that are unrelated to the original issue concerning the NB_ENABLE_AUTH variable. Unfortunately, they also introduce incorrect logic in certain places, which I believe is why we're seeing more CI failures now than for your last set of commits. In general, please keep changes scoped to the issue at hand and avoid mixing dependency changes with functional changes (e.g., our current CI workflow only tests against Python 3.10, so any changes related to supporting newer Python versions also require corresponding CI workflow updates so we can keep the environment reproducible).
If the internal structure of the app or the environment variable handling is unclear, please feel free to ask for clarification before modifying core logic.
Based on the CI workflow run at the time of my last review, the only test that was failing and needed to be updated in this PR was test_settings_read_correctly.
Please revert the other changes as detailed below and re-request a review. Thank you!
| # which can happen if the original dataframe being operated on is empty. | ||
| # For example, see https://github.com/neurobagel/api/issues/367. | ||
| # (Related: https://github.com/pandas-dev/pandas/issues/55225) | ||
| .reset_index(name="completed_pipelines") |
There was a problem hiding this comment.
Why were these lines deleted? These changes should not be necessary to address the original issue, and actually break the output of this function (since there is no longer any return statement), in turn breaking the logic of invoking functions.
This erroneous change may be the reason why you are unexpectedly getting None for subject_data locally.
Please revert the deletions in this file since they are irrelevant to the original issue.
tests/conftest.py
Outdated
| "dataset_portal_uri": "https://rpq-qpn.ca/en/researchers-section/databases/", | ||
| "sub_id": "sub-ON95534", | ||
| "dataset_name": "QPN", | ||
| "dataset_portal_uri": "https://example.org", |
There was a problem hiding this comment.
The changes to the mocked responses in this file are incorrect. For example, this fixture is meant to mock the response from a single SPARQL query to the graph store, whereas you have added properties that are in fact returned via separate graph queries. In this specific case, you have also duplicated dataset_portal_uri.
I think there may be some confusion about the schema of the responses from the Neurobagel API itself, vs the shape of the response from the graph store that an API instance talks to.
Please revert all the changes you've made to the test fixtures in this file. To my knowledge, you shouldn't need to update any existing test fixtures in order to address/test the original issue.
tests/test_query.py
Outdated
| assert response.status_code == 200 | ||
| assert all( | ||
| dataset["subject_data"] == "protected" for dataset in response.json() | ||
| dataset["subject_data"] != "protected" for dataset in response.json() |
There was a problem hiding this comment.
The change to this assertion is incorrect. This test asserts over the response for an aggregate query result, and as detailed in the docs, subject-level data should always be protected in aggregate query results.
There was a problem hiding this comment.
The changes you've made to this test module do not appear relevant for testing the original issue (the new default value of NB_ENABLE_AUTH) and introduce some invalid logic. Please revert the changes to this file.
tests/test_settings.py
Outdated
| assert settings.root_path == "" | ||
| assert settings.graph_address == "127.0.0.1" | ||
| assert settings.auth_enabled is True | ||
| assert settings.auth_enabled is False |
There was a problem hiding this comment.
👍 As far as I can tell, this is the only test that needed to be changed in this PR, since it tests the behavior referenced in the issue. In the CI tworkflow run linked in my previous review comment, this was the only failing test at the time (and thus the only test that needed updating): https://github.com/neurobagel/api/actions/runs/22391907731/job/65038713812?pr=533
There was a problem hiding this comment.
As mentioned in my last review comment, dependency-related changes should be handled in #536 and should not be part of this PR, to avoid mixing dependency updates with functional changes.
We will also soon be introducing a new dependency management system using uv (#529), so pinned dependency updates should wait until that issue has been addressed.
2516d3c to
81321cc
Compare
|
Hi @alyssadai , thank you for the guidance! I've performed a hard reset to main to remove all unrelated dependency and logic changes. I have now applied only the 2 line fix: updating the NB_ENABLE_AUTH default and the corresponding test in test_settings.py. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #533 +/- ##
==========================================
- Coverage 97.31% 97.16% -0.16%
==========================================
Files 34 34
Lines 1304 1304
==========================================
- Hits 1269 1267 -2
- Misses 35 37 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Hi @sejalpunwatkar, thanks for the updates. Before I approve this, could you please update the PR description to follow the Neurobagel PR template? It should have been automatically included when the PR was opened: https://github.com/neurobagel/api/blob/main/.github/pull_request_template.md Please leave the checklist items in the template unchecked so I can review and check them off as a final sanity check. Thank you! |
|
Hi @alyssadai, I've updated the PR description to follow the template as requested! I kept the checklist items unchecked for your review. Thank You! |
alyssadai
left a comment
There was a problem hiding this comment.
Thanks @sejalpunwatkar for the revisions! I think this PR looks good to go🧑🍳
|
🚀 PR was released in |
|
Thanks for the merge, @alyssadai ! Happy to help. Are there any other high-priority issues; specifically regarding metadata parsing or API structure, that I could look into next? |
Closes #530
Changes proposed in this pull request:
Updated the NB_ENABLE_AUTH environment-backed setting to default to False (previously True).
This ensures that authentication is not required by default, aligning with the requirements in issue #530.
Verified the change manually via a Python script.
Checklist:
For new features:
For bug fixes: