Skip to content

Commit

Permalink
fixed conflict in changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
northwestwitch committed Dec 4, 2020
2 parents ae4e3ff + 686b727 commit 0c086a3
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/black.yml
Expand Up @@ -14,7 +14,7 @@ jobs:
python-version: 3.8
- name: install black
run: |
pip install black==20.8b1
pip install black==19.10b0
- name: run black
run: |
black . --check --line-length 100
8 changes: 8 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,14 @@
### Fixed
- removed unused docker folder

## [2.3.1] - 2020-12-04
### Added
### Changed
- Install requirements in setup
- Improved Dockerfile and docker-compose files
### Fixed
- Connection string to database when creating the app

## [2.3] - 2020-12-01
### Changed
- Pulling Docker images in docker-compose from clinicalgenomics Docker Hub
Expand Down
33 changes: 27 additions & 6 deletions docker-compose.yml
Expand Up @@ -10,6 +10,8 @@ services:
# when the container is first launched.
image: vepo/mongo
container_name: mongo
networks:
- pmatcher-net
environment:
- AUTH=y
- ADMIN_USER=root
Expand All @@ -23,23 +25,42 @@ services:
- '27017'

pmatcher-cli:
container_name: pmatcher-cli
build:
context: .
dockerfile: Dockerfile
image: clinicalgenomics/patientmatcher
environment:
MONGODB_HOST: mongodb
container_name: pmatcher-cli
links:
PMATCHER_CONFIG: '/home/worker/app/patientMatcher/patientMatcher/instance/config.py'
depends_on:
- mongodb
command: bash -c 'pmatcher add demodata --ensembl_genes'
networks:
- pmatcher-net
command: bash -c "pmatcher add client -id test_client -token custom_token -url custom_url && pmatcher add demodata --ensembl_genes"

pmatcher-web:
image: clinicalgenomics/patientmatcher
container_name: pmatcher-web
build:
context: .
dockerfile: Dockerfile
environment:
MONGODB_HOST: mongodb
container_name: pmatcher-web
links:
PMATCHER_CONFIG: '/home/worker/app/patientMatcher/patientMatcher/instance/config.py'
depends_on:
- mongodb
networks:
- pmatcher-net
expose:
- '5000'
ports:
- '5000:5000'
command: bash -c 'pmatcher run --host 0.0.0.0'

networks:
pmatcher-net:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.21.0.0/24
2 changes: 1 addition & 1 deletion patientMatcher/__version__.py
@@ -1 +1 @@
__version__ = "2.3"
__version__ = "2.3.1"
7 changes: 6 additions & 1 deletion patientMatcher/instance/config.py
@@ -1,3 +1,5 @@
import os

# Turns on debugging features in Flask
DEBUG = True

Expand All @@ -8,8 +10,11 @@
DB_USERNAME = "pmUser"
DB_PASSWORD = "pmPassword"
DB_NAME = "pmatcher"
DB_HOST = "127.0.0.1"
DB_HOST = (
os.getenv("MONGODB_HOST") or "127.0.0.1"
) # simply substitute with 'mongodb' if connecting to MongoDB running in a container
DB_PORT = 27017
DB_URI = "mongodb://{}:{}@{}:{}/{}".format(DB_USERNAME, DB_PASSWORD, DB_HOST, DB_PORT, DB_NAME)

# Matching Algorithms scores
# sum of MAX_GT_SCORE and MAX_PHENO_SCORE should be 1
Expand Down
10 changes: 1 addition & 9 deletions patientMatcher/server/__init__.py
Expand Up @@ -28,15 +28,7 @@ def create_app():
app = Flask(__name__, instance_path=instance_path, instance_relative_config=True)
app.config.from_pyfile("config.py")

db_username = app.config["DB_USERNAME"]
db_password = app.config["DB_PASSWORD"]
# If app is runned from inside a container, override host port
db_host = os.getenv("MONGODB_HOST") or app.config["DB_HOST"]
db_port = app.config["DB_PORT"]
db_name = app.config["DB_NAME"]
db_uri = f"mongodb://{db_username}:{db_password}@{db_host}:{db_port}/{db_name}"

client = MongoClient(db_uri)
client = MongoClient(app.config["DB_URI"])
app.client = client
app.db = client[app.config["DB_NAME"]]
LOG.info("database connection info:{}".format(app.db))
Expand Down
37 changes: 31 additions & 6 deletions setup.py
Expand Up @@ -33,6 +33,34 @@
here = os.path.abspath(os.path.dirname(__file__))


def parse_reqs(req_path="./requirements.txt"):
"""Recursively parse requirements from nested pip files."""
install_requires = []
with io.open(os.path.join(here, "requirements.txt"), encoding="utf-8") as handle:
# remove comments and empty lines
lines = (line.strip() for line in handle if line.strip() and not line.startswith("#"))

for line in lines:
# check for nested requirements files
if line.startswith("-r"):
# recursively call this function
install_requires += parse_reqs(req_path=line[3:])

else:
# add the line as a new requirement
install_requires.append(line)

return install_requires


# What packages are required for this module to be executed?
REQUIRED = parse_reqs()

# The rest you shouldn't have to touch too much :)
# ------------------------------------------------
# Except, perhaps the License and Trove Classifiers!
# If you do change the License, remember to change the Trove Classifier for that!

# Import the README and use it as the long-description.
# Note: this will only work if 'README.rst' is present in your MANIFEST.in file!
with io.open(os.path.join(here, "README.md"), encoding="utf-8") as f:
Expand Down Expand Up @@ -89,6 +117,7 @@ def run(self):
download_url="/".join([URL, "tarball", version]),
keywords=KEYWORDS,
packages=find_packages(),
install_requires=REQUIRED,
include_package_data=True,
license=LICENSE,
classifiers=[
Expand All @@ -103,11 +132,7 @@ def run(self):
"Operating System :: MacOS",
"Operating System :: Unix",
],
entry_points={
"console_scripts": ["pmatcher = patientMatcher.cli.commands:cli"],
},
entry_points={"console_scripts": ["pmatcher = patientMatcher.cli.commands:cli"],},
# $ setup.py publish support.
cmdclass={
"upload": UploadCommand,
},
cmdclass={"upload": UploadCommand,},
)
9 changes: 1 addition & 8 deletions tests/server/test_server_responses.py
Expand Up @@ -33,14 +33,7 @@ def test_match_async_request(mock_app, database, async_response_obj, json_patien
data = {
"query_id": async_response_obj["query_id"],
"source": "fakey node",
"response": {
"results": [
{
"score": {"patient": 0.8},
"patient": json_patients[1],
}
]
},
"response": {"results": [{"score": {"patient": 0.8}, "patient": json_patients[1],}]},
}

response = mock_app.test_client().post(
Expand Down

0 comments on commit 0c086a3

Please sign in to comment.