-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from big-data-lab-team/develop
Release 0.2
- Loading branch information
Showing
25 changed files
with
448 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
language: python | ||
|
||
sudo: required | ||
|
||
services: | ||
- docker | ||
- privileged: true | ||
|
||
python: | ||
- 2.7 | ||
|
||
install: true | ||
|
||
before_script: | ||
- docker build -t simtool . | ||
|
||
script: | ||
- docker run --privileged --rm=false -v /var/run/docker.sock:/var/run/docker.sock -v $PWD:$PWD -w $PWD/sim simtool ./tests/execute_pytest.sh | ||
|
||
after_success: | ||
- coveralls | ||
|
||
deploy: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,29 @@ | ||
FROM mesosphere/spark:2.0.0-2.2.0-1-hadoop-2.6 | ||
FROM jupyter/pyspark-notebook:82b978b3ceeb | ||
|
||
RUN apt-get -y install docker.io \ | ||
python-setuptools && \ | ||
easy_install pip | ||
USER root | ||
|
||
RUN apt-get update && \ | ||
echo 'Y' | apt-get install apt-utils && \ | ||
echo 'Y' | apt-get install curl && \ | ||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - && \ | ||
echo 'Y' | apt install --reinstall base-files lsb-release lsb-base && \ | ||
echo 'Y' | apt-get install software-properties-common && \ | ||
echo 'Y' | apt-get install apt-transport-https && \ | ||
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $( lsb_release -cs ) stable" && \ | ||
apt-get update && \ | ||
apt-get install -y docker-ce && \ | ||
service docker start | ||
|
||
RUN conda create -n simenv python=2.7 pytest py4j==0.10.4 pyspark pytest-cov | ||
|
||
RUN pip install boutiques pytest pyspark pybids | ||
ENV PATH /opt/conda/envs/simenv/bin:$PATH | ||
|
||
ENTRYPOINT ["pytest"] | ||
RUN /bin/bash -c "source activate simenv" | ||
|
||
ENV PYTHONPATH /opt/conda/envs/python2/lib/python2.7/site-packages:\ | ||
/usr/local/spark-2.2.0-bin-hadoop2.7/python:\ | ||
/opt/conda/envs/python2/bin:$PYTHONPATH | ||
|
||
RUN pip install boutiques pybids duecredit nipype | ||
|
||
ENTRYPOINT ["/bin/bash"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
[metadata] | ||
description-file = README.md | ||
[aliases] | ||
test=pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import boutiques, os, time, errno, tarfile, json | ||
|
||
class Sim(object): | ||
|
||
def __init__(self, boutiques_descriptor, input_path, output_dir): | ||
|
||
self.boutiques_descriptor = boutiques_descriptor | ||
self.input_path = input_path | ||
self.output_dir = output_dir | ||
|
||
def create_tar_file(self, out_dir, tar_name, files): | ||
try: | ||
os.makedirs(out_dir) | ||
except OSError as e: | ||
if e.errno != errno.EEXIST: | ||
raise | ||
with tarfile.open(os.path.join(out_dir, tar_name), "w") as tar: | ||
for f in files: | ||
tar.add(f) | ||
|
||
def write_invocation_file(self, invocation, invocation_file): | ||
|
||
# Note: the invocation file format will change soon | ||
json_invocation = json.dumps(invocation) | ||
|
||
# Writes invocation | ||
with open(invocation_file,"w") as f: | ||
f.write(json_invocation) | ||
|
||
def bosh_exec(self, invocation_file, mount=None): | ||
try: | ||
|
||
if mount is None: | ||
boutiques.execute("launch",self.boutiques_descriptor,invocation_file, "-x") | ||
else: | ||
boutiques.execute("launch", self.boutiques_descriptor, invocation_file, "-v", | ||
"{0}:{0}".format(mount), "-x") | ||
result = 0 | ||
except SystemExit as e: | ||
result = e.code | ||
return (result, "Empty log, Boutiques API doesn't return it yet.\n") | ||
|
||
def pretty_print(self, result): | ||
(label, (returncode, log)) = result | ||
status = "SUCCESS" if returncode == 0 else "ERROR" | ||
timestamp = str(int(time.time() * 1000)) | ||
filename = "{0}.{1}.log".format(timestamp, label) | ||
with open(filename,"w") as f: | ||
f.write(log) | ||
print(" [ {0} ({1}) ] {2} - {3}".format(status, returncode, label, filename)) | ||
|
||
def check_failure(self, result): | ||
(label, (returncode, log)) = result | ||
return True if returncode !=0 else False | ||
|
||
|
||
def write_BIDS_invocation(self, analysis_level, participant_label, invocation_file): | ||
|
||
invocation = {} | ||
invocation["bids_dir"] = self.input_path | ||
invocation["output_dir_name"] = self.output_dir | ||
if analysis_level == "participant": | ||
invocation["analysis_level"] = "participant" | ||
invocation["participant_label"] = participant_label | ||
elif analysis_level == "group": | ||
invocation["analysis_level"] = "group" | ||
|
||
self.write_invocation_file(invocation, invocation_file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.