-
Notifications
You must be signed in to change notification settings - Fork 0
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
Set up project with django-plotly-dash #134
Conversation
Not sure why the tests are failing? @dalonsoa |
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.
Other than the failing tests, all looks good to me! Tested on my PC and it works as expected.
Not sure why the tests are failing either, looks like a migration issue but you haven't changed any of the models. Hopefully @dalonsoa has some insight
I can reproduce the error by simply running
|
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.
OK, the problem is that when launching the app for the first time, there's no data in the database. As the daily_validation
code is executed when the application is launched for the first time rather than when the page is loaded, there's not time to populate the db, and things crash. This is not going to be a problem in the real scenario, obviously, but it is now during development.
For you, this has worked because you already had the database populated, but in the GH Actions or in my laptop, in a totally fresh installation, it breaks.
Would my suggestion work, loading the problematic code only when the relevant view is loaded?
validated/urls.py
Outdated
@@ -15,6 +15,7 @@ | |||
from rest_framework.urlpatterns import format_suffix_patterns | |||
|
|||
from . import views | |||
from .dash_apps.finished_apps import daily_validation |
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 do you import daily_validation
here?
@@ -426,6 +427,11 @@ def post(self, request, *args, **kwargs): | |||
return render(request, "home/message.html", {"message": form}) | |||
|
|||
|
|||
class DailyValidationDev(View): | |||
def get(self, request, *args, **kwargs): | |||
return render(request, "daily_validation_dev.html") |
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.
Import the validation stuff here:
return render(request, "daily_validation_dev.html") | |
from .dash_apps.finished_apps import daily_validation | |
return render(request, "daily_validation_dev.html") |
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 worked! Thanks
This makes a few changes to the repo to get it set up with django-plotly-dash
I've created a minimal dash app accessible at http://localhost:8000/validated/daily_validation_dev/ which for now just consists of a single graph, just to see how everything is done. This will need to be added to and eventually integrated into the main page (the dev url/view should then be deleted). I am going to use this as a starting point for #121, and a similar approach could be used for #120
(I've also used github copilot to add docstrings and comments to the javascript code to make it easier for me to understand. However in the long run we are planning to get rid of this code anyway.)
Close #135