Skip to content

Commit

Permalink
Merge pull request #117 from superphy/develop
Browse files Browse the repository at this point in the history
PyPy3.6 Support
  • Loading branch information
kevinkle authored Jul 18, 2019
2 parents 2e20d40 + 52ff76a commit 4f8174e
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 114 deletions.
37 changes: 10 additions & 27 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,7 @@ version: 2
jobs:
build:
docker:
# specify the version you desire here
# use `-browsers` prefix for selenium tests, e.g. `3.6.1-browsers`
- image: superphy/tox-base:latest

# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/postgres:9.4
- image: superphy/tox-base:d698931a52ddeef64dcf5918b32790bcef75af61

working_directory: ~/repo

Expand All @@ -26,13 +19,6 @@ jobs:
git submodule init
git submodule update --remote
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "requirements.txt" }}-{{ checksum "requirements_dev.txt" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run:
name: install dependencies
command: |
Expand All @@ -45,26 +31,23 @@ jobs:
name: install lemongraph
command: |
. venv/bin/activate
apt-get update -y && apt-get install -y libffi-dev zlib1g-dev python-dev python-cffi
apt-get update -y && apt-get install -y libffi-dev zlib1g-dev python-dev python-cffi libatlas-base-dev
pip install --upgrade cffi
cd lemongraph && python setup.py install
- save_cache:
paths:
- ./venv
key: v1-dependencies-{{ checksum "requirements.txt" }}-{{ checksum "requirements_dev.txt" }}
- run:
name: update pip
command: |
pip install --upgrade pip
pypy3 -m ensurepip
pypy3 -m pip install --upgrade pip
# run tests!
# this example uses Django's built-in test-runner
# other common Python testing frameworks include pytest and nose
# https://pytest.org
# https://nose.readthedocs.io
- run:
name: run tests
command: |
. venv/bin/activate
pip install tox
tox -v
- run:
name: codecov
command: |
Expand Down
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
url = https://github.com/superphy/diffpool.git
[submodule "lemongraph"]
path = lemongraph
url = https://github.com/NationalSecurityAgency/lemongraph.git
ignore = dirty
url = https://github.com/superphy/lemongraph.git
ignore = dirty
9 changes: 2 additions & 7 deletions Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ import dill
import pandas as pd
import numpy as np
from contextlib import contextmanager
from pyinstrument import Profiler

from prairiedog.profiler import Profiler
from prairiedog.kmers import Kmers
from prairiedog.networkx_graph import NetworkXGraph
from prairiedog.graph_ref import GraphRef
from prairiedog.subgraph_ref import SubgraphRef
from prairiedog.dgl_graph import DGLGraph
from prairiedog.lemon_graph import LGGraph, DB_PATH

configfile: "config.yaml"
Expand Down Expand Up @@ -68,11 +67,7 @@ rule pangenome:
print("Using LemonGraph as graph backend")
sg = SubgraphRef(LGGraph())
else:
print("Using DGL as graph backend")
sg = SubgraphRef(DGLGraph(
n_labels=len(input),
n_nodes=4**K + 20 # We have some odd contigs that use N
))
raise Exception("No graph backend found")

# Setup pyinstrument profiler
if config['pyinstrument'] is True:
Expand Down
2 changes: 1 addition & 1 deletion lemongraph
Submodule lemongraph updated 2 files
+2 −2 requirements.txt
+3 −8 setup.py
67 changes: 0 additions & 67 deletions prairiedog/dgl_graph.py

This file was deleted.

2 changes: 1 addition & 1 deletion prairiedog/lemon_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self, db_path: str = None, delete_on_exit=False, nosync=True,
else:
os.makedirs(prairiedog.config.OUTPUT_DIRECTORY, exist_ok=True)
self.db_path = DB_PATH
log.debug("Creating LemonGraph with backing file {}".format(
log.info("Initializing LemonGraph object with backing file {}".format(
self.db_path))
self.g = LemonGraph.Graph(path=self.db_path, nosync=nosync,
noreadahead=noreadahead, readonly=readonly)
Expand Down
26 changes: 26 additions & 0 deletions prairiedog/profiler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import platform
import logging

log = logging.getLogger("prairiedog")


if platform.python_implementation() == 'PyPy':
class Profiler:
"""
PyPy is missing some functions required for pyinstrument
"""
def __init__(self):
log.warning("Initialized empty Profiler since platform is"
" {}".format(platform.python_implementation()))

def start(self):
pass

def stop(self):
pass

def output_text(self, unicode, color):
return ""
else:
import pyinstrument
Profiler = pyinstrument.Profiler
9 changes: 9 additions & 0 deletions prairiedog/test_profiler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from prairiedog.profiler import Profiler


def test_profiler():
profiler = Profiler()
profiler.start()
profiler.stop()
print(profiler.output_text(unicode=True, color=True))
assert True
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ coloredlogs==10.0
decorator==4.4.0
humanfriendly==4.18
networkx==2.3
cython
dateutils
numpy
pandas
click>=6.0
dill
dgl
torch
psutil
pyinstrument
6 changes: 3 additions & 3 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pip==18.1
pip==19.1.1
bumpversion==0.5.3
wheel==0.32.1
watchdog==0.9.0
Expand All @@ -8,8 +8,8 @@ coverage==4.5.1
Sphinx==1.8.1
twine==1.12.1

pytest==3.8.2
pytest-runner==4.2
pytest==4.6.3
pytest-runner==5.1

pytest-cov
codecov
9 changes: 7 additions & 2 deletions tests/test_subgraph_ref.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import pytest
import logging

from pyinstrument import Profiler

from prairiedog.profiler import Profiler
from prairiedog.subgraph_ref import SubgraphRef
from prairiedog.graph_ref import GraphRef

log = logging.getLogger("prairiedog")


def _do_subgraph(g, km):
log.info("Setting up SubgraphRef...")
sgr = SubgraphRef(g)
log.info("Setting up GraphRef....")
gr = GraphRef()

log.info("Updating graph...")
sgr.update_graph(km, gr)

assert True
Expand All @@ -23,11 +25,14 @@ def test_subgraph_creation(g, km_short):


def test_subgraph_creation_profile(g, km_short):
log.info("Initializing and starting profiler...")
profiler = Profiler()
profiler.start()

_do_subgraph(g, km_short)

log.info("Stopping profiler...")
profiler.stop()

log.info("Trying to print profiler test...")
print(profiler.output_text(unicode=True, color=True))
5 changes: 3 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py35, py36, py37, flake8,
envlist = py35, py36, py37, pypy36, flake8,

[flake8]
exclude = tests/*
Expand All @@ -22,12 +22,13 @@ deps =
; requirements.txt with the pinned versions and uncomment the following line:
-r{toxinidir}/requirements.txt
commands =
pip -V
pip install -U pip
pip install git+https://github.com/pytries/datrie.git
pip install snakemake
bash -ec '[ "$CI" = true ] && \
echo "In CI, will not install profiler for benchmarks" || \
pip install memory_profiler'
bash -ec 'cd lemongraph && python setup.py install'
py.test -v -s --basetemp={envtmpdir} \
pytest -v -s --basetemp={envtmpdir} \
--cov=prairiedog --cov-report=xml --cov-report=html

0 comments on commit 4f8174e

Please sign in to comment.