-
Notifications
You must be signed in to change notification settings - Fork 7
feat: spike - mounting custom libraries #3074
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
Open
mcmcgrath13
wants to merge
6
commits into
main
Choose a base branch
from
mcm/spike-custom-py-lib
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+64
−3
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
219b036
feat: spike - mounting custom libraries
mcmcgrath13 b42624c
fix: cleanup
mcmcgrath13 a548d04
style: appease ruff
mcmcgrath13 82c507c
Merge branch 'main' of https://github.com/CDCgov/NEDSS-Modernization …
mcmcgrath13 22e0219
fix: merge cruft
mcmcgrath13 4982d11
test: update test
mcmcgrath13 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # This module contains libraries that deployments mount into this location, but will be | ||
| # empty in the base product |
17 changes: 17 additions & 0 deletions
17
apps/report-execution/tests/integration/assets/custom_library.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| from src.db_transaction import Transaction | ||
| from src.models import ReportResult, TimeRange | ||
|
|
||
|
|
||
| def execute( | ||
| trx: Transaction, | ||
| subset_query: str, | ||
| data_source_name: str, | ||
| time_range: TimeRange | None = None, | ||
| **kwargs, | ||
| ): | ||
| """This is a stub custom library just to start to get the interface hooked up.""" | ||
| content = trx.execute(subset_query) | ||
|
|
||
| return ReportResult( | ||
| content_type='table', content=content, description='Custom pass through query' | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
apps/report-execution/tests/integration/libraries/custom_library.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import http.client | ||
| import json | ||
|
|
||
| import pytest | ||
|
|
||
|
|
||
| @pytest.mark.usefixtures('setup_containers') | ||
| @pytest.mark.integration | ||
| class TestCustomLibrary: | ||
| """Integration tests for custom library execution.""" | ||
|
|
||
| def test_custom_library_runs(self): | ||
| report_spec = { | ||
| 'version': 1, | ||
| 'is_export': True, | ||
| 'is_builtin': False, | ||
| 'report_title': 'Test Report', | ||
| 'library_name': 'custom_library', | ||
| # Filter code is used here as it is a stable, small table | ||
| 'data_source_name': '[NBS_ODSE].[dbo].[Filter_code]', | ||
| 'subset_query': 'SELECT * FROM [NBS_ODSE].[dbo].[Filter_code]', | ||
| } | ||
|
|
||
| connection = http.client.HTTPConnection('localhost:8001') | ||
|
|
||
| headers = {'Content-type': 'application/json'} | ||
| body = json.dumps(report_spec) | ||
|
|
||
| connection.request('POST', '/report/execute', body, headers) | ||
|
|
||
| response = connection.getresponse() | ||
| assert response.status == 200 | ||
|
|
||
| result = json.loads(response.read()) | ||
| assert result['description'] == 'Custom pass through query' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,6 @@ def test_report_runs(self): | |
|
|
||
| result = json.loads(response.read()) | ||
| assert ( | ||
| result['description'] | ||
| result['header'] | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not specific to this changeset, but lingering bug from PR interaction effect already on main |
||
| == 'Custom Report For Table: [NBS_ODSE].[dbo].[Filter_code]' | ||
| ) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.