Skip to content

Commit

Permalink
Api documentation compatibility (#650)
Browse files Browse the repository at this point in the history
* t2wml.outputs

* delete defunct files. delete references to defunct caching. begin documenting causx_utils

* vxcvxc

* delete wikidata_models code

* add some documentation for endpoints, and fix typo in documentation.md

* more documentation

* more docs
  • Loading branch information
devowit authored Oct 20, 2021
1 parent 51d2127 commit b7e9917
Show file tree
Hide file tree
Showing 11 changed files with 264 additions and 315 deletions.
52 changes: 6 additions & 46 deletions backend/app_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
if BASEDIR not in sys.path:
sys.path.append(BASEDIR) # when running migrate, needed to not get import errors

CACHE_FOLDER = os.path.join(DATADIR, "cache")
Path(CACHE_FOLDER).mkdir(parents=True, exist_ok=True)

app = Flask(__name__, static_folder=None)

Expand All @@ -31,9 +29,10 @@ def default(self, o):
app.json_encoder=NumpyEncoder
CORS(app, supports_credentials=True)


projects_dir= "/proj"
if os.name == 'nt':
projects_dir=os.path.join(BASEDIR, "media")
if os.name == 'nt': #used for debugging purposes
projects_dir=os.path.join(os.path.abspath(os.path.dirname(__file__)), "media")



Expand All @@ -43,17 +42,17 @@ class AppConfig:
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or \
'sqlite:///' + os.path.join(DATADIR, 'entitiesWithID.db')
SQLALCHEMY_TRACK_MODIFICATIONS = False
STATIC_FOLDER = os.path.join(BASEDIR, 'static')
STATIC_FOLDER = os.path.join(BASEDIR, 'static') #This is used only in commented out code for serving static files
PROJECTS_DIR=projects_dir
SECRET_KEY = os.getenv('SECRET_KEY', 'my_precious')
SECRET_KEY = os.getenv('SECRET_KEY', 'my_precious') #Obviously this needs to be overwritten in production versions


app.config.from_object(AppConfig)

DEFAULT_SPARQL_ENDPOINT = 'https://query.wikidata.org/bigdata/namespace/wdq/sparql'


## LOG STUFF
## LOG STUFF - can uncomment if you want to do logging

'''
import logging
Expand All @@ -69,42 +68,3 @@ class AppConfig:
web_logger=logging.getLogger('web-t2wml')
'''





#############SQL STUFF
"""
AUTO_MIGRATE = "sqlite" in AppConfig.SQLALCHEMY_DATABASE_URI # only set to true if database is sqlite
# MIGRATE_DIR=os.path.join(BASEDIR, "migrations")
def auto_constraint_name(constraint, table):
if constraint.name is None or constraint.name == "_unnamed_":
return "sa_autoname_%s" % str(uuid.uuid4())[0:5]
else:
return constraint.name
convention = {
"auto_constraint_name": auto_constraint_name,
"ix": 'ix_%(column_0_label)s',
"uq": "uq_%(table_name)s_%(column_0_name)s",
"ck": "ck_%(table_name)s_%(auto_constraint_name)s",
"fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
"pk": "pk_%(table_name)s"
}
metadata = MetaData(naming_convention=convention)
db = SQLAlchemy(app, metadata=metadata)
from wikidata_models import *
migrate = Migrate(app, db, render_as_batch=True) # , directory=MIGRATE_DIR
if AUTO_MIGRATE:
with app.app_context():
upgrade(directory=os.path.join(BASEDIR, 'migrations')) """
Loading

0 comments on commit b7e9917

Please sign in to comment.