-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from bioinformatics-ua/imp/improve_code_structure
Imp/improve code structure
- Loading branch information
Showing
31 changed files
with
517 additions
and
903 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,156 @@ | ||
bower_components/ | ||
node_modules/ | ||
|
||
# Retrieved from https://github.com/github/gitignore/blob/752b7678db497edb377fa982ded0c70035393794/Python.gitignore | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
*.pyc | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
cover/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
.pybuilder/ | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
# For a library or package, you might want to ignore these files since the code is | ||
# intended to run in multiple environments; otherwise, check them in: | ||
# .python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# poetry | ||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. | ||
# This is especially recommended for binary packages to ensure reproducibility, and is more | ||
# commonly ignored for libraries. | ||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control | ||
#poetry.lock | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# pytype static type analyzer | ||
.pytype/ | ||
|
||
# Cython debug symbols | ||
cython_debug/ | ||
|
||
# PyCharm | ||
# JetBrains specific template is maintainted in a separate JetBrains.gitignore that can | ||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore | ||
# and can be added to the global gitignore or merged into this file. For a more nuclear | ||
# option (not recommended) you can uncomment the following to ignore the entire idea folder. | ||
#.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
# GeoDropdown | ||
GeoDropdown makes use of geowebservice to create a multiple drodpdown lists system, which guarantees that users will provides well formatted locations, according to ISO-3166. | ||
|
||
Live demo: [demo.html](demo.html) | ||
|
||
# Hierarchical levels | ||
There are 7 hierarchical levels, which corresponds to 7 dropdown list: | ||
|
||
|
@@ -73,31 +71,52 @@ Portugal (wich is a country) geonameid is 2264397, so you can use the link /geod | |
[{"geonameid": 2262961, "fcode": "ADM1", "name": "Distrito de Set\u00c3\u00babal", "adm1": 19}, {"geonameid": 2263478, "fcode": "ADM1", "name": "Distrito de Santar\u00c3\u00a9m", "adm1": 18}, {"geonameid": 2264507, "fcode": "ADM1", "name": "Distrito de Portalegre", "adm1": 16}, {"geonameid": 2267056, "fcode": "ADM1", "name": "Distrito de Lisboa", "adm1": 14}, {"geonameid": 2267094, "fcode": "ADM1", "name": "Distrito de Leiria", "adm1": 13}, {"geonameid": 2268337, "fcode": "ADM1", "name": "Distrito de Faro", "adm1": 9}, {"geonameid": 2268404, "fcode": "ADM1", "name": "Distrito de \u00c3\u2030vora", "adm1": 8}, {"geonameid": 2269513, "fcode": "ADM1", "name": "Distrito de Castelo Branco", "adm1": 6}, {"geonameid": 2270984, "fcode": "ADM1", "name": "Distrito de Beja", "adm1": 3}, {"geonameid": 2593105, "fcode": "ADM1", "name": "Madeira", "adm1": 10}, {"geonameid": 2732264, "fcode": "ADM1", "name": "Distrito de Viseu", "adm1": 22}, {"geonameid": 2732437, "fcode": "ADM1", "name": "Distrito de Vila Real", "adm1": 21}, {"geonameid": 2732772, "fcode": "ADM1", "name": "Distrito de Viana do Castelo", "adm1": 20}, {"geonameid": 2735941, "fcode": "ADM1", "name": "Distrito do Porto", "adm1": 17}, {"geonameid": 2738782, "fcode": "ADM1", "name": "Distrito da Guarda", "adm1": 11}, {"geonameid": 2740636, "fcode": "ADM1", "name": "Distrito de Coimbra", "adm1": 7}, {"geonameid": 2742026, "fcode": "ADM1", "name": "Distrito de Bragan\u00c3\u00a7a", "adm1": 5}, {"geonameid": 2742031, "fcode": "ADM1", "name": "Distrito de Braga", "adm1": 4}, {"geonameid": 2742610, "fcode": "ADM1", "name": "Distrito de Aveiro", "adm1": 2}] | ||
``` | ||
|
||
# Server Side: | ||
# How to make it run | ||
There is a docker file to run this application. Therefore, if you want to run geodropdown, just go to geowebservice folder and run the following commands: | ||
# Setup demo | ||
## Front end: | ||
```sh | ||
npm install -g grunt bower serve | ||
|
||
# download external dependencies | ||
bower install | ||
|
||
# build dist files | ||
grunt | ||
|
||
# start a dev server to test demo.html | ||
serve | ||
``` | ||
|
||
## Server Side: | ||
### How to make it run | ||
There is a docker-compose file to run this application. Therefore, if you want to run geodropdown, just go to geowebservice folder and run the following commands: | ||
``` | ||
sh build.sh | ||
docker-compose up | ||
cd geowebservice | ||
docker-compose build | ||
./start.sh | ||
``` | ||
|
||
Now, you need to have data related to all locations around the world | ||
### How to load data to the Web Service databases | ||
|
||
**Note:** Data is automatically loaded with the start.sh script. You can ignore this section. | ||
|
||
# How to load data to the Web Service databases | ||
To load all the required data, you will need two files from geonames: allCountries.txt and countryInfo.txt. | ||
You can find them here: [files link](http://download.geonames.org/export/dump/) | ||
|
||
The next step is to give the location of those files to the webservice. So you need to change the paths in geowebservice/geodatabase/services.py file, lines 178 and 179. | ||
|
||
Now you are prepared to load all locations, simply execute python services.py in console. | ||
|
||
## Test it | ||
Go to [http://localhost:3000/demo](http://localhost:3000/demo) | ||
|
||
# Authors: | ||
|
||
- Leonardo Coelho - <[email protected]> | ||
|
||
# Contributors | ||
- Renato Pinho | ||
- Luis A. Bastião Silva - <[email protected]> | ||
- André Pedrosa - <[email protected]> | ||
|
||
|
||
# Mantainers | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Dockerfile | ||
docker-compose.yml | ||
venv | ||
db.sqlite3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,12 @@ | ||
FROM debian:jessie | ||
MAINTAINER Matt Bentley <[email protected]> | ||
FROM python:3.10 | ||
|
||
RUN (apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential git python python-dev python-setuptools nginx sqlite3 supervisor) | ||
RUN (easy_install pip &&\ | ||
pip install uwsgi) | ||
WORKDIR /app | ||
|
||
ADD requirements.txt /opt/django/app/requirements.txt | ||
RUN pip install -r /opt/django/app/requirements.txt | ||
ADD . /opt/django/ | ||
COPY requirements.txt . | ||
RUN pip install -r requirements.txt | ||
|
||
RUN (echo "daemon off;" >> /etc/nginx/nginx.conf &&\ | ||
rm /etc/nginx/sites-enabled/default &&\ | ||
ln -s /opt/django/django.conf /etc/nginx/sites-enabled/ &&\ | ||
ln -s /opt/django/supervisord.conf /etc/supervisor/conf.d/) | ||
COPY . . | ||
|
||
RUN chmod +x /opt/django/run.sh | ||
VOLUME ["/opt/django/app"] | ||
EXPOSE 80 | ||
CMD ["/opt/django/run.sh"] | ||
EXPOSE 8000 | ||
|
||
ENTRYPOINT ["gunicorn", "-b 0.0.0.0:8000", "geowebservice.wsgi"] |
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
solr: | ||
image: solr:5.5.3 | ||
hostname: solr | ||
ports: | ||
- "8887:8983" | ||
|
||
version: "3" | ||
|
||
services: | ||
solr: | ||
image: solr:5.5.3 | ||
volumes: | ||
- geodata:/opt/solr/server/solr | ||
|
||
geodropdownservice: | ||
image: bioinformaticsua/geodropdownservice | ||
geodropdownservice: | ||
build: | ||
context: . | ||
ports: | ||
- "8886:80" | ||
volumes: | ||
- .:/opt/django/app | ||
links: | ||
- solr:solr | ||
- "8886:8000" | ||
depends_on: | ||
- solr | ||
|
||
volumes: | ||
geodata: |
This file was deleted.
Oops, something went wrong.
30 changes: 10 additions & 20 deletions
30
geowebservice/geodatabase/management/commands/load_data.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,25 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import print_function | ||
import pysolr | ||
|
||
from django.core.management.base import BaseCommand, CommandError | ||
import logging | ||
|
||
import ast | ||
from django.conf import settings | ||
from django.core.management.base import BaseCommand | ||
|
||
from geodatabase.services import ServiceSolr | ||
|
||
import logging | ||
logger = logging.getLogger() | ||
logging.basicConfig(level=logging.DEBUG) | ||
|
||
|
||
class Command(BaseCommand): | ||
help = 'Closes the specified poll for voting' | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument('all', nargs='+', type=str) | ||
parser.add_argument('countries', nargs='+', type=str) | ||
parser.add_argument('countries', type=str) | ||
parser.add_argument('all', type=str) | ||
|
||
def handle(self, *args, **options): | ||
all_locations = '' | ||
countries_names = '' | ||
try: | ||
all_locations = options['all'][0] | ||
countries_names = options['countries'][0] | ||
except: | ||
all_locations = '/home/leonardo/Área de Trabalho/geonames_files/allCountries.txt' | ||
countries_names = '/home/leonardo/Área de Trabalho/geonames_files/country.csv' | ||
|
||
countries_names = options['countries'] | ||
all_locations = options['all'] | ||
|
||
s = ServiceSolr() | ||
s.load_contry_info(countries_names) | ||
s.load_initial_data(all_locations) | ||
s.load_country_info(countries_names) | ||
s.load_initial_data(all_locations) |
Oops, something went wrong.