-
Notifications
You must be signed in to change notification settings - Fork 22
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
Add CLI interface #18
Comments
@dwillis, I made this ticket to have a place to track the work that Chris and I have done so far and to reference once I send a pull request. Should the output columns match, as much as possible, the ones listed in Common Fields? Or the columns listed in the data entry instructions? Another option that Chris and I discussed would to be to have the output match that from elex so users of that tool could easily pull results from Clarity into a system designed around using elex to pull in AP results. However, our thoughts at the time were that this might be a later feature to add, if someone requests it, and instead prioritize whatever's easiest for Open Elections. |
@ghing my thoughts here are that the output should probably be closer to the columns in the data entry instructions, with the caveat that if there are additional columns they should be provided as well. I like the |
Note to self: Originally @chagan and I wanted to keep this as simple as possible and envisioned having one command to rule them all that would download all results for all jurisdictions. However, this is both slow and difficult to integration test (because I'm finding only one jurisdiction has issues while the others are fine). I also wonder if grabbing anything is the most common use case. On election night, folks probably just want racewide and for people doing further analysis, running a command for each county, or scripting that separately isn't too onerous. I'm going to try making separate jurisdictions and results subcommands. Having subcommands seems worth it anyway to make things more extensible. |
Just an update on this. I wrote almost all of the code to do this at the beginning of the month, but in testing for the use case, I ran into some errors for some of the counties. I'm slammed with other projects, at least for this week, but I'm hoping to circle back around to this at the end of the month or beginning of May. |
Start adding a CLI interface to this package that will fetch a list of jurisdictions from a parent jurisdiction and download and parse results as CSV. This is a checkpoint commit so I can share the code with @chagan. It still needs a lot of work. Addresses openelections#18 openelections#18
A little background on the empty results:
produces these results:
I need to figure out why there are result objects that don't have any votes. |
I added some logging to the Here's the code that doesn't work:
I'm going to get started on reworking this. |
The data doesn't contain information about the jurisdiction for the results, that is whether the URL represents state results or county results. However, we've found that result URLs are either for a state or a county and that they have a distinct format. Based on this, we can detect level from the URL so the user doesn't have to specify it as an explicit command line argument. Add a utility function to detect jurisdiction levels from a results URL and use this function in the CLI commands. Addresses openelections#18 openelections#18
Add preliminary documentation for the CLI in the README. This is pretty sparse. It's mostly helpful for me to remember the CLI interface as I'm working on this project in spurts. Addresses openelections#18 openelections#18
The logic that prepared a `Result` object for CSV output was incorrectly setting the votes to the total votes for each cadidate instead of the votes for each candidate in each jurisdiction. Include the vote type in the CSV results. Reorder CSV columns to match examples in http://docs.openelections.net/data-entry/ Add logging in the `Parser` class and an option in the `results` command to make it easier to identify problems with parsing or application logic. Addresses openelections#18 openelections#18
While figuring out the problem I reported in this comment, I realized that there are a bunch of fields in the XML that we could surface in the CSV. Jurisdiction:
Contest:
We should figure out which of these should be included in the output CSV and how they should be presented. My intuition is that we should:
@dwillis, do you have thoughts or questions? |
Let's include everything we can.
… On Jul 2, 2017, at 12:22 PM, Geoffrey Hing ***@***.***> wrote:
While figuring out the problem I reported in this comment, I realized that there are a bunch of fields in the XML that we could surface in the CSV.
Jurisdiction:
total voters
ballots cast
voter turnout
percent reporting
precincts participating
precincts reported
precincts reporting percent
Contest:
of candidates you can vote for
is the contest a ballot question
percent reporting
precincts participating
precincts reported
of counties reporting
We should figure out which of these should be included in the output CSV and how they should be presented.
My intuition is that we should:
Include everything
Repeat values for each result that's for a given contest, jurisdiction
Leave values recorded at the county level (e.g. precincts reporting) blank for precinct results
@dwillis, do you have thoughts or questions?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@GPHemsley I am so excited to see you giving some love to this project. I have some commits tucked away from when I was working on adding a CLI to this project. I wanted to check in and see if this was something you were also poking at. I'll try to merge in your improvements and just take stock of where I was at with adding a CLI. |
Let me merge your changes into my fork and see how far I got. I'm happy to
hand this over to you, but just wanted to give you a heads up if it's a
useful starting point.
…On Thu, Sep 6, 2018, 8:49 PM Gordon P. Hemsley ***@***.***> wrote:
@ghing <https://github.com/ghing> I was working my way towards this
ticket, per @dwillis <https://github.com/dwillis>, but I don't have to if
you have a WIP.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#18 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAGvVLA_21ZkH_PEu8vP8Utra4CAQ03Lks5uYdC6gaJpZM4MUzfm>
.
|
@GPHemsley I merged master into my feature branch over at https://github.com/ghing/clarify/tree/add-cli. Feel free to use that as a starting point for further work on this feature, and let me know if you have any questions. I'm happy to pass this off to you, but didn't want you to replicate effort. |
Thanks for all your work folks. I'm wondering what the status of this CLI work is. It sounds like some things work at least? For context, years ago I did my own interface for downloading Clarity ENR and saving snapshots in a database: I just started porting it to python3 in a new branch, then decided to look at how this project was progressing. |
While the original use case didn't want to consider how to download and unpack the XML results, I think it will make it a lot easier for volunteers to deal with counties or states that use Clarity systems for their results if they could just run a command to download the results as CSV and then use simpler scripts or manually update the data to do any post-processing.
@chagan and I started working on this at the #NICAR17 hackathon.
Tasks
clarify results
(@ghing)The text was updated successfully, but these errors were encountered: