Skip to content
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

🔥 🧹 Bugfix and cleanup for "Adding Surveys" #135

Merged
merged 6 commits into from
May 9, 2024

Conversation

Abby-Wheelis
Copy link
Member

When I checked staging this morning, I realized a change I made to display surveys broke non-survey deployments, fixed this in ensure survey_list is defined

Also addressing comments from review of #124, including refactor of data loading to better match the established convention

moved survey_list initialization out of the if block so it would be defined (just empty) on non survey deployments and prevent the breaking error on the regular deployments
push the data loading process into scaffolding.py (where it belongs) and update process to match convention

we load all participant trips, then filter to the trips with input, and return both filtered and unfiltered frames

filtered is used for visualization, unfiltered is required for the quality text stats
as a part of centralizing the data loading, move the formatting of data into the same cell
I had created two functions, one in the notebook, one in scaffolding, I was using the one in the notebook, but thought I was using the one in scaffolding

This created a catastrophic error when trying to fetch the colors for the charts - fixed now!
@Abby-Wheelis
Copy link
Member Author

After some chaos with prepping the dashboard for demo this afternoon, the error was the result of a mistake that I made:

There was a function to create the color mapping based on the options, but I had defined it twice - once in scaffolding and once in the notebook - when there was an error with Other missing, I fixed it in scaffolding, and, for some reason, this worked through all of my testing yesterday. However, I was using the notebook function to create the map, so the lack of Other fix was breaking 5534293 removes the function from the notebook, and uses the one in scaffolding.

I can now run both survey_responses and survey_metrics for dfc-fermata with the April 24th snapshot -- the May 6th snapshot only has 2 surveys in it :( [I believe I had both loaded on top of each other yesterday, back to just April 24th for now]

Will now test this cleanup so we can get the fix out for dfc-fermata tonight

@Abby-Wheelis
Copy link
Member Author

Testing done:

ran notebooks on the command line for dfc-fermata and washingtoncommons -- all ran as expected, no errors, charts display as expected

Screenshot 2024-05-08 at 4 01 50 PM
Screenshot 2024-05-08 at 4 01 33 PM

The metrics also work:
Screenshot 2024-05-08 at 4 04 25 PM

Additionally, on staging we see (with a failure to load charts):
Screenshot 2024-05-08 at 4 05 08 PM

That error is not present in the console (and charts show, just blank since I have not run them) when I input the study_config as stage-study on my branch

Bugs are resolved, and updates to data loading have been made

@Abby-Wheelis Abby-Wheelis marked this pull request as ready for review May 8, 2024 22:07
@shankari
Copy link
Contributor

shankari commented May 9, 2024

I fixed the data issue and pulled new data. This is now generating everything except
image

except which I think is expected since they were not even shown
image

image
image

Since the data has been fixed, I am going to also re-enable the ble_sensed_summary and merge this. There is one nit it would be good to fix in the next round of changes.

@shankari
Copy link
Contributor

shankari commented May 9, 2024

Fixed metrics to use the ble_sensed_summary instead of the summary

Most trips are still UNKNOWN since they were taken before the BLE integration was complete. I wonder if we should remove some of them to make this data more meaningful.

image
image

- Comment in the previous code for using the `ble_sensed_mode`
- Fixed color issues; we cannot use `colors_sensed` any more since the
  `ble_sensed_mode` will not be one of the 5 hardcoded values. So we find the
set of unique values using a `groupby+agg` and then create a fake dictionary of
the unique keys mapped to themselves to pass in. Note that the returned value
will be `colors_mode` while we need to use `colors_sensed` in the graphs to
handle the non-fleet case. So for the fleet case, we set `colors_sensed` to
`color_mode`

Now that I type that out, I see that the better fix would be to have a
`colors_sel` that is set appropriately for fleet/non-fleet and then pass in
`colors_sel` instead of `colors_mode`. But that would be a bigger change, so
will leave it for @Abby-Wheelis to handle in the next round of changes

Testing done:
e-mission#135 (comment)
Copy link
Contributor

@shankari shankari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to check error handling; when I ran this with an empty database (misconfigured mongodb URL), I got only one error displayed instead of multiple as before

Screenshot 2024-05-08 at 9 51 40 PM

also see cleanup in 88f9b23

Comment on lines +249 to +252
"if len(survey_trips) > 0:\n",
" df_responses = create_dataframe(survey_trips)\n",
"else:\n",
" df_responses = survey_trips.copy()"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I would suggest a more descriptive name than create_dataframe (create what kind of dataframe)
and it looks like the else is just setting up df_responses as an empty dataframe (if the length is zero, it is empty). I would use pd.DataFrame() to highlight that or even pd.DataFrame(columns=survey_trips.columns) just to make it more clear what is going on.

@shankari shankari merged commit 90869a7 into e-mission:main May 9, 2024
@shankari
Copy link
Contributor

shankari commented May 9, 2024

Another cleanup that needs to happen is to rework the legends. The limit of 15 characters may be too aggressive, particularly if there is a y label, or maybe we can put it on top where there is no label. And in this case, because there were actually ~ 10 entries, some of them got cutoff. We also needed to use nCols.

I think we will have to think through the various use cases and create the legend accordingly.

From the current staging...
image

@shankari
Copy link
Contributor

shankari commented May 9, 2024

I also think for multi-label charts, we can change the alt-html to have the tables side by side. Right now, they are one below the other which leaves a lot of empty space.
Screenshot 2024-05-09 at 7 08 56 AM

@shankari
Copy link
Contributor

shankari commented May 9, 2024

Also, we have "testers and participants" in some locations, but hardcoded "users" in others. Need to unify.

image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants