-
Notifications
You must be signed in to change notification settings - Fork 21
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
Unique subscriber counts #562
Conversation
flowclient/flowclient/client.py
Outdated
Example | ||
------- | ||
>>> unique_subscriber_counts( { "start_date" : "2019-03-20", "end_date" : "2019-03-31", "aggregation_unit" : "admin3" } ) | ||
[ ] # TODO - Fill this in |
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.
Accidentally forgot to delete this TODO item?
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.
I wasn't sure what goes there. Is there a systematic way to find out? I assume I can try actually running the code and extracting the relavent string from the output.
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.
Yes, you'd need to actually run it and copy & paste the output.
Note that in order to be able to successfully run it, you will need to change the dates to something between 2016-01-01
and 2016-01-07
because the data in the test database is between those dates.
The additions to the API spec (in the file I assume you edited this file manually? While this is possible, it's easier to let ApprovalTests auto-generate it for you. When you run the relevant integration test (e.g. via However, currently it is configured to use |
Codecov Report
@@ Coverage Diff @@
## master #562 +/- ##
==========================================
- Coverage 92.74% 92.74% -0.01%
==========================================
Files 115 116 +1
Lines 6038 6062 +24
Branches 672 673 +1
==========================================
+ Hits 5600 5622 +22
- Misses 312 314 +2
Partials 126 126
Continue to review full report at Codecov.
|
Re Max's flowmachine_server_tests comment, for now I have manually moved the unique_subscriber_counts entries into alphabetical order, as I have had trouble running the integration_tests: Firstly, I have established that these tests definitely won't run in Windows, with or without using the FlowKit integration test pipenv environment, because two 3rd party modules they use, "pglast" and "ujson" are Unix-only. (The only other Unix dependency I've come across in FlowKit is the use of "pwd", for dealing with the Unix password database.) I am able to run them (without missing module failures) in "Ubuntu for Windows" in their FlowKit development pipenv environment, which is good. However, this fails with hordes of errors, all I think due to the same thing: a database port not being configured, or its config not being picked up by the test scripts. Here is a sample error message:
Also, I see that after this commit one or more (?) of the automated CI tests have failed. But I can't see anything relating to Unique Subscriber Counts in the failure summary, or in any of the voluminous waffle following it! I'll copy and paste the full test output schpiel and search for any relevant failure reason(s). But at first sight it looks as if the failures may be unrelated to my changes! |
@OwlHute There's a readme file that explains how to run the integration tests, located in the integration tests folder. Note that you'll need/want to use Pipenv, because various settings are in The test that is currently failing (which I believe @maxalbert has just fixed for you), is the autogenerated api schema. Once the tests are all passing, we'll also want to look at the test coverage to assess whether you need to add some more tests to cover the new code. |
Thanks for the changes @OwlHute! The toplevel keys are now in the correct order. The nested keys were still in non-alphabetical order; for the sake of expediency I just pushed a change to fix this (you will want to run Apologies for the test run failures. This is due to #467, I'll submit a PR to fix this in a minute. In the meantime, you should be able to run the tests by setting the following environment variables explicitly in your shell (you will need to run
Are you able to run the tests with these settings? If you want to run just the API spec test (either for speed, or to avoid failures with Unix-only modules) you can do it like this (from within the integration tests pipenv environment as above):
|
@greenape Is there a need for any more test coverage or are all the changes here covered by existing tests? |
@max, many thanks for these port settings. I ran the test in the pipenv environment in Ubuntu, and the output looks a lot better, in that it is much shorter! But there are still a few errors around connections, e.g.:
E ConnectionRefusedError: [Errno 111] Connection refused
|
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.
Thanks.
Needs tests, because this drops the coverage a little too much.
Two approaches there, first is to add a tavern style test, as seen here https://github.com/Flowminder/FlowKit/tree/master/integration_tests/tests/flowapi_tests + a test for constructing the dict in the FlowClient tests, here: https://github.com/Flowminder/FlowKit/tree/master/flowclient/tests/unit
Alternative would be to add a test to the parameterised test_run_query
test here: https://github.com/Flowminder/FlowKit/blob/master/integration_tests/tests/test_queries.py which would hit both code paths.
@property | ||
def _flowmachine_query_obj(self): | ||
""" | ||
Return the underlying flowmachine daily_location object. |
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.
Return the underlying flowmachine daily_location object. | |
Return the underlying flowmachine UniqueSubscriberCounts object. |
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.
I've implemented the suggested alternative, but that _flowmachine_query_ob j() method was already present and the only change I made was to fix the object name in theader. So that won't change the test coverage. Presumably something must be added to actually call _flowmachine_query_obj() ?! (I assumed some test would run it automatically, as its name looks pretty generic.)
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.
@OwlHute This particular suggestion about changing daily_location
to UniqueSubscriberCounts
in the docstring is independent of @greenape's comment about code coverage and the need to add an additional test. (It may look related because Github displays it right underneath, but it has nothing to do with it).
flowclient/flowclient/client.py
Outdated
Example | ||
------- | ||
>>> unique_subscriber_counts( { "start_date" : "2019-03-20", "end_date" : "2019-03-31", "aggregation_unit" : "admin3" } ) | ||
[ ] # TODO - Fill this in |
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.
Example needs to be filled in as mentioned, and should actually work when run (args are wrapped in a dict here, so this would error when run?)
For reference, I'm looking at the coverage report for the added schema here: https://codecov.io/gh/Flowminder/FlowKit/src/73abcbf0213132937f6cb1d3b11640bf4e0a5b6e/flowmachine/flowmachine/core/server/query_schemas/unique_subscriber_counts.py and the client, here: https://codecov.io/gh/Flowminder/FlowKit/src/unique_subscriber_counts/flowclient/flowclient/client.py |
}, | ||
), | ||
( | ||
"unique_subscribers_count", |
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.
Why was this added twice? It seems to be an exact copy of the previous one?
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.
DOH! Looking at what I thought was one previous test case, I assumed it was the input arguments and the expected output arguments. But on closer inspection I see it is two previous test cases and only the input arguments are required. I've removed the duplicate entry now and re-committed & pushed to github
Thanks for the changes @OwlHute. This looks (almost) good, but we need a changelog entry please - see the checkbox in the PR template at the top. (Ideally we'd also want a Github issue that this PR closes, but we can add that separately.) |
I have a horrible feeling I may have morphed the name "unique_subscriber_counts" to "unique_subscribers_count" in the added test - Checking now .. |
Fixed! |
flowclient/flowclient/client.py
Outdated
|
||
|
||
def unique_subscriber_counts( | ||
start_date: str, stop_date: str, aggregation_unit: str |
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.
Sorry, I missed this earlier: this parameter should actually be named end_date
rather than stop_date
. (This was caught by the most recent integration test you added, which is why they are currently failing.)
This looks good now, as far as I can tell. Happy with the test coverage @greenape? |
Hm. Looks like needs a case added to one or both of |
@OwlHute Thanks for adding the extra test. It failed because the assert statement contained a hard-coded |
…ise the action handlers (rather than specific queries)
I'm happy to merge this now. The code coverage is still every so slightly reduced, but if I'm interpreting the codecov reports correctly then this seems to be a code path that's also not hit by other queries, so I'm happy to deal with this separately. |
FYI, I have removed the tests in |
Test coverage seems to be sufficient now, apart from a small drop that will be investigated separately
Closes #588
I have:
Description
Description of what this PR does, and what it changes.