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

Gitlab runner config #159

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
4386025
add deploy script
daler Mar 19, 2019
ead86b0
update docs about missing lcdblib and new deploy script
daler Mar 19, 2019
583a39d
update changelog
daler Mar 19, 2019
9c012f5
add task to print environment
daler Mar 19, 2019
0049bfe
rm lcdb channel; fix channel order
daler Mar 19, 2019
d2fb1f4
update reqs to trigger rebuild
daler Mar 19, 2019
1803388
disable circleci on this branch
daler Mar 19, 2019
92a2d64
disable intial setup as well
daler Mar 19, 2019
588745a
add test install script
daler Mar 19, 2019
e185d2c
try caching
daler Mar 19, 2019
9cf95ee
install curl
daler Mar 19, 2019
2ab5f2b
use steps
daler Mar 19, 2019
0ba5f86
s/step/stage
daler Mar 19, 2019
f31228e
no sudo
daler Mar 19, 2019
defa967
install curl
daler Mar 19, 2019
720ae83
install curl
daler Mar 19, 2019
bc5f90d
s/debian/ubuntu/
daler Mar 19, 2019
d796dd2
always install
daler Mar 19, 2019
115f3a8
simplify setup
daler Mar 19, 2019
0adbe0a
avoid using ~
daler Mar 19, 2019
0398ac3
global path
daler Mar 19, 2019
b29f5b2
show path
daler Mar 20, 2019
018be90
which conda
daler Mar 20, 2019
a202263
change cache location
daler Mar 22, 2019
9b7214c
cache key
daler Mar 22, 2019
d48a58d
fix cache
daler Mar 22, 2019
ce9c235
add trailing "/" to cache dir
daler Mar 22, 2019
dada0dd
try different cache dir
daler Apr 13, 2019
913e1b1
be clear about path
daler Apr 14, 2019
8315bb3
change cache policy
daler Apr 14, 2019
226826d
do not install if miniconda exists
daler Apr 14, 2019
f80cf9c
only do updates if not using cache
daler Apr 14, 2019
431017b
only install if not cached
daler Apr 14, 2019
f26e907
minor
daler Apr 15, 2019
80122fd
export env.yaml as artifact
daler Apr 15, 2019
1eaaa6e
export env.yaml as artifact
daler Apr 15, 2019
45dfc67
support chipseq paired end
daler Apr 20, 2019
82f84ac
export correct env
daler Apr 20, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 39 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,55 +217,88 @@ jobs:
name: Build and upload docs
command: ci/build-docs.sh

report-env:
<<: *defaults
steps:
- add_ssh_keys:
fingerprints:
- 99:b4:dd:2c:82:9a:27:07:ca:b4:eb:bf:9c:49:4a:72
- checkout
- *restore_cache
- *set-path
- run:
name: Report environment
command: conda env export -n lcdb-wf-test


workflows:
version: 2
test-suite:
jobs:
- initial-setup
- initial-setup:
filters:
branches:
ignore:
- gitlab-runner-config
- pytest:
requires:
- initial-setup
filters:
branches:
ignore:
- gitlab-runner-config
- chipseq:
requires:
- initial-setup
- pytest
filters:
branches:
ignore:
- master
- gitlab-runner-config
- rnaseq:
requires:
- initial-setup
- pytest
filters:
branches:
ignore:
- master
- gitlab-runner-config
- rnaseq-star:
requires:
- initial-setup
- pytest
filters:
branches:
ignore:
- master
- gitlab-runner-config
- references:
requires:
- initial-setup
- pytest
filters:
branches:
ignore:
- master
- gitlab-runner-config
- colocalization:
requires:
- initial-setup
- pytest
filters:
branches:
ignore:
- master
- gitlab-runner-config
- build-docs:
requires:
- initial-setup

- report-env:
requires:
- rnaseq
- rnaseq-star
- chipseq
- references
- colocalization
filters:
branches:
ignore:
- gitlab-runner-config
48 changes: 14 additions & 34 deletions .circleci/setup.sh
Original file line number Diff line number Diff line change
@@ -1,42 +1,22 @@
#!/bin/bash
set -e

WORKSPACE=`pwd`
MINICONDA_VER=4.3.21
MINICONDA_VER=latest
tag="Linux"

# Set path
echo "export PATH=$WORKSPACE/miniconda/bin:$PATH" >> $BASH_ENV
source $BASH_ENV
if ! [ -x "$(command -v conda)" ]; then
apt-get update
apt-get install -y curl
curl -L -o miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-$MINICONDA_VER-$tag-x86_64.sh
bash miniconda.sh -b -p $CI_PROJECT_DIR/miniconda
conda update -y conda
export PATH=$CI_PROJECT_DIR/miniconda/bin:$PATH

if ! type conda > /dev/null; then
echo "Setting up conda..."

# setup conda if not loaded from cache
mkdir -p $WORKSPACE

# step 1: download and install miniconda
if [[ $OSTYPE == darwin* ]]; then
tag="MacOSX"
elif [[ $OSTYPE == linux* ]]; then
tag="Linux"
else
echo "Unsupported OS: $OSTYPE"
exit 1
fi
curl -L -o miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-$MINICONDA_VER-$tag-x86_64.sh
bash miniconda.sh -b -p $WORKSPACE/miniconda

conda config --system --add channels defaults
conda config --system --add channels conda-forge
conda config --system --add channels bioconda
conda config --system --add channels lcdb

# After SSHing in, for some reason this seems to fix it...
conda install -y r-base=3.4.1 bioconductor-genomeinfodbdata bioconductor-annotationhub
conda update -y conda
conda create -n lcdb-wf-test -y --file requirements.txt
conda remove -y r-base

yum install -y git
conda create -n lcdb-wf-test -y --file requirements.txt
fi

conda config --system --add channels defaults
conda config --system --add channels bioconda
conda config --system --add channels conda-forge

35 changes: 35 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
stages:
- init
- workflows

before_script:
- export PATH="$CI_PROJECT_DIR/miniconda/bin:$PATH"

initialize-conda:
stage: "init"
image: "ubuntu:latest"
script:
- "bash .circleci/setup.sh"
- "conda env export -n lcdb-wf-test > env.yaml"
cache:
key: "v1"
paths:
- "$CI_PROJECT_DIR/miniconda/"
artifacts:
paths:
- '$CI_PROJECT_DIR/env.yaml'


run-chipseq:
stage: "workflows"
image: "ubuntu:latest"
script:
- source activate lcdb-wf-test
- python ci/get-data.py
- cd workflows/chipseq
- ./run_test.sh --use-conda -j8 -k -p -r
cache:
key: "v1"
paths:
- "$CI_PROJECT_DIR/miniconda/"
policy: "pull"
129 changes: 129 additions & 0 deletions deploy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
import os
import tempfile
import argparse
import subprocess as sp
import datetime
import json

HERE = os.path.dirname(__file__)

usage = """
This script assists in the deployment of lcdb-wf to working directories.

The lcdb-wf repository contains infrastructure for testing that is not
typically needed when using it in practice. Furthermore, you might not need all
possible workflows.

This script copies over only the files requred for each "flavor" of analysis
(rnaseq, chipseq, colocalization, full) and also stores a file,
`.lcdb-wf-deployment.yaml`, containing details about the git commit that was
used and the timestamp. This can be used to compare changes and stay
up-to-date.
"""

ap = argparse.ArgumentParser(usage=usage)
ap.add_argument('--flavor', default='full', help='''Options are rnaseq, chipseq, colocalization, full. Default is full.''')
ap.add_argument('--dest', help='''Destination directory in which to copy files''')
args = ap.parse_args()
dest = args.dest
flavor = args.flavor

flavors = {
'all': {
'include': [
'wrappers/wrappers',
'include',
'lib',
'requirements.txt',
],
'exclude': [
'wrappers/wrappers/demo',
'workflows/*/run_test.sh',

# The following files to exclude are those that are created from
# a test run.
'lib/__pycache__',
'lib/postprocess/__pycache__',
'include/AnnotationHubCache',
'workflows/*/Snakefile.test',
'workflows/*/references_data',
'workflows/*/.snakemake',
'workflows/*/data',
'workflows/rnaseq/downstream/rnaseq_cache',
'workflows/rnaseq/downstream/rnaseq_files',
'workflows/rnaseq/downstream/final_clusters',
'workflows/rnaseq/downstream/*.tsv*',
'workflows/rnaseq/downstream/*log',
'workflows/rnaseq/downstream/*html',
'workflows/colocalization/results',
],
},
'chipseq': [
'workflows/chipseq',
'workflows/references',
],
'rnaseq': [
'workflows/rnaseq',
'workflows/rnaseq/downstream/',
'workflows/references',
],
'colocalization': [
'workflows/colocalization',
],

'full': [
'workflows',
],
}

paths = set(flavors['all']['include'])
paths = paths | set(flavors[flavor])

exclude = tempfile.NamedTemporaryFile(delete=False).name
with open(exclude, 'w') as fout:
fout.write('\n'.join(flavors['all']['exclude']))

include = tempfile.NamedTemporaryFile(delete=False).name
with open(include, 'w') as fout:
fout.write('\n'.join(paths) + '\n')


sp.check_call([
'rsync',
'--relative',
'-ar',
'--files-from={}'.format(include),
'--exclude-from={}'.format(exclude),
HERE,
dest])


commit, message = sp.check_output(
['git', 'log', '--oneline', '-1'],
universal_newlines=True
).strip().split(' ', 1)
now = datetime.datetime.strftime(datetime.datetime.now(), '%Y%m%d%H%M')
remotes = sp.check_output(
['git', 'remote', '-v'],
universal_newlines=True
)
remotes = [i.strip() for i in remotes.splitlines()]
branch = sp.check_output([
'git', 'branch'], universal_newlines=True)
branch = [i for i in branch.splitlines() if i.startswith('*')]
assert len(branch) == 1
branch = branch[0]
branch = branch.split('* ')[1]

d = {
'git': {
'commit': commit,
'message': message,
'remotes': remotes,
'branch': branch,
},
'timestamp': now}
log = os.path.join(dest, '.lcdb-wf-deployment.json')
with open(log, 'w') as fout:
fout.write(json.dumps(d) + '\n')
os.chmod(log, 0o440)
10 changes: 9 additions & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ Changelog
Changes since v1.2
------------------

Infrastructure
~~~~~~~~~~~~~~
- new deploy script to copy over only the files necessary for an analysis,
avoiding the clutter of testing infrastructure.
- lcdblib, an external package, is no longer a dependency. In the interest of
transparency, the relevant code was copied over to the ``lib`` directory in
this repository.

ChIP-seq and RNA-seq
~~~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -236,4 +244,4 @@ Both RNA-seq and ChIP-seq

v1.0
----
First full release.
First full release.
34 changes: 34 additions & 0 deletions docs/deploy.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Deploying ``lcdb-wf`` and staying up-to-date
============================================
The repository comes with lots of infrastructure for testing that is not
necessarily needed in practice when using lcdb-wf for a project. To get
a simplified version:

.. code-block:: bash

python deploy.py --flavor rnaseq project-dir


The script will use ``rsync`` to copy over files to `project-dir`, excluding
various test files and excluding any files that may have been created in the
process of testing. For "flavor", choose ``chipseq``, ``rnaseq``,
``colocalization``, or ``full`` to get everything.

This script also writes a file in the destination called
``.lcdb-wf-deployment.json`` which stores details about what commit was used to
deploy and the timestamp. This can come in handy later when comparing
a deployed directory with the main repository to decide whether to update.

Updating
--------
The most straightforward approach to updating is to use a diff tool like `meld
<http://meldmerge.org>`_ to visually compare differences between a deployed
project and a freshly-cloned version of lcdb-wf:

.. code-block:: bash

git clone https://github.com/lcdb/lcdb-wf.git comparison-directory
meld project-dir comparison-directory

This way you can pick and choose which updates are relevant without having to
resort to arcane git commands and difficult merges.
Loading