geoseeq 0.5.6a2__tar.gz → 0.5.6a4__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/PKG-INFO +1 -1
  2. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/cli/main.py +16 -10
  3. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/cli/shared_params/common_state.py +18 -3
  4. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/file_system_cache.py +33 -6
  5. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/id_constructors/from_blobs.py +2 -0
  6. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/id_constructors/from_ids.py +1 -0
  7. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq.egg-info/PKG-INFO +1 -1
  8. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/pyproject.toml +1 -1
  9. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/setup.py +1 -1
  10. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/LICENSE +0 -0
  11. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/README.md +0 -0
  12. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/__init__.py +0 -0
  13. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/app.py +0 -0
  14. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/blob_constructors.py +0 -0
  15. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/bulk_creators.py +0 -0
  16. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/cli/__init__.py +0 -0
  17. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/cli/constants.py +0 -0
  18. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/cli/copy.py +0 -0
  19. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/cli/detail.py +0 -0
  20. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/cli/download.py +0 -0
  21. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/cli/fastq_utils.py +0 -0
  22. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/cli/get_eula.py +0 -0
  23. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/cli/manage.py +0 -0
  24. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/cli/progress_bar.py +0 -0
  25. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/cli/run.py +0 -0
  26. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/cli/search.py +0 -0
  27. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/cli/shared_params/__init__.py +0 -0
  28. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/cli/shared_params/config.py +0 -0
  29. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/cli/shared_params/id_handlers.py +0 -0
  30. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/cli/shared_params/obj_getters.py +0 -0
  31. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/cli/shared_params/opts_and_args.py +0 -0
  32. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/cli/upload/__init__.py +0 -0
  33. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/cli/upload/upload.py +0 -0
  34. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/cli/upload/upload_advanced.py +0 -0
  35. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/cli/upload/upload_reads.py +0 -0
  36. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/cli/user.py +0 -0
  37. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/cli/utils.py +0 -0
  38. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/cli/view.py +0 -0
  39. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/constants.py +0 -0
  40. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/contrib/__init__.py +0 -0
  41. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/contrib/ncbi/__init__.py +0 -0
  42. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/contrib/ncbi/api.py +0 -0
  43. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/contrib/ncbi/bioproject.py +0 -0
  44. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/contrib/ncbi/cli.py +0 -0
  45. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/contrib/ncbi/setup_logging.py +0 -0
  46. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/id_constructors/__init__.py +0 -0
  47. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/id_constructors/from_names.py +0 -0
  48. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/id_constructors/from_uuids.py +0 -0
  49. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/id_constructors/resolvers.py +0 -0
  50. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/id_constructors/utils.py +0 -0
  51. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/knex.py +0 -0
  52. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/organization.py +0 -0
  53. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/pipeline.py +0 -0
  54. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/plotting/__init__.py +0 -0
  55. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/plotting/constants.py +0 -0
  56. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/plotting/highcharts.py +0 -0
  57. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/plotting/map/__init__.py +0 -0
  58. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/plotting/map/base_layer.py +0 -0
  59. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/plotting/map/map.py +0 -0
  60. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/plotting/map/overlay.py +0 -0
  61. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/plotting/selectable.py +0 -0
  62. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/project.py +0 -0
  63. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/remote_object.py +0 -0
  64. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/result/__init__.py +0 -0
  65. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/result/bioinfo.py +0 -0
  66. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/result/file_download.py +0 -0
  67. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/result/file_upload.py +0 -0
  68. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/result/result_file.py +0 -0
  69. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/result/result_folder.py +0 -0
  70. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/result/utils.py +0 -0
  71. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/sample.py +0 -0
  72. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/search.py +0 -0
  73. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/upload_download_manager.py +0 -0
  74. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/user.py +0 -0
  75. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/utils.py +0 -0
  76. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/vc/__init__.py +0 -0
  77. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/vc/checksum.py +0 -0
  78. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/vc/cli.py +0 -0
  79. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/vc/clone.py +0 -0
  80. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/vc/constants.py +0 -0
  81. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/vc/vc_cache.py +0 -0
  82. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/vc/vc_dir.py +0 -0
  83. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/vc/vc_sample.py +0 -0
  84. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/vc/vc_stub.py +0 -0
  85. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq/work_orders.py +0 -0
  86. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq.egg-info/SOURCES.txt +0 -0
  87. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq.egg-info/dependency_links.txt +0 -0
  88. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq.egg-info/entry_points.txt +0 -0
  89. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/geoseeq.egg-info/top_level.txt +0 -0
  90. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/setup.cfg +0 -0
  91. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/tests/__init__.py +0 -0
  92. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/tests/test_api_client.py +0 -0
  93. {geoseeq-0.5.6a2 → geoseeq-0.5.6a4}/tests/test_plotting.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: geoseeq
3
- Version: 0.5.6a2
3
+ Version: 0.5.6a4
4
4
  Summary: GeoSeeq command line tools and python API
5
5
  Author: David C. Danko
6
6
  Author-email: "David C. Danko" <dcdanko@biotia.io>
@@ -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.6a2') # remember to update setup
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
- endpoint = click.prompt(f'Enter the URL to use for GeoSeeq (Most users can use the default)', default=DEFAULT_ENDPOINT).strip(' \"\'')
90
- api_token = click.prompt(f'Enter your GeoSeeq API token', hide_input=True).strip(' \"\'')
91
- eula_accepted = click.confirm(f'Have you read and accepted the GeoSeeq End User License Agreement? Use `geoseeq eula show` to view the EULA.')
92
- if not eula_accepted:
93
- click.echo('You must accept the EULA to use the GeoSeeq API.')
94
- return
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', 'WARNING', 'INFO', 'DEBUG']),
41
- default='WARNING',
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
 
@@ -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(__name__) # Same name as calling module
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 = 3 * 60 * 60 # 3 hours in seconds
12
- CACHE_DIR = os.environ.get('GEOSEEQ_API_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'{CACHE_DIR}/.geoseeq_api_cache/v1/geoseeq_api_cache__{hash_obj(obj)}'
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)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: geoseeq
3
- Version: 0.5.6a2
3
+ Version: 0.5.6a4
4
4
  Summary: GeoSeeq command line tools and python API
5
5
  Author: David C. Danko
6
6
  Author-email: "David C. Danko" <dcdanko@biotia.io>
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "geoseeq"
7
- version = "0.5.6a2"
7
+ version = "0.5.6a4"
8
8
  authors = [
9
9
  { name="David C. Danko", email="dcdanko@biotia.io" },
10
10
  ]
@@ -5,7 +5,7 @@ import setuptools
5
5
 
6
6
  setuptools.setup(
7
7
  name='geoseeq',
8
- version='0.5.6a1', # remember to update version string in CLI as well
8
+ version='0.5.6a3', # remember to update version string in CLI as well
9
9
  author="David C. Danko",
10
10
  author_email='dcdanko@biotia.io',
11
11
  description=open('README.md').read(),
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes