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

Update deployment and add version notice #77

Merged
merged 11 commits into from
Sep 7, 2023
30 changes: 21 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,20 +198,31 @@ jobs:

# make sure we have a lowercase repo
user_name="bids"
repo_name=$(echo "${CIRCLE_PROJECT_REPONAME}_fs<< parameters.version >>" | tr '[:upper:]' '[:lower:]')
repo_name=$(echo "${CIRCLE_PROJECT_REPONAME}" | tr '[:upper:]' '[:lower:]')
FSMAJORVERSION=<< parameters.version >>
Shotgunosine marked this conversation as resolved.
Show resolved Hide resolved
if [[ FSMAJORVERSION -eq 6 ]]; then
FSVERSION=6.0.1
else
FSVERSION=7.4.1
fi

if [[ -n "${DOCKER_TOKEN}" ]]; then
echo "${DOCKER_TOKEN}" | docker login -u "${DOCKER_USER}" --password-stdin

: "Pushing to DockerHub ${user_name}/${repo_name}:unstable"
docker tag "${user_name}/${repo_name}" "${user_name}/${repo_name}:unstable"
docker push "${user_name}/${repo_name}:unstable"
docker tag "${user_name}/${repo_name}" "${user_name}/${repo_name}:${FSVERSION}-unstable"
docker push "${user_name}/${repo_name}:${FSVERSION}-unstable"

if [[ -n "${CIRCLE_TAG}" ]]; then
: "Pushing to DockerHub ${user_name}/${repo_name}:${FSVERSION}-${CIRCLE_TAG}"
if [[ FSMAJORVERSION -eq 6 ]]; then
docker push "${user_name}/${repo_name}:latest"
fi

if [[ -n "${CIRCLE_TAG}" ]]; then
: "Pushing to DockerHub ${user_name}/${repo_name}:${CIRCLE_TAG}"
docker push "${user_name}/${repo_name}:latest"
docker tag "${user_name}/${repo_name}" "${user_name}/${repo_name}:${CIRCLE_TAG}"
docker push "${user_name}/${repo_name}:${CIRCLE_TAG}"
docker tag "${user_name}/${repo_name}" "${user_name}/${repo_name}:${FSMAJORVERSION}"
docker push ${user_name}/${repo_name}:${FSMAJORVERSION}
docker tag "${user_name}/${repo_name}" "${user_name}/${repo_name}:${FSVERSION}-${CIRCLE_TAG}"
docker push "${user_name}/${repo_name}:${FSVERSION}-${CIRCLE_TAG}"
fi

fi
Expand Down Expand Up @@ -244,6 +255,7 @@ workflows:
only: /.*/

- test:
name: test_<< matrix.version >>
matrix:
parameters:
version: ['6', '7']
Expand All @@ -263,7 +275,7 @@ workflows:
context:
- dockerhub
requires:
- test
- test_<< matrix.version >>
filters:
branches:
ignore: /.*/
Expand Down
17 changes: 13 additions & 4 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
def run(command, env={}, ignore_errors=False):
merged_env = os.environ
merged_env.update(env)

# DEBUG env triggers freesurfer to produce gigabytes of files
merged_env.pop('DEBUG', None)
process = Popen(command, stdout=PIPE, stderr=subprocess.STDOUT, shell=True, env=merged_env)
Expand All @@ -27,7 +28,17 @@ def run(command, env={}, ignore_errors=False):
if process.returncode != 0 and not ignore_errors:
raise Exception("Non zero return code: %d" % process.returncode)


# warn about freesurfer version
with open(os.path.join(os.environ['FREESURFER_HOME'], 'build-stamp.txt'), 'r') as h:
bs = h.read()
if 'x86_64-7.' in bs:
fsversion=7
else:
fsversion=6
warn("You are using FreeSurver version 6. "
"The FreeSurfer 7 BIDS-App is now available via docker pull bids/freesurfer:v7 . "
"FreeSurfer 7 will become the default version in the FreeSurfer BIDS-App begining in 2024. "
"From that point on, the FreeSurfer 6 BIDS-App will remain available at bids/freesurfer:v6 .")
__version__ = open(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'version')).read()

parser = argparse.ArgumentParser(description='FreeSurfer recon-all + custom template generation.')
Expand Down Expand Up @@ -519,9 +530,7 @@ def run(command, env={}, ignore_errors=False):

# The call to python2 is only required if we're running Freesurfer 6, we'll need to check version
# and modify the calls accordingly.
with open(os.path.join(os.environ['FREESURFER_HOME'], 'build-stamp.txt'), 'r') as h:
bs = h.read()
if '-7.' in bs:
if fsversion == 7:
cmd_start = ''
else:
cmd_start = 'python2 '
Expand Down