Skip to content

Commit d0d82bb

Browse files
authored
Add option to prevent param log and fix issue where token encryption isn't available (#55)
* add option to skip logging of param * add fallback to plaintext token cache * import on use * change email
1 parent 7a1b595 commit d0d82bb

File tree

4 files changed

+22
-18
lines changed

4 files changed

+22
-18
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ See the following set of Jupyter notebooks that contain examples on the followin
109109

110110
### Supported environment variables
111111

112-
| Name | Description | Default |
113-
|-------------|-------------------------------|----------------|
114-
| PW_HOME | Local configuration directory | ~/.cirro |
115-
| PW_BASE_URL | Base URL of the data portal | data-portal.io |
112+
| Name | Description | Default |
113+
|-------------|-------------------------------|-----------------|
114+
| PW_HOME | Local configuration directory | ~/.cirro |
115+
| PW_BASE_URL | Base URL of the data portal | data-portal.io |
116116

117117
### Configuration
118118

cirro/api/auth/oauth_client.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
import jwt
1212
import requests
1313
from botocore.exceptions import ClientError
14-
from msal_extensions import FilePersistence, FilePersistenceWithDataProtection, \
15-
KeychainPersistence, LibsecretPersistence
14+
from msal_extensions import FilePersistence
1615
from requests.auth import AuthBase
1716

1817
from cirro.api.auth.base import AuthInfo, RequestAuthWrapper
@@ -26,16 +25,19 @@
2625
def _build_token_persistence(location, fallback_to_plaintext=False):
2726
try:
2827
if sys.platform.startswith('win'):
28+
from msal_extensions import FilePersistenceWithDataProtection
2929
return FilePersistenceWithDataProtection(location)
3030
if sys.platform.startswith('darwin'):
31+
from msal_extensions import KeychainPersistence
3132
return KeychainPersistence(location, service_name='cirro-client')
3233
if sys.platform.startswith('linux'):
34+
from msal_extensions import LibsecretPersistence
3335
return LibsecretPersistence(location)
3436
raise RuntimeError(f"Unsupported platform: {sys.platform}")
3537
except Exception:
3638
if not fallback_to_plaintext:
3739
raise
38-
logger.warning("Encryption unavailable. Opting in to plain text.")
40+
logger.debug("Encryption unavailable. Opting in to plain text.")
3941
return FilePersistence(location)
4042

4143

@@ -87,7 +89,7 @@ def __init__(self, client_id: str, region: str, auth_endpoint: str, enable_cache
8789
self._persistence = None
8890

8991
if enable_cache:
90-
self._persistence = _build_token_persistence(str(TOKEN_PATH), fallback_to_plaintext=False)
92+
self._persistence = _build_token_persistence(str(TOKEN_PATH), fallback_to_plaintext=True)
9193
self._token_info = self._load_token_info()
9294

9395
if not self._token_info:

cirro/helpers/preprocess_dataset.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,18 @@ def _write_json(self, dat, local_path: str, indent=4):
8989
with Path(local_path).open(mode="wt") as handle:
9090
return json.dump(dat, handle, indent=indent)
9191

92-
def add_param(self, name: str, value, overwrite=False):
92+
def add_param(self, name: str, value, overwrite=False, log=True):
9393
"""Add a parameter to the dataset."""
9494

9595
assert overwrite or name not in self.params, \
9696
f"Cannot add parameter {name}, already exists (and overwrite=False)"
9797

98-
self.logger.info(f"Adding parameter {name} = {value}")
98+
if log:
99+
self.logger.info(f"Adding parameter {name} = {value}")
99100
self.params[name] = value
100101

101-
self.logger.info("Saving parameters")
102+
if log:
103+
self.logger.info("Saving parameters")
102104
self._write_json(self.params, "nextflow.json")
103105

104106
def remove_param(self, name: str, force=False):
@@ -126,11 +128,11 @@ def update_compute(self, from_str, to_str, fp="nextflow-override.config"):
126128
handle.write(compute)
127129

128130
def wide_samplesheet(
129-
self,
130-
index=["sampleIndex", "sample", "lane"],
131-
columns="read",
132-
values="file",
133-
column_prefix="fastq_"
131+
self,
132+
index=["sampleIndex", "sample", "lane"],
133+
columns="read",
134+
values="file",
135+
column_prefix="fastq_"
134136
):
135137
"""Format a wide samplesheet with each read-pair on a row."""
136138

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232

3333
setup(
3434
name='cirro',
35-
version='0.6.1',
35+
version='0.6.2',
3636
author='Fred Hutch',
3737
license='MIT',
38-
author_email='hutchdatacore@fredhutch.org',
38+
author_email='cirro@fredhutch.org',
3939
description='CLI tool for interacting with the Cirro platform',
4040
packages=find_packages(include=['cirro*']),
4141
install_requires=install_requires,

0 commit comments

Comments
 (0)