Skip to content

Commit

Permalink
πŸ›fix pypi deployment (#16)
Browse files Browse the repository at this point in the history
* πŸ› fix pypi deployment
* 🎨 minor style change
* βœ… update toil_container version
  • Loading branch information
jsmedmar committed May 12, 2018
1 parent 4d1a5c9 commit c031451
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ install:
matrix:
include:
- python: 2.7
env: DEPLOY_TOIL_EXAMPLE=true DEPLOY_PYPI=true
env: DEPLOY_TOIL_EXAMPLE=true
- python: 3.6
env: SKIP_TOIL_TEST=true

Expand All @@ -30,7 +30,7 @@ deploy:
tags: true
repo: leukgen/cookiecutter-toil
branch: master
condition: $DEPLOY_PYPI = true
python: 2.7

env:
global:
Expand Down
1 change: 1 addition & 0 deletions setup.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
],
"license": "BSD",
"name": "cookiecutter-toil",
"description": "πŸͺ A cookiecutter for the creation of toil pipelines.",
"long_description": "πŸ“˜ learn more on `GitHub <https://github.com/leukgen/cookiecutter-toil>`_!",
"url": "https://github.com/leukgen/cookiecutter-toil"
}
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/.coveragerc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[paths]
source =
{{cookiecutter.project_slug}}
/test/{{cookiecutter.project_slug}}
*/{{cookiecutter.project_slug}}

[run]
source =
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/.isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ force_single_line=true
from_first=true
known_future_library=future,pies
known_standard_library=std,std2
known_third_party=click,pandas,numpy,toil
known_third_party=click,pandas,numpy,toil,toil_container
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/.travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: python

python:
- 3.6
- {% if cookiecutter.cli_type == 'toil' %}2.7{% else %}3.6{% endif %}

services:
- docker
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM {% if cookiecutter.cli_type == "toil" %} python:2.7-jessie {% elif cookiecutter.cli_type == "click" %} python:3.6-jessie {% endif %}
FROM {% if cookiecutter.cli_type == "toil" %}python:2.7-jessie{% elif cookiecutter.cli_type == "click" %}python:3.6-jessie{% endif %}

RUN \
# install packages dependencies
Expand Down
3 changes: 2 additions & 1 deletion {{cookiecutter.project_slug}}/setup.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@
"install_requires": [
"Click>=6.7",
"docker==2.5.1"{% if cookiecutter.cli_type == 'toil' %},
"toil_container>=0.2.3"{% endif %}
"toil_container>=0.2.4"{% endif %}
],
"extras_require": {
"test": [
"coverage>=4.4.2",
"pydocstyle>=2.1.1",
"pytest-cov>=2.5.1",
"pytest-env==0.6.2",
"pytest-sugar>=0.9.1",
"pylint>=1.8.1",
"tox==2.9.1"
]
Expand Down
10 changes: 7 additions & 3 deletions {{cookiecutter.project_slug}}/test-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ echo "testing container..."
# make sure current dir is repo dir
cd $( dirname "${BASH_SOURCE[0]}" )

TEST_IMAGE="{{cookiecutter.project_slug}}_test_image"

if [ "$1" = "--skip-build" ]; then
echo "skipping build..."
else
echo "building image, to skip run with --skip-build..."
docker build -q -t test-image .
docker build -q -t $TEST_IMAGE .
fi

# see https://explainshell.com/explain?cmd=set+-euxo%20pipefail
Expand All @@ -20,9 +22,11 @@ set -euxo pipefail
echo "testing docker image..."
find . -name '*.pyc' -exec rm {} +
find . -name '__pycache__' -exec rm -rf {} +
docker run --rm test-image --version

# run tox inside the container
docker run --rm $TEST_IMAGE --version
docker run --rm --entrypoint "" -v `pwd`:/test -w /test \
test-image bash -c "cp -r /test /tmp && cd /tmp/test/ && pip install tox && tox && cp .coverage /test"
$TEST_IMAGE bash -c "cp -r /test /{{cookiecutter.project_slug}} && cd /{{cookiecutter.project_slug}} && pip install tox && tox && cp .coverage /test"

# move container coverage paths to local, see .coveragerc [paths] and this comment:
# https://github.com/pytest-dev/pytest-cov/issues/146#issuecomment-272971136
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,14 @@ def run(self, fileStore):
fileStore.logToMaster(output)


def run_toil(options):
"""Toil implementation for {{cookiecutter.project_slug}}."""
head = Hello(cores=1, memory="1G", options=options)
child = HelloMessage(cores=1, memory="1G", options=options)
head.addChild(child)
ContainerJob.Runner.startToil(head, options)


def get_parser():
"""Get pipeline configuration using toil's."""
parser = ContainerArgumentParser(
version=__version__,
description="{{cookiecutter.project_slug}} pipeline",
description="A hello world toil pipeline.",
)

settings = parser.add_argument_group("{{cookiecutter.project_slug}} arguments")
settings = parser.add_argument_group("pipeline arguments")

settings.add_argument(
"--message",
Expand Down Expand Up @@ -79,6 +71,14 @@ def process_parsed_options(options):
return options


def run_toil(options):
"""Run toil pipeline give an options namespace."""
head = Hello(cores=1, memory="1G", options=options)
child = HelloMessage(cores=1, memory="1G", options=options)
head.addChild(child)
ContainerJob.Runner.startToil(head, options)


def main():
"""
Parse options and run toil.
Expand Down

0 comments on commit c031451

Please sign in to comment.