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

PR for new qmpy version V1.5 - last upgrade before cloud transitioning #137

Open
wants to merge 43 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
14499c0
Introduced environmental variables in .env file for easier OQMD hosting
tachyontraveler Dec 27, 2021
3f60ac0
cleaned up the imports of a few JS files to improve page loading spee…
tachyontraveler Jan 6, 2022
e93bb1c
upgraded jsmol to 14.32.6
tachyontraveler Jan 6, 2022
3f76c39
fixed issues with analysis/symmetry/opertions page and added links to…
tachyontraveler Jan 6, 2022
95ae596
removing a few unnecessary warnings from dependent packages
tachyontraveler Jan 19, 2022
73e9c48
initiating Github Actions and pre-commit blackening. removed unnecess…
tachyontraveler Jan 19, 2022
8aa50f0
added graphviz install to Github actions
tachyontraveler Jan 19, 2022
d14b118
added graphviz-dev install to Github actions
tachyontraveler Jan 19, 2022
9b553fa
GH Actions: fixing error in django migrations
tachyontraveler Jan 19, 2022
0e7cdec
GH Actions: installing qmpy via setup.py is required to migrte db
tachyontraveler Jan 19, 2022
4ec4706
incorporating internal and production to same branch, and differentia…
tachyontraveler Jan 20, 2022
910a257
upgraded python to 3.9, fractions.gcd is explicitly defined since it …
tachyontraveler Jan 20, 2022
e589770
GH Actions: changed python 3.7 to 3.9
tachyontraveler Jan 20, 2022
91033ab
GH Actions: setup.py needed dotenv
tachyontraveler Jan 20, 2022
cdbb662
GH Actions: corrected django testing command error
tachyontraveler Jan 20, 2022
fa21808
GH Actions: directory change in steps
tachyontraveler Jan 20, 2022
432e15a
GH Actions: debugging ci workflow
tachyontraveler Jan 20, 2022
b0352c5
GH Actions: root user is needed to create new test DB
tachyontraveler Jan 20, 2022
6d9ac49
GH Actions: makemigrations required for auth, sites, etc prior to mig…
tachyontraveler Jan 20, 2022
2b06f58
Changes in REST query parser and also in corresponding Tests. These t…
tachyontraveler Jan 20, 2022
70eec94
Bubye Travis.ci. Edits on env file, settings. Initialized dockerfiles
tachyontraveler Jan 21, 2022
ebc3b3f
suppressing PuLP messages, and removed version constrains on PuLP, an…
tachyontraveler Jan 21, 2022
2e771b5
combined DB migrate and tests to the same workflow
tachyontraveler Jan 22, 2022
1c4934a
Cloud transition: Dockerfiles for debug and deploy, GH Action with op…
tachyontraveler Jan 28, 2022
35da895
fixed issues with generating docs
tachyontraveler Jan 29, 2022
789f4ae
error correction in docker build for deploy container
tachyontraveler Jan 29, 2022
4887f90
error correction in optimade validator
tachyontraveler Jan 29, 2022
65caf46
error correction in optimade validator
tachyontraveler Jan 29, 2022
dedc57e
removed optimade validator for now
tachyontraveler Jan 29, 2022
d904823
Specifying JSMOL PHP server, removed a few unused imports from views …
tachyontraveler Feb 24, 2022
cb8fd5e
Dockerfile for Gunicorn, minor fixes in html and static assets
tachyontraveler Feb 24, 2022
6ec1d73
REST API strongly favoring OPTIMADE, instead of OQMDAPI - avoiding re…
tachyontraveler Feb 28, 2022
68348eb
bokeh to latest release
tachyontraveler Mar 12, 2022
709b8b3
added robots.txt
tachyontraveler Mar 25, 2022
506340e
bokeh dependency updated in requirements
tachyontraveler Mar 25, 2022
2d2356c
fixed error with element query parsing, and some deployment-related m…
tachyontraveler Mar 28, 2022
81e114d
precommit version needs to be specified
tachyontraveler Mar 28, 2022
3000428
Redis is now supported(optionally) for custom visualization crystal d…
tachyontraveler Apr 1, 2022
70f9b62
pinned versions of dependencies from latest working installation is s…
tachyontraveler Apr 1, 2022
3d3f537
codeql action added for sematic code analysis
tachyontraveler Apr 4, 2022
17b9b3d
disallowed indexing of raw poscar files by search engines
tachyontraveler Apr 4, 2022
6a5b1d0
removed javascript from codeql analysis since those scripts are exter…
tachyontraveler Apr 4, 2022
b08f4a1
increased the max number of gclp compositions supported in re-evaluat…
tachyontraveler May 18, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
68 changes: 68 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml

# Translations
*.mo

# Mr Developer
.mr.developer.cfg
.project
.pydevproject

# Rope
.ropeproject

# Django stuff:
*.log
*.pot

# Sphinx documentation is needed
# to be included unlike in .gitignore
#
# Because, symlinks does not work
# inside docker as of Docker v20.10.12
#docs/_build/

# Linux tempfiles
*.swp

# Django migrations
*/migrations

# Implementation Secrets
.env

# Git-related
.git*
114 changes: 114 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#################################################################################
# This is an example file with all the required environment variables to
# create the ".env" file. For security reasons, ".env" is not included in
# version control (see .gitignore) and thus, not pushed to GitHub.
#
# Steps to follow:
#
# Step 1: Copy this file (".env.example") to a new file named ".env" in
# this directory.
#
# Step 2: Close this file (".env.example") and open the new file (".env")
# and proceed to the Step 3 from ".env".
#
# Step 3: Modify the environment values below to match your system and
# configuration.
#
# Step 4: Save this ".env" file.
#
################################################################################

# Database-related variables.
#
# Make sure to set them to match your MySQL DB configuration.
# See their usage in qmpy/db/settings.py file.
# In short, they are used to define Django's DATABASES dictionary
OQMD_DB_name=qmdb
OQMD_DB_user=root
OQMD_DB_pswd=secret
OQMD_DB_host=127.0.0.1
OQMD_DB_port=3306


# Web-hosting related variables
#
# The "OQMD_WEB_hosts" variable holds comma-separated hostnames that are
# to be included in Django's ALLOWED_HOSTS tag.
# See qmpy/qmpy/db/settings.py file.
#
# Set OQMD_WEB_debug=True only when the server is not in production.
# OQMD_WEB_debug=False prints too many details during error enounters -> high security risk
OQMD_WEB_hosts=0.0.0.0,example.com,localhost,127.0.0.1,www.example.com
OQMD_WEB_debug=False


# REST API-related variables
# These values are required to make queries from the /api/search page
# Regular REST API from /optimade/ and /oqmdapi/ pages would work fine even without these
# These values should match the host:port values provided in server hosting command
# Eg:
# A server hosted using "python manage.py runserver example.com:8888" should
# have OQMD_REST_baseURL='http://example.com:8888'
OQMD_REST_baseURL="http://127.0.0.1:8000"


# Static file storage-related variables
# These values are used in qmpy/db/settings.py file.
# The correct values for your implementation depends on where the static files are stored
# for your server.
#
# "OQMD_STATIC_root" and "OQMD_STATIC_url" are assigned to Django's STATIC_ROOT
# and STATIC_URL respectively.
# https://docs.djangoproject.com/en/2.2/ref/contrib/staticfiles/#settings
#
# OQMD_USE_CDN refers to whether CDN-hosted JS files are to be loaded instead of
# local static JS files
# Used in qmpy/templatetags/custom_filters.py
OQMD_STATIC_root=/static/
OQMD_STATIC_url=/static/
OQMD_USE_CDN=True

# Secret Key for signing cookies, hash generation and some authentication in Django.
#
# It's more significant in Django servers where the user authentication
# is required, unlike oqmd.org
#
# More details:
# https://docs.djangoproject.com/en/2.2/ref/settings/#secret-key
#
# You can simply generate a 50 character key anytime.
# https://github.com/django/django/blob/stable/2.2.x/django/core/management/utils.py#L76
# The key given is randomly generated, but not used in any of our servers:
OQMD_DJANGO_secretkey='48o2)h#gwow!iyg&__4d%zkv8v&h=n!sv)0rvj$*1yj8tw0riu'

# URL of the PHP server to do CORS operations for JSMOL.
# More details:
# https://wiki.jmol.org/index.php/Jmol_JavaScript_Object/Info
#
# According to the official docs, if you can't host a php server,
# it is fine to set the value as:
# https://chemapps.stolaf.edu/jmol/jsmol/php/jsmol.php

JSMOL_serverURL='/static/js/jsmol/php/jsmol.php'



# Redis cache server - optional
# _____________________________
# Currently (as of March, 2022), Redis is used in OQMD only for
# storing data to do custom structure visualization.
# Leave this section commented - just like this, if you don't
# have a redis server running.
#
# If you wanna use Redis with qmpy,
# first install and start a redis server in your machine:
# https://redis.io/docs/getting-started/
# Now install redis's python handler in qmpy's python environment:
# pip install redis

# Once the redis dependency is installed and the server is running,
# uncomment the lines below and set the correct Redis server host and port

#REDIS_SERVER_HOST=127.0.0.1
#REDIS_SERVER_PORT=6379

71 changes: 71 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# OQMD CI workflow
name: qmpy ci workflow

on:
pull_request:
branches:
- master
- develop
push:
branches:
- master

jobs:
health-check-job: # running basic health checks
runs-on: ubuntu-latest # currently testing out only in ubuntu
env:
QMPY_ENV_FILEPATH: .env.example
services:
mysql: # latest mysql image is tested
image: mysql
env:
MYSQL_ROOT_PASSWORD: secret
MYSQL_DATABASE: qmdb
MYSQL_USER: qmpy_user
MYSQL_PASSWORD: secret
ports:
- 3306:3306 # exposing the default 3306 port
# mysql healthcheck
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Cache dependency
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Graphviz
run: sudo apt-get install -y graphviz graphviz-dev
- name: Setup python environment # Need to change this section after Python version upgrades
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Check Python version
run: python --version
- name: Install qmpy
run: python setup.py install
- name: Set ENV
run: echo "QMPY_ENV_FILEPATH=${GITHUB_WORKSPACE}/.env.example" >> $GITHUB_ENV
- name: Make Migrations
run: python manage.py makemigrations auth qmpy contenttypes sites
working-directory: qmpy/db
- name: Run Migrations
run: python manage.py migrate
working-directory: qmpy/db
- name: Run Tests
run: python manage.py test qmpy
working-directory: qmpy/db

# Container-related
- name: Build dev docker image
run: docker build . --file dockerfiles/Dockerfile.debug -t qmpy_debug
- name: Build a production docker image
run: docker build . --file dockerfiles/Dockerfile.gunicorn -t qmpy_deploy
- name: Run the dev server in a container
run: docker run -dp 8000:8000 qmpy_debug

# OPTIMADE validator action may be implemented later

39 changes: 39 additions & 0 deletions .github/workflows/codeql.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# CodeQL (from LGTM) Action to perform semantic code analysis
# https://github.com/github/codeql-action

name: "CodeQL"

on:
push:
branches: [ master]
pull_request:
branches: [ master ]

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'python' ]

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
- name: Autobuild
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,7 @@ docs/_build/

# Django migrations
*/migrations

# Implementation Secrets
.env
cloudbuild.yaml
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
repos:
- repo: https://github.com/psf/black
rev: 22.1.0
hooks:
- id: black
language: python
files: \.py$
38 changes: 0 additions & 38 deletions .travis.yml

This file was deleted.

16 changes: 16 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Security Policy

## Support for Vulnerability Fixes

Due to the very limited availability of resources from our side, we're currently able to
provide only annual updates, and only on the master branch. The pip pckages are updated less
frequently.
The dependent packages are recommended to be installed from `requirements.txt` than from
`requirements-pinned.txt` whenever possible to get the latest patched versions.

## Reporting a Vulnerability

A vulnerability can be reported either via Github Discussions or as an Issue. Please make sure
to add appropriate tags, if applicable, and any suggestions on how to fix this vulenrability
would also be highly appreciated.
We would act on the problem as soon as possible, based on its severity.
Loading