Skip to content
This repository was archived by the owner on Dec 27, 2022. It is now read-only.

Commit 3d0a4ae

Browse files
committed
rf/wip: removing boto3 requirements, removing some s3-related functions, updated travis.yml to see if it pushes to ghpages from travis
1 parent 19ed647 commit 3d0a4ae

File tree

11 files changed

+21
-808
lines changed

11 files changed

+21
-808
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ env:
2222
global:
2323
- GH_USER: nipy
2424
- GH_REPO: dmriprep
25-
- secure: VmTfAChlLlC8WfK0QS9UzfTdI58so7YLkQdlTbB3WptqKIPDcGUSUjyB5ow9BO6nwupN0/zxaM3rneWJeJ7oEBQWGrbpdDkLWkCPB6htjECmUhfyWJccBH4ZnvVjDQH9Wl5SgNieJjGzI8QBLwnsvjzafH3VkP3SWFvqq4J3bGyDb97MUkWgDLdjy+3HsX6Ye7HCkYnLhi2BSwON/asQLd+Pr1FOv+P2tsJgwz9X4gkzws8gP5jGM4J5jxwYRUQKZKjgiEvDZbL0OqTvH/jxELKwcuIhDrqVeemZn5wWLRt7pvFUAzAwUliE0/NROUFi57RhU9NrwOZAo7ek3muM33AgBGodpkFJJ9vmsMJf5Diz71YN3xvMMD2vlfDByjcPOqYu/uM5o6sbuLZNDc+NExlsSSskMOnOBGz5e+Exo6c+X6Dxqx3rT6jmBPVTv7E9RiL1wwXF18fpCDrXwZb/mmxxbB0Bm3x/etIbi/mmbGlPo8K2GgOyzACPK3DHA6lRPd97qwU5cp/+7IWr7LWrVxAl6VS19/GIkVVlmBS3/7IJSg4ANgLAVZzXrcRcJTEY2xsF3TFJm840v6ArkFEogj84dGcxr1o9oLFLh2ZBSatoqSwdL8NezJruoOYDGzW37thp51iAHwNZ+Zfpv/PIcmWRrsBbhV+FA8KkFxmfIR0=
25+
- secure: raeexu68fu/Hu4Ey0VkP3ljvAJut2X8xRAkTXO9nL6HlWQGt1pjYhXSxaLLZVQpgpDcDeOziUUCb4y7UALFHTkIrYrzp/Jq3Cn10tmsItEMAhH0cfzTuMr0Huhl/Zeiw67Qn16W7xpYEtV7zHBOYicQIFvzAOhNWDy/A/9c7XkKsEU47FqN/vxodCv+WMHQyvuM3ceaofccF+mVekAg7PztPrukzpwP+uishNfSeoHI3WeUDjX82bQZ3KE/oRHrB+YCB5rFg0wfekfsUnkyhS9HWF9CECM5mKWcPle0AZpjQXODrUIXk8dRSAprAzD1XGxRzmYG3nYPGx9a6gm6ofueHbLPery/0cLVYNX4IHBR2UpW6aA9VsgMBgG8LAdGiMqvvio2CZ+/tGdmIXx5twRCTGaJ4qJUdyyL881ChaUl8rBde7R8EtCBThKeV8Tnnun2PfLPt12qAc+EAc1r6a9zf/Mb8ahjTrZSU1heUn5irs44KvJk+QuftW9hF6hIvBfug7SHBIAdvyCd8TjMNShJNVPqQZU6NWSwTAGAj4Y/QsocvxYRoKHIhpyHbMZ+Lj+P27VfNYdkTe/viQcLEg8x4YYHCaKiYl4iwepEtyevtbtzUtb1Ba5clotgisw/PFao9q6GrWuy57eb/ZM8aKSHfb4JhN0swmi1t0uBOzP0=

dmriprep/__init__.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,17 @@
1010
import logging
1111
import os
1212

13-
from .dmriprep import upload_to_s3 # noqa
14-
from . import fetch_bids_s3 # noqa
15-
16-
1713
module_logger = logging.getLogger(__name__)
1814

1915
# get the log level from environment variable
20-
if "AFQ_LOGLEVEL" in os.environ:
21-
loglevel = os.environ['AFQ_LOGLEVEL']
16+
if "DMIRPREP_LOGLEVEL" in os.environ:
17+
loglevel = os.environ['DMRIPREP_LOGLEVEL']
2218
module_logger.setLevel(getattr(logging, loglevel.upper()))
2319
else:
2420
module_logger.setLevel(logging.WARNING)
2521

2622
# create a file handler
27-
logpath = os.path.join(os.path.expanduser('~'), '.afq', 'afq.log')
23+
logpath = os.path.join(os.path.expanduser('~'), '.dmriprep', 'dmriprep.log')
2824

2925
# Create the config directory if it doesn't exist
3026
logdir = os.path.dirname(logpath)
@@ -49,8 +45,3 @@
4945
# add the handlers to the logger
5046
module_logger.addHandler(handler)
5147
module_logger.info('Started new dmriprep session')
52-
53-
# Reduce verbosity of the boto logs
54-
logging.getLogger('boto').setLevel(logging.WARNING)
55-
logging.getLogger('boto3').setLevel(logging.WARNING)
56-
logging.getLogger('botocore').setLevel(logging.WARNING)

dmriprep/base.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44

55
from collections import namedtuple
66

7-
import boto3
8-
from botocore import UNSIGNED
9-
from botocore.client import Config
10-
117

128
# Define the different namedtuple return types
139
InputFiles = namedtuple(
@@ -20,6 +16,3 @@
2016
'InputFilesWithSession',
2117
['subject', 'site', 'session', 'files', 'file_type']
2218
)
23-
24-
# Global s3 client to preserve anonymous config
25-
s3_client = boto3.client('s3', config=Config(signature_version=UNSIGNED))

dmriprep/dmriprep.py

Lines changed: 1 addition & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -7,91 +7,12 @@
77
import os.path as op
88
import subprocess
99

10-
import boto3
11-
import nibabel as nib
12-
13-
from . import fetch_bids_s3 as fetch
14-
from .run_1 import run_dmriprep
10+
from .run import run_dmriprep
1511

1612

1713
mod_logger = logging.getLogger(__name__)
1814

1915

20-
def move_t1_to_freesurfer(t1_file):
21-
"""Move the T1 file back into the freesurfer directory.
22-
23-
This step is specific to the HBN dataset where the T1 files
24-
are outside of the derivatives/sub-XXX/freesurfer directory.
25-
26-
Parameters
27-
----------
28-
t1_file : string
29-
Path to the T1 weighted nifty file
30-
"""
31-
freesurfer_path = op.join(op.dirname(t1_file), 'freesurfer')
32-
33-
convert_cmd = 'mri_convert {in_:s} {out_:s}'.format(
34-
in_=t1_file, out_=op.join(freesurfer_path, 'mri', 'orig.mgz')
35-
)
36-
37-
fnull = open(os.devnull, 'w')
38-
cmd = subprocess.call(convert_cmd.split(),
39-
stdout=fnull,
40-
stderr=subprocess.STDOUT)
41-
42-
43-
def upload_to_s3(output_files, outdir, bucket, prefix, site, session, subject):
44-
"""Upload output files to S3, using key format specified by input params
45-
46-
Parameters
47-
----------
48-
output_files : list
49-
Output files to transfer to S3. Assume that the user has passed in
50-
relative paths that are appropriate to fill in after the 'dmriprep'
51-
directory.
52-
53-
outdir : string
54-
a path to the root of the data
55-
56-
bucket : string
57-
Output S3 bucket
58-
59-
prefix : string
60-
Output S3 prefix
61-
62-
site : string
63-
Site ID, e.g. 'side-SI'
64-
65-
session : string
66-
Session ID, e.g. 'sess-001'
67-
68-
subject : string
69-
Subject ID, e.g. 'sub-ABCXYZ'
70-
71-
Returns
72-
-------
73-
list
74-
S3 keys for each output file
75-
"""
76-
s3 = boto3.client('s3')
77-
78-
def filename2s3key(filename):
79-
return '/'.join([
80-
prefix, site, subject, session,
81-
'derivatives', 'dmriprep',
82-
filename
83-
])
84-
85-
for file in output_files:
86-
with open(op.abspath(op.join(outdir, file)), 'rb') as fp:
87-
s3.put_object(
88-
Bucket=bucket,
89-
Body=fp,
90-
Key=filename2s3key(file),
91-
)
92-
93-
return [filename2s3key(f) for f in output_files]
94-
9516

9617
def pre_afq_individual(input_s3_keys, s3_prefix, out_bucket,
9718
in_bucket='fcp-indi', workdir=op.abspath('.')):

0 commit comments

Comments
 (0)