Skip to content

Commit

Permalink
Merge branch 'sub_queue_and_find_py_venv' into release-0.15.3
Browse files Browse the repository at this point in the history
  • Loading branch information
sammeier committed May 23, 2017
2 parents 397c8b7 + cec46cb commit 0b0a75b
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 36 deletions.
35 changes: 28 additions & 7 deletions firecloud/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ def get_entity(namespace, workspace, etype, ename, api_root=PROD_API_ROOT):
api_root, namespace, workspace, etype, ename)
return __get(uri)


def delete_entities(namespace, workspace, json_body, api_root=PROD_API_ROOT):
"""Delete entities in a workspace.
Expand Down Expand Up @@ -812,7 +813,7 @@ def update_repository_method(namespace, method, synopsis,

def delete_repository_method(namespace, name, snapshot_id,
api_root=PROD_API_ROOT):
"""Redact a version of a workflow.
"""Redacts a method and all of its associated configurations.
The method should exist in the methods repository.
Expand All @@ -823,10 +824,27 @@ def delete_repository_method(namespace, name, snapshot_id,
api_root (str): FireCloud API url, if not production
Swagger:
UNDOCUMENTED
https://api.firecloud.org/#!/Method_Repository/delete_api_methods_namespace_name_snapshotId
"""
uri = "{0}/methods/{1}/{2}/{3}".format(api_root, namespace,
name, snapshot_id)
uri = "{0}/methods/{1}/{2}/{3}".format(api_root, namespace, name, snapshot_id)
return __delete(uri)

def delete_repository_config(namespace, name, snapshot_id,
api_root=PROD_API_ROOT):
"""Redacts a configuration and all of its associated configurations.
The configuration should exist in the methods repository.
Args:
namespace (str): configuration namespace
configuration (str): configuration name
snapshot_id (int): snapshot_id of the configuration
api_root (str): FireCloud API url, if not production
Swagger:
https://api.firecloud.org/#!/Method_Repository/delete_api_configurations_namespace_name_snapshotId
"""
uri = "{0}/configurations/{1}/{2}/{3}".format(api_root, namespace, name, snapshot_id)
return __delete(uri)

def get_repository_method_acl(namespace, method,
Expand Down Expand Up @@ -1089,7 +1107,7 @@ def list_workspaces(api_root=PROD_API_ROOT):
"""
return __get(api_root+ "/workspaces")

def create_workspace(namespace, name, protected=False,
def create_workspace(namespace, name, authorizationDomain = "",
attributes=None, api_root=PROD_API_ROOT):
"""Create a new FireCloud Workspace.
Expand All @@ -1108,12 +1126,15 @@ def create_workspace(namespace, name, protected=False,
uri = "{0}/workspaces".format(api_root)
if not attributes:
attributes = dict()

body = {
"namespace": namespace,
"name": name,
"attributes": attributes,
"isProtected": protected
"attributes": attributes
}
if authorizationDomain:
body["authorizationDomain"] = {"membersGroupName": authorizationDomain}

return __post(uri, json=body)

def delete_workspace(namespace, workspace,api_root=PROD_API_ROOT):
Expand Down
8 changes: 4 additions & 4 deletions firecloud/fiss.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def space_lock(args):
def space_new(args):
""" Create a new workspace. """
r = fapi.create_workspace(args.project, args.workspace,
args.protected, dict(), args.api_url)
args.authdomain, dict(), args.api_url)
fapi._check_response_code(r, 201)
print_('Created workspace {0}/{1}'.format(args.project, args.workspace))
if fapi.get_verbosity():
Expand Down Expand Up @@ -1528,9 +1528,9 @@ def main(argv=None):
# Create Workspace
subp = subparsers.add_parser('space_new', parents=[workspace_parent],
description='Create new workspace')
phelp = 'Create a protected (dbGaP-controlled) workspace.'
phelp += 'You must have linked NIH credentials for this option.'
subp.add_argument('--protected', action='store_true', help=phelp)
phelp = 'Limit access to the workspace to a specific authorization domain. '
phelp += 'For dbGaP-controlled access (domain name: dbGapAuthorizedUsers) you must have linked NIH credentials to your account.'
subp.add_argument('--authdomain', default="", help=phelp)
subp.set_defaults(func=space_new)

# Determine existence of workspace
Expand Down
10 changes: 8 additions & 2 deletions firecloud/tests/highlevel_tests.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,22 @@

# Context manager to capture stdout when calling another function
# Source: http://stackoverflow.com/questions/16571150/how-to-capture-stdout-output-from-a-python-function-call
from cStringIO import StringIO
# from cStringIO import StringIO
# replace cStringIO with StringIO for python3 compatibility
from io import StringIO
import sys
import ast

class Capturing(list):
def __enter__(self):
self._stdout = sys.stdout
sys.stdout = self._stringio = StringIO()
return self
def __exit__(self, *args):
self.extend(self._stringio.getvalue().splitlines())
if sys.version_info[0] < 3:
self.extend(self._stringio.getvalue().splitlines())
else:
self.extend(ast.literal_eval(self._stringio.getvalue()).decode().splitlines())
del self._stringio # free up some memory
sys.stdout = self._stdout

Expand Down
5 changes: 3 additions & 2 deletions firecloud/tests/lowlevel_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,11 @@ def test_get_submission(self):
"""Test get_submission()."""
pass

@unittest.skip("Not Implemented")
def test_get_submission_queue(self):
"""Test get_submission_queue()."""
pass
r = fapi.get_submission_queue()
print_(r.status_code, r.content)
self.assertEqual(r.status_code, 200)

@unittest.skip("Not Implemented")
def test_get_workflow_outputs(self):
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
'requests',
'six',
'yapsy',
'nose',
'pylint==1.7.1'
],
classifiers = [
Expand Down
48 changes: 27 additions & 21 deletions util/findPython.sh
Original file line number Diff line number Diff line change
@@ -1,36 +1,42 @@
#!/bin/bash

# findPython.sh: help determine installation location for this package,
# by identifying existing candidate Python installations
# config.sh: Help determine installation location for gdctools package,
# by identifying existing Python installations as candidates.

InstallDir=

# Use any Python3 installation, or Python2 if >= 2.7
Python=`type -P python`
if [ -n "$Python" ] ; then
case `python --version 2>&1 | awk '{print $NF}'` in
2.7*| 3.*)
InstallDir=`dirname $Python`
InstallDir=`dirname $InstallDir`
;;
esac
if [ -n "$1" ] ; then
PythonExe=$1
shift
else
PythonExe=python
fi

# For convenience, give precedence to well-known directories @ Broad Institute
BroadDirs="/local/firebrowse/latest /xchip/tcga/Tools/gdac/latest"
for dir in $BroadDirs ; do
if [ -d $dir ] ; then
InstallDir=$dir
break
fi
done

if [ -z "$InstallDir" ] ; then
# Nothing found: for convenience, look for well-known dirs @ Broad Institute
BroadDirs="/local/firebrowse/latest /xchip/tcga/Tools/gdac/latest"
for dir in $BroadDirs ; do
if [ -d $dir ] ; then
InstallDir=$dir
break
fi
done
if [ -n "$VIRTUAL_ENV" ] ; then
InstallDir=$VIRTUAL_ENV
else
Python=`type -P $PythonExe`
if [ -n "$Python" ]; then
InstallDir=`dirname $Python`
InstallDir=`dirname $InstallDir`
fi
fi
fi

if [ -z "$InstallDir" ] ; then
echo "Error: could not find an appropriate python installation to use" >&2
echo "Error: could not find a $PythonExe installation to use" >&2
exit 1
fi

echo "$InstallDir"
exit 0
exit 0

0 comments on commit 0b0a75b

Please sign in to comment.