Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
wshayes committed Apr 7, 2020
2 parents c67d6d7 + 3fc3276 commit 11b94da
Show file tree
Hide file tree
Showing 92 changed files with 900 additions and 56,752 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.5.1
current_version = 0.6.0
commit = True
tag = True

Expand Down
4 changes: 2 additions & 2 deletions .readthedocs.yml
Expand Up @@ -3,11 +3,11 @@ formats:
- epub
- pdf

requirements_file: requirements-docs.txt
# requirements_file: requirements_dev.txt

build:
image: latest

python:
version: 3.6
# setup_py_install: true
# pip_install: true
1 change: 1 addition & 0 deletions .vscode/settings.json
Expand Up @@ -2,6 +2,7 @@
"peacock.color": "#eaca7f",
"workbench.colorCustomizations": {
"activityBar.background": "#f1dcab",
"activityBar.activeBackground": "#f1dcab",
"activityBar.activeBorder": "#1ba47b",
"activityBar.foreground": "#15202b",
"activityBar.inactiveForeground": "#15202b99",
Expand Down
61 changes: 61 additions & 0 deletions CHANGELOG.md
@@ -0,0 +1,61 @@
# Change Log

## [Unreleased](https://github.com/belbio/bel_api/tree/HEAD)

[Full Changelog](https://github.com/belbio/bel_api/compare/v0.2.0...HEAD)

**Closed issues:**

- Refactor term completion [\#50](https://github.com/belbio/bel_api/issues/50)
- Medline processing [\#46](https://github.com/belbio/bel_api/issues/46)

## [v0.2.0](https://github.com/belbio/bel_api/tree/v0.2.0) (2018-01-21)
[Full Changelog](https://github.com/belbio/bel_api/compare/v0.1.2...v0.2.0)

## [v0.1.2](https://github.com/belbio/bel_api/tree/v0.1.2) (2018-01-08)
[Full Changelog](https://github.com/belbio/bel_api/compare/v0.1.1...v0.1.2)

## [v0.1.1](https://github.com/belbio/bel_api/tree/v0.1.1) (2018-01-08)
**Fixed bugs:**

- nested statements [\#35](https://github.com/belbio/bel_api/issues/35)
- Ortholog bug - bad species\_id results in 500 error [\#25](https://github.com/belbio/bel_api/issues/25)

**Closed issues:**

- Allow setting custom canonical/decanonical targets [\#32](https://github.com/belbio/bel_api/issues/32)
- Evaluate 204 instead of 404 [\#29](https://github.com/belbio/bel_api/issues/29)
- Pluralize all routes [\#28](https://github.com/belbio/bel_api/issues/28)
- Re-work Config.py [\#27](https://github.com/belbio/bel_api/issues/27)
- Ortholog response [\#26](https://github.com/belbio/bel_api/issues/26)
- Evaluate adding Swagger UI to Falcon [\#24](https://github.com/belbio/bel_api/issues/24)
- Generate semantic classes using the YAML file [\#14](https://github.com/belbio/bel_api/issues/14)
- Swap name/abbrev in yaml file [\#13](https://github.com/belbio/bel_api/issues/13)
- BEL-LANG pop\(\) [\#12](https://github.com/belbio/bel_api/issues/12)
- BEL-LANG Add label to subject/object [\#11](https://github.com/belbio/bel_api/issues/11)
- BEL-LANG Add gene mod\_func [\#10](https://github.com/belbio/bel_api/issues/10)
- Create namespace/annotation terminology files [\#9](https://github.com/belbio/bel_api/issues/9)
- Create gene scaffold BEL statements [\#8](https://github.com/belbio/bel_api/issues/8)
- Create orthology BEL statements [\#7](https://github.com/belbio/bel_api/issues/7)
- Add LIC file to project root [\#5](https://github.com/belbio/bel_api/issues/5)
- Add py.test skeleton [\#4](https://github.com/belbio/bel_api/issues/4)
- Create Terminology JSON Schema [\#3](https://github.com/belbio/bel_api/issues/3)
- Create API specification [\#1](https://github.com/belbio/bel_api/issues/1)

**Merged pull requests:**

- Bump elasticsearch from 5.4.0 to 6.0.0 [\#34](https://github.com/belbio/bel_api/pull/34) ([dependabot[bot]](https://github.com/apps/dependabot))
- Bump python-arango from 3.11.0 to 3.12.1 [\#30](https://github.com/belbio/bel_api/pull/30) ([dependabot[bot]](https://github.com/apps/dependabot))
- updated schemas [\#22](https://github.com/belbio/bel_api/pull/22) ([wshayes](https://github.com/wshayes))
- Updated nanopub jsonschema [\#21](https://github.com/belbio/bel_api/pull/21) ([wshayes](https://github.com/wshayes))
- Bump PyJWT from 1.5.2 to 1.5.3 [\#20](https://github.com/belbio/bel_api/pull/20) ([dependabot[bot]](https://github.com/apps/dependabot))
- Bump falcon from 1.1.0 to 1.3.0rc2 [\#19](https://github.com/belbio/bel_api/pull/19) ([dependabot[bot]](https://github.com/apps/dependabot))
- Bump elasticsearch from 5.1.0 to 5.4.0 [\#18](https://github.com/belbio/bel_api/pull/18) ([dependabot[bot]](https://github.com/apps/dependabot))
- Bump gunicorn from 19.6.0 to 19.7.1 [\#16](https://github.com/belbio/bel_api/pull/16) ([dependabot[bot]](https://github.com/apps/dependabot))
- Bump PyJWT from 1.4.2 to 1.5.2 [\#15](https://github.com/belbio/bel_api/pull/15) ([dependabot[bot]](https://github.com/apps/dependabot))
- Added py.test skeleton/instructions [\#6](https://github.com/belbio/bel_api/pull/6) ([wshayes](https://github.com/wshayes))
- Contribution guidelines [\#2](https://github.com/belbio/bel_api/pull/2) ([wshayes](https://github.com/wshayes))



\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
28 changes: 0 additions & 28 deletions CHANGES.md

This file was deleted.

44 changes: 13 additions & 31 deletions DEVELOPMENT.md
@@ -1,43 +1,25 @@
# Development Notes

## Developing
## Run development tasks

After going through the setup. You will be able to edit the bel and belapi code and see
the changes made to the docker containers immediately. The belapi code is volume mounted
into the /app directory of the docker container. The bel code is volume mounted into the
python 3.6 package location for the install bel package.
In order to run in the appropriate development environment, you need to run
the following from the top-level directory with the docker-compose.yml file.
This bel_operations docker instance includes all of the python modules needed
for the main bel_api instance as well as additional python development modules
such as py.test

## Setup

To get started:
docker-compose run bel_operations

bash <(curl -s https://raw.githubusercontent.com/belbio/bel_api/master/bin/setup_dev.sh)
This will start a docker container with a python environment setup for testing, etc.

Review configuration in the .env file and the conf directory files
You may want to add the following to your .bash_aliases file

Run:
alias belops="docker-compose run bel_operations"

docker-compose up -d

## Docker info

# Follows logs for the belapi service
docker-compose logs -f bb_belapi

Services:
bb_belapi - provides BEL API endpoint
bb_elasticsearch - used for terminology searches/term completion
bb_arangodb - [graph] database for terms, orthologies, etc
bb_celery_worker - queue/batch processing manager
bb_flower - Web GUI for celery
bb_rabbitmq - Message broker used for queues by celery
bb_traefik - reverse proxy to provide access to the docker services

## Misc

This will start docker containers needed to run everything.

To make life easier on Macs using local DNS dev domains: https://medium.com/@williamhayes/local-dev-on-docker-fun-with-dns-85ca7d701f0a
You can now run tests inside the bel_operations instance:

./bin/runtests

The bel_operations prompt will look like `api@<container_id>:/app$`

2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
0.5.1
0.6.0
37 changes: 0 additions & 37 deletions app/Config.py

This file was deleted.

2 changes: 1 addition & 1 deletion app/__version__.py
@@ -1,2 +1,2 @@
__version__ = "0.5.1"
__version__ = "0.6.0"
__name__ = "BELBIO API"
3 changes: 0 additions & 3 deletions app/common/celery.py
Expand Up @@ -5,9 +5,6 @@

import bel.setup_logging

from structlog import get_logger
log = get_logger()

CELERY_BROKER = os.environ.get('CELERY_BROKER')
CELERY_BACKEND = os.environ.get('CELERY_BACKEND')

Expand Down
4 changes: 2 additions & 2 deletions app/common/mail.py
@@ -1,4 +1,4 @@
import requests
from bel.utils import http_client

from bel.Config import config

Expand All @@ -13,6 +13,6 @@ def send_mail(mail_to: str, subject: str, msg: str, mail_from: str = config['bel
"text": msg,
}

request = requests.post(f"{config['bel_api']['mail']['api']}/messages", auth=('api', config['secrets']['bel_api']['mail']['api_key']), data=data)
request = http_client.post(f"{config['bel_api']['mail']['api']}/messages", auth=('api', config['secrets']['bel_api']['mail']['api_key']), data=data)
return request

14 changes: 12 additions & 2 deletions app/main.py
@@ -1,16 +1,24 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

""" BEL API
isort:skip_file
"""

import os
import sys

import gevent.monkey
gevent.monkey.patch_all()

import bel.lang.bel_specification
# import logging
# import logging.config
# # from pythonjsonlogger import jsonlogger
import bel.setup_logging
import falcon
import gevent.monkey

# TODO - figure out how to run logging setup and belspec once on startup rather than
# every time a worker is initialized (moved bel.lang.bel_specification.update_specifications to bel/__init__.py)
import structlog
Expand Down Expand Up @@ -39,7 +47,9 @@
TermEquivalentsResource, TermResource,
TermsResource, TermTypesResource)

gevent.monkey.patch_all()
# import logging_tree
# from logging_tree import printout
# printout()


# Setup logging
Expand Down
51 changes: 26 additions & 25 deletions app/resources/belspec.py
Expand Up @@ -10,53 +10,53 @@

log = structlog.getLogger(__name__)

belspec_dir = config["bel"]["lang"]["specifications"]
belspec_dir = config['bel']['lang']['specifications']


class BelSpecResource(object):
def on_get(self, req, resp, version=""):

def on_get(self, req, resp, version=''):

versions = bel.lang.bel_specification.get_bel_versions()
if version:
if version not in versions:
description = f"No BEL Specification found for {version}"
resp.media = {"title": "No BEL Spec found", "message": description}
description = f'No BEL Specification found for {version}'
resp.media = {'title': 'No BEL Spec found', 'message': description}
resp.status = falcon.HTTP_404

version_underscores = version.replace(".", "_")
fn = f"{belspec_dir}/bel_v{version_underscores}.yaml"
with open(fn, "r") as f:
belspec = yaml.load(f, Loader=yaml.SafeLoader)
version_underscores = version.replace('.', '_')
fn = f'{belspec_dir}/bel_v{version_underscores}.yaml'
with open(fn, 'r') as f:
belspec = yaml.load(f)

resp.media = {"belspec": belspec, "versions": versions}
resp.media = {'belspec': belspec, 'versions': versions}
resp.status = falcon.HTTP_200
else:
resp.media = {"versions": versions}
resp.media = {'versions': versions}
resp.status = falcon.HTTP_200

def on_put(self, req, resp):
"""Save BEL Spec onto server"""

force = req.get_param("force", False)
belspec = req.media["belspec"]
fn_version = belspec["version"].replace(".", "_")
belspec = req.media['belspec']
fn_version = belspec['version'].replace('.', '_')

fn = f"{belspec_dir}/bel_v{fn_version}.yaml"
with open(fn, "w") as f:
fn = f'{belspec_dir}/bel_v{fn_version}.yaml'
with open(fn, 'w') as f:
yaml.dump(belspec, f, indent=2)

bel.lang.bel_specification.update_specifications(force=force)
bel.lang.bel_specification.update_specifications()

resp.status = falcon.HTTP_204

def on_delete(self, req, resp, version):
"""Delete version on server"""

fn_version = version.replace(".", "_")
yaml_fn = f"{belspec_dir}/bel_v{fn_version}.yaml"
json_fn = f"{belspec_dir}/bel_v{fn_version}.json"
ebnf_fn = f"{belspec_dir}/bel_v{fn_version}.ebnf"
parser_fn = f"{belspec_dir}/bel_v{fn_version}_parser.py"
fn_version = version.replace('.', '_')
yaml_fn = f'{belspec_dir}/bel_v{fn_version}.yaml'
json_fn = f'{belspec_dir}/bel_v{fn_version}.json'
ebnf_fn = f'{belspec_dir}/bel_v{fn_version}.ebnf'
parser_fn = f'{belspec_dir}/bel_v{fn_version}_parser.py'

if os.path.exists(yaml_fn):
os.remove(yaml_fn)
Expand All @@ -68,14 +68,15 @@ def on_delete(self, req, resp, version):
os.remove(parser_fn)

# Update versions file
version_fn = f"{belspec_dir}/versions.json"
with open(version_fn, "r") as f:
version_fn = f'{belspec_dir}/versions.json'
with open(version_fn, 'r') as f:
versions = json.load(f)

versions = [v for v in versions if v != version]

with open(version_fn, "w") as f:
with open(version_fn, 'w') as f:
json.dump(versions, f, indent=4)

resp.status = falcon.HTTP_200
resp.media = {"versions": versions}
resp.media = {'versions': versions}

0 comments on commit 11b94da

Please sign in to comment.