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

Application upgrade to SQLAlchemy, Pytest #346

Open
wants to merge 168 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
168 commits
Select commit Hold shift + click to select a range
e59749a
Move to application factory pattern and SQLAlchemy
benjwadams May 12, 2022
b13952b
WIP Commit
benjwadams Dec 13, 2023
7c84b15
Draft commit for moving completely to SQLAlchemy
benjwadams Apr 12, 2024
ffe1c4a
Remove MongoDB from compose file
benjwadams Apr 17, 2024
e4b541b
Add BerkeleyDB tooling to Dockerfile package installation
benjwadams Apr 17, 2024
9f78c5b
Merge branch 'main' into application_factory_fixes_rebase
benjwadams Apr 22, 2024
f7215a2
Continue moving over more changes
benjwadams Apr 22, 2024
2e4ba43
Remove BerkeleyDB
benjwadams Apr 24, 2024
3e099b7
Further BerkeleyDB removal changes
benjwadams Apr 24, 2024
742e5ef
Port over InfluxDB metrics script
benjwadams Apr 24, 2024
145cc16
Add column for passing CF Standard names
benjwadams Apr 24, 2024
739f06a
FIXUP: proper ioos_qc installation
benjwadams Apr 25, 2024
5a95a7d
Set FLASK_APP environment variable for running application factory
benjwadams Apr 25, 2024
5369e4b
Alter model definitions and fix cchecker import
benjwadams Apr 25, 2024
dc1d98e
Fix up various view calls, remove model deletion from queue jobs
benjwadams Apr 25, 2024
41950e4
Convert over to MySQL as default DB backend
benjwadams Apr 25, 2024
4fbbb1a
Remove non functioning queued removal task
benjwadams Apr 25, 2024
03a395c
Remove defunct imports
benjwadams Apr 25, 2024
adee440
FIXUP: re-add needed reverse proxy script
benjwadams Apr 26, 2024
67c3f7c
Add example deployment feature testing file
benjwadams Apr 26, 2024
670c84d
Merge remote-tracking branch 'ben/add_features_tests_draft' into appl…
benjwadams May 1, 2024
258b5d4
Set up test config, folder hierarchy
benjwadams May 3, 2024
2a3279c
Set default FLASK_APP in Dockerfile
benjwadams May 3, 2024
26073d4
Mail config for testing
benjwadams May 3, 2024
d3841f2
Fix config to TESTING if specified
benjwadams May 3, 2024
9f0c815
Fix deployment.json dump to file
benjwadams May 3, 2024
5bf484b
'Sync' deployment after creation
benjwadams May 3, 2024
97fa4e1
Update Gherkin file for deployment operations
benjwadams May 3, 2024
8506e70
Adds testing for feature step definition for deployment creation
benjwadams May 3, 2024
b0e7df0
Adds test requirements file
benjwadams May 3, 2024
b50a28c
Remove extra MySQL restart key from docker-compose.yml
benjwadams May 9, 2024
1795adb
Don't track test cache files
benjwadams May 10, 2024
342c091
Fixup and reorganize code
benjwadams May 10, 2024
31a3e8c
Add pytest-mock to test requirements file
benjwadams May 10, 2024
57da88e
Add more deployment addition scenarios
benjwadams May 10, 2024
27c7a22
Add testing requirements installation to GitHub Actions setup
benjwadams May 10, 2024
04c0d8e
Add test requirements to GHA as root
benjwadams May 10, 2024
ba0ea05
Fixup: Missing database extension
benjwadams May 10, 2024
13a6ab5
Try to fix logging
benjwadams May 10, 2024
eacca48
Fix names in build_erddap_catalog.py
benjwadams May 10, 2024
c9306ea
Add UDUNITS_XML_PATH to environment variables
benjwadams May 28, 2024
d7122fc
Re-enable CSRF token for deployment file upload
benjwadams May 28, 2024
6c80277
Use different ERDDAP Docker image
benjwadams May 28, 2024
118871b
Merge branch 'main' into application_factory_fixes_rebase
benjwadams May 28, 2024
30788b8
Add WMO ID display to glider deployment detail page
benjwadams May 29, 2024
fc37940
Merge pull request #351 from benjwadams/show_wmo_id_glider_detail
benjwadams May 29, 2024
ad18233
Remove extraneous Docker Compose elements
benjwadams May 29, 2024
3db72d4
Update config variables used in replicatePrivateErddapDeployments.py
benjwadams May 29, 2024
ce30488
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Jun 3, 2024
5d103cc
Merge pull request #352 from ioos/pre-commit-ci-update-config
ocefpaf Jun 4, 2024
31972ac
keep sync_theme alive
ocefpaf Jun 13, 2024
348bddc
Put navoceano files into proper directory based upon date of deployment
benjwadams Jul 3, 2024
36949d2
Use deployment dir split for navo directory
benjwadams Jul 4, 2024
f984297
Add another xattr check on glider_qc task before running QARTOD
benjwadams Jul 8, 2024
62d729b
Merge pull request #354 from ocefpaf/sync_theme
benjwadams Jul 11, 2024
1498114
Bump flask-cors from 3.0.9 to 4.0.1
dependabot[bot] Jul 11, 2024
938eae2
Bump gautamkrishnar/keepalive-workflow from 2.0.1 to 2.0.6
dependabot[bot] Jul 12, 2024
072ba39
Merge pull request #358 from ioos/dependabot/github_actions/gautamkri…
benjwadams Jul 22, 2024
dacf27f
Handle building catalog when file missing
benjwadams Jul 29, 2024
ad579a3
Updates mapping from NumPy dtypes to ERDDAP
benjwadams Jul 31, 2024
384aa6f
Exclude QARTOD variables not provided by user for delayed mode datase…
benjwadams Aug 1, 2024
807e1d4
Merge pull request #360 from benjwadams/qartod_erddap_datasets_delaye…
benjwadams Aug 2, 2024
fe13c23
Add functionality to quality control lat and lon glider track coordin…
leilabbb Aug 7, 2024
0311cbb
Merge branch 'main' of https://github.com/ioos/glider-dac
leilabbb Aug 7, 2024
afb644a
Bump aiohttp from 3.9.4 to 3.10.2
dependabot[bot] Aug 9, 2024
db0dbd1
Revert "Add functionality to quality control lat and lon glider track…
benjwadams Aug 13, 2024
35bc1f5
Merge pull request #362 from ioos/dependabot/pip/aiohttp-3.10.2
benjwadams Aug 13, 2024
066e526
Merge pull request #357 from ioos/dependabot/pip/flask-cors-4.0.1
benjwadams Aug 13, 2024
3c2dfd8
Update glider_qc.py with location test
leilabbb Aug 16, 2024
f1ecbfe
modified the test_units_qc
leilabbb Aug 22, 2024
fdcb703
Bump gautamkrishnar/keepalive-workflow from 2.0.6 to 2.0.7
dependabot[bot] Aug 23, 2024
eb32e87
Merge pull request #370 from ioos/dependabot/github_actions/gautamkri…
ocefpaf Aug 23, 2024
05225bb
Merge pull request #369 from leilabbb/main
benjwadams Aug 29, 2024
f01f573
Bump flask-cors from 4.0.1 to 5.0.0
dependabot[bot] Sep 3, 2024
cb9b9c5
Fix location test CF standard name
benjwadams Sep 3, 2024
b0fe319
Fix location test if already existing and properly handle scalar vari…
benjwadams Sep 11, 2024
f4cda24
Merge pull request #377 from benjwadams/fix_location_test
benjwadams Sep 24, 2024
a6c4f72
Add exception handling to QARTOD test runs
benjwadams Sep 30, 2024
3c1f252
Fix async fetch of aggregated datasets which was failing in odd ways
benjwadams Sep 30, 2024
4e0ac29
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 30, 2024
40362bc
Merge pull request #378 from benjwadams/qc_and_replicate_fixes
benjwadams Sep 30, 2024
0d60f8a
Add aiofiles to requirements.txt
benjwadams Sep 30, 2024
eb0e0da
Handle errors in location test (#379)
benjwadams Oct 2, 2024
c347c09
Handle errors in time pre-QC check
benjwadams Oct 3, 2024
72b4ad6
Remove netCDF sync from call since we have context handler
benjwadams Oct 3, 2024
6ad366c
Set error in user_qc extended attribute if QC fails
benjwadams Oct 3, 2024
9f5abcf
Merge pull request #381 from benjwadams/handle_time_check_errors
benjwadams Oct 3, 2024
b5233a2
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Oct 7, 2024
0685f72
Merge pull request #383 from ioos/pre-commit-ci-update-config
ocefpaf Oct 8, 2024
3c06245
Hard-code the QARTOD variables' standard and long names in the .xml f…
leilabbb Oct 29, 2024
ab9b729
Update build_erddap_catalog.py
leilabbb Oct 29, 2024
e1b7bb9
Update build_erddap_catalog.py
leilabbb Oct 29, 2024
65c51c6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 30, 2024
a6c1205
Merge pull request #386 from ioos/fix_erddap_catalog
benjwadams Oct 30, 2024
eef2cfb
Alter Dockerfile to remove warning conditions
benjwadams Oct 31, 2024
48b080a
Update CF Standard Name Table at build time
benjwadams Oct 31, 2024
2210168
changes made to correct the global attribute displaying discovered is…
leilabbb Oct 31, 2024
bf61c24
Revert "Update CF Standard Name Table at build time"
benjwadams Oct 31, 2024
54bef2f
Mount CF Standard Name Table as Docker volume
benjwadams Nov 1, 2024
537fe21
Remove extraneous loop code
benjwadams Nov 1, 2024
7c1e4a0
Only run Compliance Checker on completed deployment if not previously…
benjwadams Nov 1, 2024
8fb944d
Move Dockerfile volume declaration earlier in file
benjwadams Nov 1, 2024
76123ac
Add directory volume for authority tables
benjwadams Nov 1, 2024
eb2a4ab
Merge pull request #387 from benjwadams/update_dockerfile_cchecker_st…
benjwadams Nov 5, 2024
f4e0082
Fail compliance check if unable to open a file
benjwadams Nov 5, 2024
5d524b7
Change lock criteria for QC
benjwadams Nov 5, 2024
88fef46
Revert lock check for non-event listener QARTOD QC invocation
benjwadams Nov 5, 2024
0474c9d
Correct variable name from qartod_location_flag to qartod_location_te…
benjwadams Nov 6, 2024
a26de1a
Fix logger reference in email script
benjwadams Nov 7, 2024
3b8322e
Merge pull request #389 from benjwadams/qc_task_updates
benjwadams Nov 7, 2024
c17ab33
Bump aiohttp from 3.10.2 to 3.10.11
dependabot[bot] Nov 18, 2024
45dd434
Merge pull request #396 from ioos/dependabot/pip/aiohttp-3.10.11
benjwadams Nov 20, 2024
46b45e5
Create email for non-completed deployments older than two weeks
benjwadams Nov 21, 2024
60ba766
Fixup old deployment emails
benjwadams Nov 21, 2024
cd3e2f6
Fix result sort
benjwadams Nov 21, 2024
97ff47e
Remove extraneous function call and properly render HTML
benjwadams Nov 21, 2024
de76c27
Update body message for incomplete deployments
benjwadams Nov 21, 2024
5f9b4a4
Merge pull request #397 from benjwadams/old_non_complete_glider_email
benjwadams Nov 22, 2024
9fc755a
Allow replication/aggregation of delayed mode datasets
benjwadams Nov 22, 2024
6b5fc27
Merge pull request #398 from benjwadams/allow_replicate_delayed_mode
benjwadams Nov 22, 2024
a62395a
Pass compliance checking to scheduled jobs
benjwadams Nov 23, 2024
e454b45
Bump gautamkrishnar/keepalive-workflow from 2.0.7 to 2.0.8
dependabot[bot] Nov 25, 2024
60e9d7e
Merge pull request #400 from ioos/dependabot/github_actions/gautamkri…
ocefpaf Nov 26, 2024
55b56d4
Suppress error message when QC xattr not found on file
benjwadams Nov 26, 2024
9ec67c4
Merge pull request #399 from benjwadams/cchecker_deployment_scheduled…
benjwadams Nov 26, 2024
912a258
Fix CF standard name for location test
benjwadams Nov 27, 2024
0c9bdc7
Update glider_qc.py
leilabbb Nov 28, 2024
8cc6c6e
Merge branch 'main' into qc_fixes
leilabbb Nov 28, 2024
a2e7231
Update qc_config.yml
leilabbb Nov 28, 2024
4c376bd
Update glider_qc.py
leilabbb Dec 6, 2024
01cb059
Update test_glider_qc.py
leilabbb Dec 6, 2024
76253f8
Update glider_qc.py
leilabbb Dec 7, 2024
bb81a60
Update test_glider_qc.py
leilabbb Dec 7, 2024
dd0c223
Update test_glider_qc.py
leilabbb Dec 7, 2024
3ee08ac
Update test_glider_qc.py
leilabbb Dec 7, 2024
aeea41b
Merge branch 'main' into application_factory_fixes_rebase
benjwadams Dec 9, 2024
38d9757
Move email modules, fix some breakage
benjwadams Dec 17, 2024
0dc82b4
Allow standalone config
benjwadams Dec 19, 2024
6c55103
Fix tests
benjwadams Dec 23, 2024
34ba3d9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 24, 2024
7f9f71c
Merge pull request #401 from ioos/qc_fixes
benjwadams Dec 24, 2024
b641011
Fix QC typo and don't double print exception
benjwadams Dec 24, 2024
cb8b465
More test fixes, mark email failure test as skip
benjwadams Dec 24, 2024
58b6071
Merge branch 'main' into application_factory_fixes_rebase
benjwadams Dec 24, 2024
afbbf43
Update model definitions and deployment FK references to user
benjwadams Dec 31, 2024
ba657da
Spelling and trailing whitespace fixes
benjwadams Dec 31, 2024
8117af1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 31, 2024
2b17c8d
Update GitHub workflow for pytest to reflect test directory change
benjwadams Dec 31, 2024
c07b39b
Update pytest GitHub actions to include develop branch
benjwadams Jan 6, 2025
fec1f21
Fix foreign key linkage for deployment user's username
benjwadams Jan 6, 2025
cb23313
Attempt build of test requirements as non-root user
benjwadams Jan 6, 2025
d2d7019
Revert "Attempt build of test requirements as non-root user"
benjwadams Jan 6, 2025
cfa517d
Attempt explicit install of pytest-bdd in GHA pytest
benjwadams Jan 6, 2025
3ef2a38
Remove develop branch from GHA targets
benjwadams Jan 16, 2025
3cfeff3
Combine GHA test requirements installation and test run steps
benjwadams Jan 16, 2025
917d343
Merge branch 'dependabot/pip/flask-cors-5.0.0' into application_facto…
benjwadams Jan 16, 2025
6c8809a
Remove hybrid properties from deployment view to fix BDD tests
benjwadams Jan 16, 2025
e432ca7
Run pytest with GHA on all branches upon pull request
benjwadams Jan 17, 2025
769a4e4
Attempt to use YAML folded style for GHA pytest run
benjwadams Jan 18, 2025
ae3d45f
Explicitly set FLASK_ENV to TESTING for GHA pytest step
benjwadams Jan 18, 2025
40ce0c5
Fix field name in deployment view
benjwadams Jan 27, 2025
77e5e20
Add DB expressions for hybrid properties
benjwadams Jan 27, 2025
ad6c2e9
Update filesystem paths for tessting setup
benjwadams Jan 27, 2025
f5529f8
Allow loading of environment variables prefixed with REDIS into config
benjwadams Jan 28, 2025
70ef345
Attempt Redis build on GHA
benjwadams Jan 28, 2025
8b69011
Use OVERRIDE as environment variable prefix
benjwadams Jan 28, 2025
79752b0
Remove MongoDB related configuration variables
benjwadams Jan 28, 2025
8ca5970
Fix docstring for SQLAlchemy deployment model parameter
benjwadams Jan 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ on:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
Expand All @@ -16,8 +14,20 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Start Redis
uses: supercharge/redis-github-action@1.7.0
with:
redis-version: 7

- name: Build Docker image
run: docker build -t glider-dac-build .

- name: Run tests
run: docker run --rm glider-dac-build pytest /glider-dac/tests
- name: Install testing requirements and run tests
# FIXME: Why is it necessary to set FLASK_ENV to TESTING here when
# pytest runs off GHA usually set this properly?
run: >
docker run --network host -e FLASK_ENV=TESTING
-e OVERRIDE_REDIS_HOST=localhost -e OVERRIDE_REDIS_URL=redis://localhost:6379/8
--rm -u root glider-dac-build bash -c
"pip install --no-cache -r /glider-dac/test_requirements.txt &&
pytest /glider-dac/glider_dac/tests"
14 changes: 12 additions & 2 deletions .github/workflows/sync_theme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
schedule:
- cron: "00 14 * * *"

workflow_dispatch:
workflow_dispatch: null


jobs:
Expand All @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout repo
uses: actions/checkout@v4
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4
with: { ref: gh-pages }

- name: submodule checkout
Expand All @@ -39,3 +39,13 @@ jobs:
timestamp=$(date -u)
git commit -m "Update theme on: ${timestamp}" || exit 0
git push

keepalive-job:
name: Keepalive Workflow
runs-on: ubuntu-latest
if: github.event_name == 'schedule'
permissions:
actions: write
steps:
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4
- uses: gautamkrishnar/keepalive-workflow@995aec69bb3f2b45b20f4e107907992c8715086d # 2.0.8
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ config.local.yml
ftp_temp
tds_temp
tds_catalogs
data/
glider_dac/tests/data/
.pytest_cache
secrets/

# BerkeleyDB user database
users.db
.env
.venv/
activate
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files

- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
rev: v2.3.0
hooks:
- id: codespell
exclude: >
Expand Down
25 changes: 12 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
FROM python:3.8
FROM python:3.9

ARG glider_gid_uid=1000
RUN apt-get update && \
apt-get -y install cron rsync libxml2-dev libudunits2-dev \
libnetcdf-dev netcdf-bin && \
mkdir glider-dac && groupadd -g $glider_gid_uid glider && \
useradd -u $glider_gid_uid -g $glider_gid_uid glider
ENV UDUNITS2_XML_PATH=/usr/share/xml/udunits
COPY . /glider-dac
# TODO: move logs elsewhere
VOLUME /glider-dac/logs/ /data
WORKDIR glider-dac
VOLUME /glider-dac/logs/ /data /usr/local/lib/python3.8/site-packages/compliance_checker/data
WORKDIR /glider-dac
# not clear why reinstalling Mongo-related dependencies is necessary under
# Python 3, but this allows the service to run without import or runtime errors
RUN pip install -U pip && \
pip install --no-cache Cython thredds_crawler numpy==1.19.5 pytest && \
pip install --no-cache -r requirements.txt && \
pip uninstall -y mongokit && \
pip install --no-cache --force-reinstall mongokit-py3==0.9.1.1 && \
pip install -U pymongo==2.8
RUN cd /usr/local/src && pip install -U pip && \
pip install --no-cache Cython thredds_crawler numpy pytest && \
pip install --no-cache -r /glider-dac/requirements.txt

RUN mkdir -p /data/submission /data/data/priv_erddap /data/data/pub_erddap \
/erddapData/flag /erddapData/hardFlag berkeleydb \
/erddapData/flag /erddapData/hardFlag \
/data/catalog/priv_erddap && \
chown -R glider:glider /glider-dac /data && \
chown -R glider:glider /glider-dac /data /usr/local/lib/python3.9/site-packages/compliance_checker/data && \
ln -sf /glider-dac/scripts/crontab /etc/crontab
USER glider
ENV PYTHONPATH="${PYTHONPATH}:/glider-dac"
ENV PYTHONPATH="${PYTHONPATH:-}:/glider-dac"
ENV FLASK_APP=glider_dac:create_app

EXPOSE 5000
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:5000", "app:app"]
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:5000", "glider_dac:create_app()"]
81 changes: 40 additions & 41 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,50 +1,49 @@
from glider_dac import app
from glider_dac.common import log_formatter
from flask import current_app
import os

def initialize_logs(app):
'''
Initializes the Application Logger
'''
import logging
log_path = app.config.get('LOG_DIR', 'logs')
if not os.path.exists(log_path):
os.makedirs(log_path)
#def initialize_logs(app):
# '''
# Initializes the Application Logger
# '''
# import logging
# log_path = app.config.get('LOG_DIR', 'logs')
# if not os.path.exists(log_path):
# os.makedirs(log_path)
#
# file_handler = logging.FileHandler(os.path.join(log_path, 'application.log'))
# stream_handler = logging.StreamHandler()
# file_handler.setFormatter(log_formatter)
# stream_handler.setFormatter(log_formatter)
# app.logger.addHandler(file_handler)
# app.logger.addHandler(stream_handler)
# app.logger.setLevel(logging.DEBUG)
# app.logger.info('Utility Application Process Started')

file_handler = logging.FileHandler(os.path.join(log_path, 'application.log'))
stream_handler = logging.StreamHandler()
file_handler.setFormatter(log_formatter)
stream_handler.setFormatter(log_formatter)
app.logger.addHandler(file_handler)
app.logger.addHandler(stream_handler)
app.logger.setLevel(logging.DEBUG)
app.logger.info('Utility Application Process Started')
#from flask import jsonify, url_for

from flask import jsonify, url_for

def has_no_empty_params(rule):
'''
Something to do with empty params?
'''
defaults = rule.defaults if rule.defaults is not None else ()
arguments = rule.arguments if rule.arguments is not None else ()
return len(defaults) >= len(arguments)
#def has_no_empty_params(rule):
# '''
# Something to do with empty params?
# '''
# defaults = rule.defaults if rule.defaults is not None else ()
# arguments = rule.arguments if rule.arguments is not None else ()
# return len(defaults) >= len(arguments)

#@app.route('/site-map', methods=['GET'])
def site_map():
'''
Returns a json structure for the site routes and handlers
'''
links = []
for rule in app.url_map.iter_rules():
# Filter out rules we can't navigate to in a browser
# and rules that require parameters
if "GET" in rule.methods and has_no_empty_params(rule):
url = url_for(rule.endpoint)
links.append((url, rule.endpoint))
# links is now a list of url, endpoint tuples
return jsonify(rules=links)
initialize_logs(app)
#def site_map():
# '''
# Returns a json structure for the site routes and handlers
# '''
# links = []
# for rule in app.url_map.iter_rules():
# # Filter out rules we can't navigate to in a browser
# # and rules that require parameters
# if "GET" in rule.methods and has_no_empty_params(rule):
# url = url_for(rule.endpoint)
# links.append((url, rule.endpoint))
# # links is now a list of url, endpoint tuples
# return jsonify(rules=links)
#initialize_logs(app)

if __name__ == '__main__':
app.run(host=app.config['HOST'], port=app.config['PORT'], debug=app.config['DEBUG'])
42 changes: 37 additions & 5 deletions config.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
COMMON: &common
FLASK_APP: "glider_dac:create_app()"
HOST: localhost
PORT: 5000
DEBUG: False
MONGODB_HOST: mongo
MONGODB_PORT: 27017
MONGODB_DATABASE: gliderdac

APPLICATION_PREFIX: "/gliders/"
SERVER_NAME: "localhost:5000"
APPLICATION_ROOT: "/"
APPLICATION_PREFIX: "/"
SECRET_KEY: thisisakey
LOG_FILE: yes
WEB_PASSWORD: password
Expand All @@ -25,6 +25,11 @@ COMMON: &common
MAILER_DEBUG: 1
MAIL_DEFAULT_TO: receiver@domain.com
#MAIL_DEFAULT_LIST: YOUR_EMAIL
#

# IMPORTANT: Modification tracking must be set to True for certain parts of
# deployment lifecycle to work properly!
SQLALCHEMY_TRACK_MODIFICATIONS: True

# Google Analytics
GA_ENABLED: True
Expand All @@ -43,7 +48,6 @@ COMMON: &common
INFLUXDB_PORT: 8086
ADMINS:
- admin
USER_DB_FILE: berkeleydb/users.db

REDIS_HOST: redis
REDIS_PORT: 6379
Expand All @@ -69,6 +73,34 @@ COMMON: &common
PUBLIC_CATALOG: '/data/catalog/pub_erddap/datasets.xml'
PRIVATE_CATALOG: '/data/catalog/priv_erddap/datasets.xml'

SQLALCHEMY_DATABASE_URI: mysql://username:password@mysql/gliderdac

DEVELOPMENT: &development
<<: *common
DEBUG: True
PREFERRED_URL_SCHEME: http

TESTING:
<<: *common
DEBUG: True
TESTING: True
PREFERRED_URL_SCHEME: http
# enable email for mock email testing
MAIL_ENABLED: True
# only use in memory DB for testing
SQLALCHEMY_DATABASE_URI: 'sqlite:///:memory:'
WTF_CSRF_ENABLED: False
# TODO: these directories need to be made relative to project root
path2priv: 'tests/test_fs/data/priv_erddap/'
path2pub: 'tests/test_fs/data/pub_erddap/'
path2thredds: 'tests/test_fs/data/data/thredds/'
flags_private: 'tests/test_fs/scratch/tomcat-erddap-private/flag'
flags_public: 'tests/test_fs/scratch/tomcat-erddap-public/flag'
DATA_ROOT: tests/test_fs/submission
PRIV_DATA_ROOT: tests/test_fs/data/priv_erddap
PUBLIC_DATA_ROOT: tests/test_fs/data/pub_erddap
THREDDS_DATA_ROOT: tests/test_fs/data/thredds
ARCHIVE_PATH: tests/test_fs/data/archive
NCEI_DIR: tests/test_fs/data/archive
SERVER: "http://localhost:8080/erddap"
erddap_private: 'localhost:8080'
7 changes: 4 additions & 3 deletions console
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env python

from IPython import embed
from glider_dac import app, db
from bson import ObjectId
from glider_dac import db
from flask import current_app
from glider_dac.extensions import db

with app.app_context():
with current_app.app_context():
embed()
Loading