Skip to content

Commit

Permalink
FISS v0.16.13:
Browse files Browse the repository at this point in the history
* Docker updated to use local files rather than pull from pypi
* Enhanced installation of Google Cloud SDK and ensured its availability
to subprocesses
* Fixed a broken test
  • Loading branch information
dheiman committed Jun 1, 2018
1 parent 1b8f97c commit 6d440fc
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 45 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
*
!Dockerfile
!firecloud
!LICENSE
!README
!requirements.txt
!setup.py
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
FROM python:2.7.15-slim

COPY . /fiss

RUN set -ex \
&& apt-get update && apt-get install -y --no-install-recommends curl \
&& rm -rf /var/lib/apt/lists/* \
&& pip install --no-cache-dir -U --upgrade-strategy eager firecloud
&& pip install --no-cache-dir -U --upgrade-strategy eager /fiss \
&& rm -rf /fiss

CMD ["fissfc"]
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ Change Log for FISSFC: the (Fi)recloud (S)ervice (S)elector
=======================================================================
Terms used below: HL = high level interface, LL = low level interface

v0.16.13 - Dockerfile updated to use local files rather than pull from pypi;
Enhanced installation of Google Cloud SDK and ensured its
availability to subprocesses; Fixed a broken LL test.

v0.16.12 - Removed gcloud requirement from README (automatic as of v0.16.11);
Updated Dockerfile and added .dockerignore

Expand Down
2 changes: 1 addition & 1 deletion firecloud/__about__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Package version
__version__ = "0.16.12"
__version__ = "0.16.13"
42 changes: 42 additions & 0 deletions firecloud/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import os

# Based on https://stackoverflow.com/a/379535
def which(program):
"""Find given program on system PATH. Works for both *NIX and Windows"""
def is_exe(fpath):
return os.path.exists(fpath) and os.access(fpath, os.X_OK) and os.path.isfile(fpath)

def ext_candidates(fpath):
yield fpath
# Handle windows executable extensions
for ext in os.environ.get("PATHEXT", "").split(os.pathsep):
if ext: yield fpath + ext

fpath, _ = os.path.split(program)
if fpath and is_exe(program):
return program
else:
for path in os.environ["PATH"].split(os.pathsep):
exe_file = os.path.join(path, program)
for candidate in ext_candidates(exe_file):
if is_exe(candidate):
return candidate

return None

def __ensure_gcloud():
"""The *NIX installer is not guaranteed to add the google cloud sdk to the
user's PATH (the Windows installer does). This ensures that if the default
directory for the executables exists, it is added to the PATH for the
duration of this package's use."""
if which('gcloud') is None:
gcloud_path = os.path.join(os.path.expanduser('~'),
'google-cloud-sdk', 'bin')
env_path = os.getenv('PATH')
if os.path.isdir(gcloud_path):
if env_path is not None:
os.environ['PATH'] = gcloud_path + os.pathsep + env_path
else:
os.environ['PATH'] = gcloud_path

__ensure_gcloud()
2 changes: 1 addition & 1 deletion firecloud/tests/lowlevel_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_clone_workspace(self):
# Cleanup, Delete workspace
r = fapi.delete_workspace(self.project, temp_space)
print(r.status_code, r.content)
self.assertEqual(r.status_code, 200)
self.assertIn(r.status_code, [200, 202])

@unittest.skip("Not Implemented")
def test_copy_config_from_repo(self):
Expand Down
76 changes: 34 additions & 42 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,26 @@
from setuptools.package_index import PackageIndex
from setuptools.command.easy_install import six, rmtree_safe, rmtree, log
from firecloud.__about__ import __version__
from firecloud import which
_README = os.path.join(os.path.dirname(__file__), 'README')
_LONG_DESCRIPTION = open(_README).read()

# Based on https://stackoverflow.com/a/379535
def which(program):
def is_exe(fpath):
return os.path.exists(fpath) and os.access(fpath, os.X_OK) and os.path.isfile(fpath)

def ext_candidates(fpath):
yield fpath
# Handle windows executable extensions
for ext in os.environ.get("PATHEXT", "").split(os.pathsep):
if ext: yield fpath + ext

fpath, _ = os.path.split(program)
if fpath and is_exe(program):
return program
else:
for path in os.environ["PATH"].split(os.pathsep):
exe_file = os.path.join(path, program)
for candidate in ext_candidates(exe_file):
if is_exe(candidate):
return candidate

return None

class InstallCommand(install):
def needs_gcloud(self):
"""Returns true if gcloud is unavailable and needed for
authentication."""
gcloud_default_path = ['google-cloud-sdk', 'bin']
if platform.system() != "Windows":
gcloud_default_path = os.path.join(os.path.expanduser('~'),
*gcloud_default_path)
else:
gcloud_default_path = os.path.join(os.environ['LOCALAPPDATA'],
'Google', 'Cloud SDK',
*gcloud_default_path)
return not os.getenv('SERVER_SOFTWARE',
'').startswith('Google App Engine/') and \
which('gcloud') is None
'').startswith('Google App Engine/') \
and gcloud_default_path not in os.environ["PATH"].split(os.pathsep) \
and which('gcloud') is None

sub_commands = install.sub_commands + [('install_gcloud', needs_gcloud)]

Expand All @@ -56,20 +43,22 @@ def initialize_options(self):
self.package_index = None

def finalize_options(self):
self.win_gcloud_url = \
"https://dl.google.com/dl/cloudsdk/channels/rapid/google-cloud-sdk.zip"
self.nix_gcloud_url = "https://sdk.cloud.google.com"
self.win_gcloud_installer = "google-cloud-sdk\install.bat"
self.silent = "--disable-prompts"

if platform.system() != "Windows":
self.curl = which('curl')
self.bash = which('bash')
self.gcloud_url = "https://sdk.cloud.google.com"
self.silent = "--disable-prompts"
else:
self.silent = "/S"
self.gcloud_url = "https://dl.google.com/dl/cloudsdk/channels/" \
"rapid/GoogleCloudSDKInstaller.exe"
self.package_index = PackageIndex()

# Copied from setuptools.command.easy_install.easy_install
@contextlib.contextmanager
def _tmpdir(self):
tmpdir = tempfile.mkdtemp(prefix=six.u("easy_install-"))
tmpdir = tempfile.mkdtemp(prefix=six.u("install_gcloud-"))
try:
# cast to str as workaround for #709 and #710 and #712
yield str(tmpdir)
Expand All @@ -80,13 +69,11 @@ def run(self):
warn_msg = "Please install the Google Cloud SDK manually:\n\t" \
"https://cloud.google.com/sdk/downloads"
if platform.system() == "Windows":
from zipfile import ZipFile
with self._tmpdir() as tmpdir:
ZipFile(self.package_index.download(self.win_gcloud_url,
tmpdir)).extractall(tmpdir)
gcloud_install_cmd = \
self.package_index.download(self.gcloud_url, tmpdir)
try:
output = subprocess.check_output([os.path.join(tmpdir,
self.win_gcloud_installer),
output = subprocess.check_output([gcloud_install_cmd,
self.silent],
stderr=subprocess.STDOUT)
log.info(output)
Expand All @@ -96,7 +83,7 @@ def run(self):
elif self.curl is not None and self.bash is not None:
try:
script = subprocess.check_output([self.curl, "-s", "-S",
self.nix_gcloud_url],
self.gcloud_url],
stderr=subprocess.STDOUT)
if script:
with self._tmpdir() as tmpdir:
Expand All @@ -116,6 +103,12 @@ def run(self):
else:
log.warn("Unable to find curl and/or bash. " + warn_msg)

def get_inputs(self):
return []

def get_outputs(self):
return []

# Setup information
setup(
cmdclass = {
Expand All @@ -129,6 +122,7 @@ def run(self):
author = 'Broad Institute CGA Genome Data Analysis Center',
author_email = 'gdac@broadinstitute.org',
long_description = _LONG_DESCRIPTION,
license = "BSD 3-Clause License",
url = 'https://github.com/broadinstitute/fiss',
entry_points = {
'console_scripts': [
Expand All @@ -139,7 +133,7 @@ def run(self):
},
test_suite = 'nose.collector',
install_requires = [
'google-auth',
'google-auth==1.4.2',
'pydot',
'requests[security]',
'six',
Expand All @@ -150,8 +144,6 @@ def run(self):
"Programming Language :: Python :: 3",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering :: Bio-Informatics",
"Topic :: Scientific/Engineering :: Interface Engine/Protocol Translator",

],

"Topic :: Scientific/Engineering :: Interface Engine/Protocol Translator"
]
)

0 comments on commit 6d440fc

Please sign in to comment.