geoseeq 0.5.6a2__py3-none-any.whl → 0.5.6a4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- geoseeq/cli/main.py +16 -10
- geoseeq/cli/shared_params/common_state.py +18 -3
- geoseeq/file_system_cache.py +33 -6
- geoseeq/id_constructors/from_blobs.py +2 -0
- geoseeq/id_constructors/from_ids.py +1 -0
- {geoseeq-0.5.6a2.dist-info → geoseeq-0.5.6a4.dist-info}/METADATA +1 -1
- {geoseeq-0.5.6a2.dist-info → geoseeq-0.5.6a4.dist-info}/RECORD +11 -11
- {geoseeq-0.5.6a2.dist-info → geoseeq-0.5.6a4.dist-info}/LICENSE +0 -0
- {geoseeq-0.5.6a2.dist-info → geoseeq-0.5.6a4.dist-info}/WHEEL +0 -0
- {geoseeq-0.5.6a2.dist-info → geoseeq-0.5.6a4.dist-info}/entry_points.txt +0 -0
- {geoseeq-0.5.6a2.dist-info → geoseeq-0.5.6a4.dist-info}/top_level.txt +0 -0
geoseeq/cli/main.py
CHANGED
@@ -14,7 +14,7 @@ from .search import cli_search
|
|
14
14
|
from geoseeq.vc.cli import cli_vc
|
15
15
|
from geoseeq.knex import DEFAULT_ENDPOINT
|
16
16
|
from geoseeq.utils import set_profile
|
17
|
-
from .shared_params.opts_and_args import overwrite_option
|
17
|
+
from .shared_params.opts_and_args import overwrite_option, yes_option
|
18
18
|
from .detail import cli_detail
|
19
19
|
from .run import cli_app
|
20
20
|
from .get_eula import cli_eula
|
@@ -53,7 +53,7 @@ def version():
|
|
53
53
|
Use of this tool implies acceptance of the GeoSeeq End User License Agreement.
|
54
54
|
Run `geoseeq eula show` to view the EULA.
|
55
55
|
"""
|
56
|
-
click.echo('0.5.
|
56
|
+
click.echo('0.5.6a4') # remember to update setup
|
57
57
|
|
58
58
|
|
59
59
|
@main.group('advanced')
|
@@ -74,9 +74,12 @@ def cli_experimental():
|
|
74
74
|
cli_experimental.add_command(cli_vc)
|
75
75
|
|
76
76
|
@main.command('config')
|
77
|
+
@yes_option
|
78
|
+
@click.option('--api-token', default=None, help='The API token to use.')
|
79
|
+
@click.option('--endpoint', default=None, help='The endpoint to use.')
|
77
80
|
@click.option('-p', '--profile', default=None, help='The profile name to use.')
|
78
81
|
@overwrite_option
|
79
|
-
def cli_config(profile, overwrite):
|
82
|
+
def cli_config(yes, api_token, endpoint, profile, overwrite):
|
80
83
|
"""Configure the GeoSeeq API.
|
81
84
|
|
82
85
|
---
|
@@ -84,13 +87,16 @@ def cli_config(profile, overwrite):
|
|
84
87
|
Use of this tool implies acceptance of the GeoSeeq End User License Agreement.
|
85
88
|
Run `geoseeq eula show` to view the EULA.
|
86
89
|
"""
|
87
|
-
if not profile:
|
90
|
+
if not profile and not yes:
|
88
91
|
profile = click.prompt(f'Set custom profile name? (Leave blank for default)', default="").strip(' \"\'')
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
92
|
+
if not endpoint and not yes:
|
93
|
+
endpoint = click.prompt(f'Enter the URL to use for GeoSeeq (Most users can use the default)', default=DEFAULT_ENDPOINT).strip(' \"\'')
|
94
|
+
if not api_token:
|
95
|
+
api_token = click.prompt(f'Enter your GeoSeeq API token', hide_input=True).strip(' \"\'')
|
96
|
+
if not yes:
|
97
|
+
eula_accepted = click.confirm(f'Have you read and accepted the GeoSeeq End User License Agreement? Use `geoseeq eula show` to view the EULA.')
|
98
|
+
if not eula_accepted:
|
99
|
+
click.echo('You must accept the EULA to use the GeoSeeq API.')
|
100
|
+
return
|
95
101
|
set_profile(api_token, endpoint=endpoint, profile=profile, overwrite=overwrite)
|
96
102
|
click.echo(f'Profile configured.')
|
@@ -2,7 +2,7 @@ import logging
|
|
2
2
|
|
3
3
|
import click
|
4
4
|
from geoseeq.knex import DEFAULT_ENDPOINT
|
5
|
-
|
5
|
+
import geoseeq.file_system_cache
|
6
6
|
from geoseeq import Knex
|
7
7
|
from geoseeq.utils import load_auth_profile
|
8
8
|
|
@@ -17,6 +17,7 @@ class State(object):
|
|
17
17
|
self.outfile = None
|
18
18
|
self.log_level = 20
|
19
19
|
self._knex = None
|
20
|
+
self.use_cache = True
|
20
21
|
|
21
22
|
def get_knex(self):
|
22
23
|
logger.setLevel(self.log_level)
|
@@ -37,8 +38,8 @@ def log_level_option(f):
|
|
37
38
|
state.log_level = value
|
38
39
|
return value
|
39
40
|
return click.option('-l', '--log-level',
|
40
|
-
type=click.Choice(['CRITICAL', 'ERROR', '
|
41
|
-
default='
|
41
|
+
type=click.Choice(['CRITICAL', 'ERROR', 'WARN', 'INFO', 'DEBUG']),
|
42
|
+
default='WARN',
|
42
43
|
envvar='GEOSEEQ_CLI_LOG_LEVEL',
|
43
44
|
expose_value=False,
|
44
45
|
callback=callback)(f)
|
@@ -103,11 +104,25 @@ def outfile_option(f):
|
|
103
104
|
callback=callback)(f)
|
104
105
|
|
105
106
|
|
107
|
+
def cache_option(f):
|
108
|
+
def callback(ctx, param, value):
|
109
|
+
state = ctx.ensure_object(State)
|
110
|
+
state.use_cache = value
|
111
|
+
geoseeq.file_system_cache.USE_GEOSEEQ_CACHE = value
|
112
|
+
return value
|
113
|
+
return click.option('--use-cache/--no-cache',
|
114
|
+
default=True,
|
115
|
+
expose_value=False,
|
116
|
+
help='Cache data from the geoseeq server.',
|
117
|
+
callback=callback)(f)
|
118
|
+
|
119
|
+
|
106
120
|
def common_options(f):
|
107
121
|
f = outfile_option(f)
|
108
122
|
f = log_level_option(f)
|
109
123
|
f = endpoint_option(f)
|
110
124
|
f = profile_option(f)
|
125
|
+
f = cache_option(f)
|
111
126
|
return f
|
112
127
|
|
113
128
|
|
geoseeq/file_system_cache.py
CHANGED
@@ -1,15 +1,20 @@
|
|
1
1
|
import json
|
2
2
|
import logging
|
3
3
|
import os
|
4
|
+
from os.path import join, abspath
|
4
5
|
from glob import glob
|
5
6
|
from hashlib import sha256
|
6
7
|
from random import randint
|
7
8
|
from time import time
|
8
9
|
|
9
|
-
logger = logging.getLogger(
|
10
|
+
logger = logging.getLogger("geoseeq_api") # Same name as calling module
|
10
11
|
logger.addHandler(logging.NullHandler()) # No output unless configured by calling program
|
11
|
-
CACHED_BLOB_TIME =
|
12
|
-
CACHE_DIR =
|
12
|
+
CACHED_BLOB_TIME = 5 * 60 # 5 minutes in seconds
|
13
|
+
CACHE_DIR = join(
|
14
|
+
os.environ.get('XDG_CACHE_HOME', join(os.environ["HOME"], ".cache")),
|
15
|
+
"geoseeq"
|
16
|
+
)
|
17
|
+
USE_GEOSEEQ_CACHE = None
|
13
18
|
|
14
19
|
|
15
20
|
def hash_obj(obj):
|
@@ -30,8 +35,31 @@ def time_since_file_cached(blob_filepath):
|
|
30
35
|
class FileSystemCache:
|
31
36
|
|
32
37
|
def __init__(self, timeout=CACHED_BLOB_TIME):
|
33
|
-
self.no_cache = 'false' in os.environ.get('USE_GEOSEEQ_CACHE', 'TRUE').lower()
|
34
38
|
self.timeout = timeout
|
39
|
+
self._no_cache = False
|
40
|
+
self.setup()
|
41
|
+
|
42
|
+
@property
|
43
|
+
def cache_dir_path(self):
|
44
|
+
return abspath(f'{CACHE_DIR}/geoseeq_api_cache/v1/')
|
45
|
+
|
46
|
+
def setup(self):
|
47
|
+
if self.no_cache:
|
48
|
+
return
|
49
|
+
try:
|
50
|
+
os.makedirs(self.cache_dir_path, exist_ok=True)
|
51
|
+
open(join(self.cache_dir_path, 'flag'), 'w').close()
|
52
|
+
except Exception as e:
|
53
|
+
logger.warning(f'Could not create cache directory. {e}')
|
54
|
+
self._no_cache = True
|
55
|
+
|
56
|
+
@property
|
57
|
+
def no_cache(self):
|
58
|
+
if self._no_cache or not USE_GEOSEEQ_CACHE:
|
59
|
+
logger.debug('Cache is disabled.')
|
60
|
+
return True
|
61
|
+
logger.debug('Cache is enabled.')
|
62
|
+
return not USE_GEOSEEQ_CACHE
|
35
63
|
|
36
64
|
def clear_blob(self, obj):
|
37
65
|
if self.no_cache:
|
@@ -46,8 +74,7 @@ class FileSystemCache:
|
|
46
74
|
pass
|
47
75
|
|
48
76
|
def get_cached_blob_filepath(self, obj):
|
49
|
-
path_base = f'
|
50
|
-
os.makedirs(os.path.dirname(path_base), exist_ok=True)
|
77
|
+
path_base = join(self.cache_dir_path, f'geoseeq_api_cache__{hash_obj(obj)}')
|
51
78
|
paths = sorted(glob(f'{path_base}__*.json'))
|
52
79
|
if paths:
|
53
80
|
return paths[-1], True
|
@@ -93,6 +93,7 @@ def sample_result_file_from_blob(knex, blob, already_fetched=True, modified=Fals
|
|
93
93
|
arf.load_blob(blob)
|
94
94
|
ar._already_fetched = already_fetched
|
95
95
|
ar._modified = modified
|
96
|
+
arf.cache_blob(blob)
|
96
97
|
return arf
|
97
98
|
|
98
99
|
|
@@ -110,6 +111,7 @@ def project_result_file_from_blob(knex, blob, already_fetched=True, modified=Fal
|
|
110
111
|
arf.load_blob(blob)
|
111
112
|
ar._already_fetched = already_fetched
|
112
113
|
ar._modified = modified
|
114
|
+
arf.cache_blob(blob)
|
113
115
|
return arf
|
114
116
|
|
115
117
|
|
@@ -28,6 +28,7 @@ from geoseeq.knex import with_knex
|
|
28
28
|
def _generic_from_id(knex, id, from_uuid_func, from_name_func):
|
29
29
|
"""Return the object which the id points to."""
|
30
30
|
if is_grn_or_uuid(id):
|
31
|
+
id = id.split(':')[-1] # if this is a GRN, get the UUID. Won't hurt if it's already a UUID.
|
31
32
|
return from_uuid_func(knex, id)
|
32
33
|
if is_name(id):
|
33
34
|
return from_name_func(knex, id)
|
@@ -3,7 +3,7 @@ geoseeq/app.py,sha256=Y6d1UzxFLfE3RNccATbFCVi6kH3eFmzwoUbeR2Ry09A,2387
|
|
3
3
|
geoseeq/blob_constructors.py,sha256=AkWpDQY0EdGMxF1p6eRspyHKubcUdiW4it-_Q7S2QWk,188
|
4
4
|
geoseeq/bulk_creators.py,sha256=pdn-Dv7yv5SFv-PfDuQbuOnw2W4-BfIfRJVRAhM8U6s,2115
|
5
5
|
geoseeq/constants.py,sha256=h9RURz4xs2bZyDrSGocej7ANJvRLr_H1H7JRxpNUXJM,431
|
6
|
-
geoseeq/file_system_cache.py,sha256=
|
6
|
+
geoseeq/file_system_cache.py,sha256=fZrvqWmUtTLFOpm_qG0fz1Q0GWnw_yVOAcFVPloc75c,4101
|
7
7
|
geoseeq/knex.py,sha256=6fPO8F8yxgBgBXZiliMJvYYjgf_16chfJPyWLe-kpPk,7898
|
8
8
|
geoseeq/organization.py,sha256=a9xmGDE0tQsjPJfyFkYnWagxZ8xpdeckkwvkhH6LNIk,2462
|
9
9
|
geoseeq/pipeline.py,sha256=89mhWaecsKnm6tyRkdkaVp4dmZh62_v42Ze0oXf8OTY,9873
|
@@ -22,7 +22,7 @@ geoseeq/cli/detail.py,sha256=q8Suu-j2k18knfSVFG-SWWGNsKM-n8y9RMA3LcIIi9Y,4132
|
|
22
22
|
geoseeq/cli/download.py,sha256=ldpqpnRe00utb1EL1T_5CyPbFrZbtauIvOSOHtxz9qc,17656
|
23
23
|
geoseeq/cli/fastq_utils.py,sha256=-bmeQLaiMBm57zWOF0R5OlWTU0_3sh1JBC1RYw2BOFM,3083
|
24
24
|
geoseeq/cli/get_eula.py,sha256=79mbUwyiF7O1r0g6UTxG9kJGQEqKuH805E6eLkPC6Y4,997
|
25
|
-
geoseeq/cli/main.py,sha256=
|
25
|
+
geoseeq/cli/main.py,sha256=v-LPHFlWQVPUfnerEWAKd4QzY9_NX8FsALoS0Td32RQ,3211
|
26
26
|
geoseeq/cli/manage.py,sha256=wGXAcVaXqE5JQEU8Jh6OlHr02nB396bpS_SFcOZdrEo,5929
|
27
27
|
geoseeq/cli/progress_bar.py,sha256=p1Xl01nkYxSBZCB30ue2verIIi22W93m3ZAMAxipD0g,738
|
28
28
|
geoseeq/cli/run.py,sha256=bx2AV6VIqOSTlxUda78xl0XxcZ8TXlQx02-e7iLQPwI,3838
|
@@ -31,7 +31,7 @@ geoseeq/cli/user.py,sha256=fARv_5vx-QYT765Hsjgwr6J5ddA_viCPQdv9iUoVX6w,925
|
|
31
31
|
geoseeq/cli/utils.py,sha256=f0wX5-19uDrYZ8d-aBLplqfbGOkr5BH8x3AMSAyPCes,2873
|
32
32
|
geoseeq/cli/view.py,sha256=P-o2YKBkTrPzSI-JOv7xROc63HLSUygZNZsjp9TGvSw,6783
|
33
33
|
geoseeq/cli/shared_params/__init__.py,sha256=ckNHGCBJUpJbQmcYi7lW-lsC0xKud6CCMznwcG5Vte4,325
|
34
|
-
geoseeq/cli/shared_params/common_state.py,sha256=
|
34
|
+
geoseeq/cli/shared_params/common_state.py,sha256=jiHZtL3TATMjEoqhbO7HT8KkLJr1QPsy7ZHT4qcoQ1E,4095
|
35
35
|
geoseeq/cli/shared_params/config.py,sha256=HQ0xQh_jdt3EKI5VXYqQXzo-s8Rm6YlziMyVX-kg598,1072
|
36
36
|
geoseeq/cli/shared_params/id_handlers.py,sha256=501K9sCVkI0YGDQ62vXk_DM5lMMDrdB5spIS3cw9x9U,9299
|
37
37
|
geoseeq/cli/shared_params/obj_getters.py,sha256=ZSkt6LnDkVFlNVYKgLrjzg60-6BthZMr3eeD3HNqzac,2741
|
@@ -47,8 +47,8 @@ geoseeq/contrib/ncbi/bioproject.py,sha256=_oThTd_iLDOC8cLOlJKAatSr362OBYZCEV3Yrq
|
|
47
47
|
geoseeq/contrib/ncbi/cli.py,sha256=j9zEcaZPTryK3a4xluRxigcJKDhRpRxbp3KZSx-Bfhk,2400
|
48
48
|
geoseeq/contrib/ncbi/setup_logging.py,sha256=Tp1bY1U0f-o739aHpvVYriG2qdd1lFvCYBXZeXQgt-w,175
|
49
49
|
geoseeq/id_constructors/__init__.py,sha256=w5E0PNQ9UuAxBeZbDI7KBnUoERd85gGz3nScz45bd2o,126
|
50
|
-
geoseeq/id_constructors/from_blobs.py,sha256=
|
51
|
-
geoseeq/id_constructors/from_ids.py,sha256=
|
50
|
+
geoseeq/id_constructors/from_blobs.py,sha256=aj7M7NRpKGs3u3xUvuFJwmJdFeIcJPmaI2_bhwbFfEs,5702
|
51
|
+
geoseeq/id_constructors/from_ids.py,sha256=bbAJX4LnuN70v9bny6N-jAwOudb2-ztHvlMBgRuSDz0,3151
|
52
52
|
geoseeq/id_constructors/from_names.py,sha256=RqgFjDsAwQcidMkZwX7oB00OvBAKTiilHYetTPogJ40,4174
|
53
53
|
geoseeq/id_constructors/from_uuids.py,sha256=5NrQoRBNBfiB48SIB6QFZvO0lxNrxAHbu1MDkNRSu_4,3305
|
54
54
|
geoseeq/id_constructors/resolvers.py,sha256=8hp5xJSCoZrAXtMT54Hp4okt63l909XqJU3IQx-VCgc,2676
|
@@ -80,9 +80,9 @@ geoseeq/vc/vc_stub.py,sha256=IQr8dI0zsWKVAeY_5ybDD6n49_3othcgfHS3P0O9tuY,3110
|
|
80
80
|
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
81
81
|
tests/test_api_client.py,sha256=TS5njc5pcPP_Ycy-ljcfPVT1hQRBsFVdQ0lCqBmoesU,12810
|
82
82
|
tests/test_plotting.py,sha256=TcTu-2ARr8sxZJ7wPQxmbs3-gHw7uRvsgrhhhg0qKik,784
|
83
|
-
geoseeq-0.5.
|
84
|
-
geoseeq-0.5.
|
85
|
-
geoseeq-0.5.
|
86
|
-
geoseeq-0.5.
|
87
|
-
geoseeq-0.5.
|
88
|
-
geoseeq-0.5.
|
83
|
+
geoseeq-0.5.6a4.dist-info/LICENSE,sha256=IuhIl1XCxXLPLJT_coN1CNqQU4Khlq7x4IdW7ioOJD8,1067
|
84
|
+
geoseeq-0.5.6a4.dist-info/METADATA,sha256=LhtmueF63lmmEYDNxUOUx0W-kmalxajzteiqn8nlgP4,4805
|
85
|
+
geoseeq-0.5.6a4.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
86
|
+
geoseeq-0.5.6a4.dist-info/entry_points.txt,sha256=yF-6KDM8zXib4Al0qn49TX-qM7PUkWUIcYtsgt36rjM,45
|
87
|
+
geoseeq-0.5.6a4.dist-info/top_level.txt,sha256=zZk7mmeaqAYqFJG8nq2DTgSQPbflRjJwkDIhNURPDEU,14
|
88
|
+
geoseeq-0.5.6a4.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|