Skip to content

Commit 95e03f1

Browse files
authored
v0.16.34 (#180)
api.py * check for presence of clock skew argument rather than check google.auth.__version__ fiss.py * meth_acl/config_acl - changed map(f(x),iterable) returns into list comprehensions to make py2/3 consistent * mop updated to account for change in Terra output directory structure fccore.py * removed version string parser in favor of above check for the clock skew argument
1 parent 50a3e2a commit 95e03f1

File tree

5 files changed

+34
-52
lines changed

5 files changed

+34
-52
lines changed

changelog.txt

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ Change Log for FISSFC: the (Fi)recloud (S)ervice (S)elector
33
=======================================================================
44
Terms used below: HL = high level interface, LL = low level interface
55

6+
v0.16.34 - Hotfixes: in Python 2 map() returns a list, in Python 3, map()
7+
returns a generator object - tasks that returned map(f(x),iterable)
8+
now return a list comprehension; clock-skew now checks for argument
9+
presence at runtime rather than google.auth version; mop HL function
10+
updated to account for new output path structure in Terra.
11+
612
v0.16.33 - HL: added space_size, space_cost; hotfixes: fixed Python 2 compatibility;
713
blocked google-auth versions with restrictive clock-skew and enabled
814
later versions with modifiable clock-skew, increasing clock-skew

firecloud/__about__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# Package version
2-
__version__ = "0.16.33"
2+
__version__ = "0.16.34"

firecloud/api.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@
2121
from six.moves.urllib.parse import urlencode, urljoin
2222
from six import string_types
2323

24+
import inspect
25+
2426
import google.auth
2527
from google.auth.exceptions import DefaultCredentialsError, RefreshError
2628
from google.auth.transport.requests import AuthorizedSession, Request
2729
from google.oauth2 import id_token
2830

2931
from firecloud.errors import FireCloudServerError
3032
from firecloud.fccore import __fcconfig as fcconfig
31-
from firecloud.fccore import release_tuple_from_version_string
3233
from firecloud.__about__ import __version__
3334

3435
FISS_USER_AGENT = "FISS/" + __version__
@@ -49,12 +50,18 @@ def _set_session():
4950
global __USER_ID
5051

5152
if __SESSION is None:
53+
# determine if clock_skew_in_seconds is a parameter for id_token.verify_oauth2_token()
54+
try: # PY3
55+
argspec = inspect.getfullargspec(id_token.verify_oauth2_token)
56+
except AttributeError: # PY2
57+
argspec = inspect.getargspec(id_token.verify_oauth2_token)
58+
5259
try:
5360
__SESSION = AuthorizedSession(google.auth.default(['https://www.googleapis.com/auth/userinfo.profile',
5461
'https://www.googleapis.com/auth/userinfo.email'])[0])
5562
health()
5663
# google.auth 2.1.0 introduced a restrictive clock skew that was unmodifiable until 2.3.2
57-
if release_tuple_from_version_string(google.auth.__version__) >= (2,3,2):
64+
if 'clock_skew_in_seconds' in argspec.args:
5865
__USER_ID = id_token.verify_oauth2_token(__SESSION.credentials.id_token,
5966
Request(session=__SESSION),
6067
clock_skew_in_seconds=10)['email']

firecloud/fccore.py

-43
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import tempfile
2222
import shutil
2323
import subprocess
24-
import re
2524
from io import IOBase
2625
from firecloud import __about__
2726
from google.auth import environment_vars
@@ -220,46 +219,4 @@ def edit_file(name, backup=None):
220219
current_tolm = os.stat(name).st_mtime
221220
return current_tolm != previous_tolm
222221

223-
224-
# From PEP-440:
225-
# https://peps.python.org/pep-0440/#appendix-b-parsing-version-strings-with-regular-expressions
226-
VERSION_PATTERN = r"""
227-
v?
228-
(?:
229-
(?:(?P<epoch>[0-9]+)!)? # epoch
230-
(?P<release>[0-9]+(?:\.[0-9]+)*) # release segment
231-
(?P<pre> # pre-release
232-
[-_\.]?
233-
(?P<pre_l>(a|b|c|rc|alpha|beta|pre|preview))
234-
[-_\.]?
235-
(?P<pre_n>[0-9]+)?
236-
)?
237-
(?P<post> # post release
238-
(?:-(?P<post_n1>[0-9]+))
239-
|
240-
(?:
241-
[-_\.]?
242-
(?P<post_l>post|rev|r)
243-
[-_\.]?
244-
(?P<post_n2>[0-9]+)?
245-
)
246-
)?
247-
(?P<dev> # dev release
248-
[-_\.]?
249-
(?P<dev_l>dev)
250-
[-_\.]?
251-
(?P<dev_n>[0-9]+)?
252-
)?
253-
)
254-
(?:\+(?P<local>[a-z0-9]+(?:[-_\.][a-z0-9]+)*))? # local version
255-
"""
256-
257-
version_regex = re.compile(
258-
r"^\s*" + VERSION_PATTERN + r"\s*$",
259-
re.VERBOSE | re.IGNORECASE,
260-
)
261-
262-
def release_tuple_from_version_string(version_string):
263-
return tuple(int(val) for val in version_regex.match(version_string).group('release').split('.'))
264-
265222
# }}}

firecloud/fiss.py

+18-6
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ def meth_acl(args):
476476
args.snapshot_id)
477477
fapi._check_response_code(r, 200)
478478
acls = sorted(r.json(), key=lambda k: k['user'])
479-
return map(lambda acl: '{0}\t{1}'.format(acl['user'], acl['role']), acls)
479+
return ['{0}\t{1}'.format(acl['user'], acl['role']) for acl in acls]
480480

481481
@fiss_cmd
482482
def meth_set_acl(args):
@@ -668,7 +668,7 @@ def config_acl(args):
668668
args.snapshot_id)
669669
fapi._check_response_code(r, 200)
670670
acls = sorted(r.json(), key=lambda k: k['user'])
671-
return map(lambda acl: '{0}\t{1}'.format(acl['user'], acl['role']), acls)
671+
return ['{0}\t{1}'.format(acl['user'], acl['role']) for acl in acls]
672672

673673
@fiss_cmd
674674
def config_set_acl(args):
@@ -1374,10 +1374,17 @@ def list_blob_gen(bucket_name):
13741374

13751375
# Check to see if bucket file path contain the user's submission id
13761376
# to ensure deletion of files in the submission directories only.
1377-
# Splits the bucket file: "gs://bucket_Id/submission_id/file_path", by the '/' symbol
1378-
# and stores values in a 5 length array: ['gs:', '' , 'bucket_Id', submission_id, file_path]
1379-
# to extract the submission id from the 4th element (index 3) of the array
1380-
bucket_files = set(bucket_file for bucket_file in bucket_file_sizes if bucket_file.split('/', 4)[3] in submission_ids)
1377+
# Splits the bucket file: gs://<bucket>/<submission_id>/<file_path> or
1378+
# gs://<bucket>/submissions/<submission_id>/<file_path>, by the '/' symbol
1379+
# and stores values in a 6 length array: ['gs:', '' , <bucket>, <submission_id>, <workflow_name>, <file_path>] or
1380+
# ['gs:', '' , <bucket>, 'submissions', <submission_id>, <file_path>]
1381+
# to extract the submission id from the 4th or 5th element (index 3 or 4) of the array
1382+
bucket_files = set()
1383+
for bucket_file in bucket_file_sizes:
1384+
for sub_id in bucket_file.split('/', 5)[3:5]:
1385+
if sub_id in submission_ids:
1386+
bucket_files.add(bucket_file)
1387+
break
13811388

13821389
except Exception as e:
13831390
eprint("Error retrieving files from bucket:" +
@@ -1428,12 +1435,17 @@ def can_delete(f):
14281435
return False
14291436
if filename == "rc":
14301437
return False
1438+
if filename == "memory_retry_rc":
1439+
return False
14311440
# Don't delete tool's exec.sh or script
14321441
if filename in ('exec.sh', 'script'):
14331442
return False
14341443
# keep stdout, stderr, and output
14351444
if filename in ('stderr', 'stdout', 'output'):
14361445
return False
1446+
# Don't delete utility scripts
1447+
if filename in ('gcs_localization.sh', 'gcs_delocalization.sh', 'gcs_transfer.sh'):
1448+
return False
14371449
# Only delete specified unreferenced files
14381450
if args.include:
14391451
for glob in args.include:

0 commit comments

Comments
 (0)