-
Notifications
You must be signed in to change notification settings - Fork 27
Allow custom CDISC Library API URL (proxy / local cache support) #1484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
gerrycampion
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
primarily feedback where we will see merge conflicts with #1506 which will allow users to retrieve latest rules with the default library api, but no api key
| # Validation: If using the default CDISC Library URL, API key is required | ||
| if api_url == "https://api.library.cdisc.org/api" and not self._api_key: | ||
| raise ValueError( | ||
| "CDISC_LIBRARY_API_KEY is required when using the default CDISC Library API URL. " | ||
| "Either provide an API key or specify a custom CDISC_LIBRARY_API_URL which does not require an API key." | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will go away with #1506 because a missing library api key will still be able to fetch the rules
| def test_library_service_requires_key_for_default_url(): | ||
| """Test that API key is required when using default CDISC Library URL.""" | ||
| with pytest.raises(ValueError, match="CDISC_LIBRARY_API_KEY is required"): | ||
| CDISCLibraryService("", "", MagicMock()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed
| logger = logging.getLogger("validator") | ||
|
|
||
| # Validation: Ensure at least one is provided when using default URL | ||
| effective_url = apiurl if apiurl else "https://library.cdisc.org/api" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this go into the click "default" value instead?
| if effective_url == "https://library.cdisc.org/api" and not apikey: | ||
| logger.error( | ||
| "CDISC_LIBRARY_API_KEY is required when using the default CDISC Library API URL.\n" | ||
| "Either provide --apikey or set CDISC_LIBRARY_API_KEY environment variable,\n" | ||
| "or specify a custom URL with --apiurl or CDISC_LIBRARY_API_URL environment variable," | ||
| "which does or does not require specific API key for proxy access" | ||
| ) | ||
| ctx.exit(2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be removed
| @@ -1,4 +1,5 @@ | |||
| CDISC_LIBRARY_API_KEY=your_api_key_here | |||
| CDISC_LIBRARY_API_URL=http://localhost:31415/api # smart proxy server will not use CDISC_LIBRARY_API_KEY, but will might need it's own key to query upstream server. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo "but will might need"
This PR adds support for configuring a custom CDISC Library API URL, enabling the use of local or private proxy/cache services (e.g. basic example https://github.com/tomhub/cdisc-proxy). This helps reduce load on the upstream CDISC Library API and limits repeated API calls in shared or CI environments.
Key changes
Why this matters
This should partially address issue #1413
NOTE: I think [tests/unit/test_cdisc_library_service.py] needs to be properly fixed.