-
Notifications
You must be signed in to change notification settings - Fork 2
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
New project initialization #1
Conversation
@mhuyck: By the way, I copied |
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 have lots to say here. You can maybe see the evolution of my thinking as I gradually remember what all of these parts are.
I think the majority of my notes are questions to help make sure I'm on the same page about where we are headed and how we plan to do deployment in this version. I think there are a relatively small number of specific code changes I'm suggesting and only one or two outright errors that I caught.
This is great work. Thank you for bringing us into the Python 3 and Django 2.2 future, @dongbohu!
SECRET_KEY = config.get('secret_key', 'django_secret_key') | ||
|
||
# SECURITY WARNING: don't run with debug turned on in production! | ||
DEBUG = config.get('debug', True) |
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.
Question: instead of a stern SECURITY WARNING comment in the code that nobody but a developer will see, should we make the codebase secure by default and make DEBUG default to False? To make things a little easier for developers, we could put a comment about setting the 'debug' config parameter to True in the config_template.yml
file.
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.
By the way, I realize this is boilerplate... just wondering if and when we want to uphold certain standards of deployability.
(Also: I know we had this hard-coded to True
in adage-server
. I'm trying to think through the steps toward our end goal explicitly and make sure we improve our final product this time based upon what we learned with our first effort.)
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.
Good point. In the default settings.py
(generated by django-admin startproject
command), this section was:
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
which is probably where the lines in adage
came from. I found it a little annoying when deploying the production server, because I had to modify settings.py
directly. That is why I put this option in config.yml
now.
This is also the reason why the default is True
here, because I try to keep it consistent with the original setting.
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'm totally fine with defaulting it to True
for now. It will be a while before we come to the point of deploying this in production. At the same time, that time delay is why I was thinking it might be good to change the default now so we don't forget. After the code review is done we tend to not revisit questions like this.
Is there a place for us to keep notes about things we want to remember to do before production deployment? If you prefer to leave the development default for now then maybe we should have a list of reminders about this and other things we know we need to come back to.
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.
'corsheaders', | ||
'organisms', | ||
'genes', | ||
'analyze', |
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 think we should rename this unless you foresee any major trouble arising from that. What I didn't understand when building models initially is that these things are all objects, so the names should all be nouns. Also, analyze
or its noun form analysis
isn't necessarily the most useful name. I'm going to look through how this is used and see if I can think of something better.
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.
Agree. I simply copied this line from original Adage settings. analysis
is one option, but it seems a little too generic. @cgreene, do you have any preference on the name of this Django app?
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.
Is this app essentially the place where most of the endpoints live? It's too generic for me to remember what goes in it now. 😭
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.
@cgreene: Yes, you are right.
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.
In a new django project, would this just be called adage
? I think the django devs might have changed how apps were named by default a bit after this project was created.
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.
In Django's jargon, adage
is the project's name, analyze
, genes
, organisms
are App's name. The app's name doesn't really matter to the frontend. It only matters to backend development. So we can name it anything, but still we want it to be a reasonable 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.
I'm really glad we're doing this review. This is the first time for this particular naming decision because the first time around actually predates the GreeneLab code review policy!
I jabbed the original developer in the ribs and asked "what were you thinking?" (We go way back.) He mumbled something about it seeming good at the time because we didn't really know what the data models were going to look like.
The naming is indeed generic because it encompasses everything. I wonder if it makes sense to split the backend into two Django "apps" because there is something of a logical split between the annotated "source data" (Samples
, essentially, which we pulled from ArrayExpress queries, along with Experiment
, and all of the SampleAnnotation
models) and "ADAGE model data" (MLModel
, Signature
, Activity
, and the rest). That separation of concerns would help our system design by giving a stronger core purpose to the two parts of the backend.
We should also keep in mind that the Django framework was not originally written for single page apps. Our goal here should be to make the best use of the capabilities it provides without getting too hung up on parts that are not relevant to us as we aim to build a solid REST API.
Maybe we are wandering outside the scope of this pull request. Does it make sense to resolve this question via an issue?
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.
Update: I suggest we follow the default Django 2.2 project layout @cgreene points out and dispense with the idea of a separate "app" (currently named analyze
). The possibility of separate app modules that Django offers are very useful as reusable modules and they make sense for something portable like genes
and organisms
, but the bulk of the Adage API is probably inseparable from the rest of the back end code.
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.
@mhuyck: I think I've addressed most of your comments. To keep this PR from growing too big, I will add new issues to keep track of some questions that you raised. Please let me know if you have any other comments. Thanks.
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 think we still need to decide how we're going to proceed with the analyze
"app". We should either fold that code into the adage
project now or document it as an issue to be fixed in an upcoming PR.
I'm also not clear on the resolution for where to put those regex lines I noted in adage/genes/models.py
.
Everything else seems to be addressed.
@mhuyck: I have created a few new issues to keep track of the two questions that I haven't addressed: |
I also added a new line in |
Looks good. Thanks @dongbohu! |
This PR includes the initialization files for adage backend in Python 3. Most of the files involved are boilerplate code. The files that should be reviewed include:
Here is a demo site that I built on AWS based on this PR:
https://py3-adage.greenelab.com/api/v1/
Right now it only supports machine learning model API (enabled by Django REST framework):
https://py3-adage.greenelab.com/api/v1/mlmodels/