geoseeq 0.5.6a8__tar.gz → 0.5.6a10__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.6a8 → geoseeq-0.5.6a10}/PKG-INFO +1 -1
  2. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/cli/download.py +8 -3
  3. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/cli/main.py +1 -1
  4. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/cli/shared_params/opts_and_args.py +1 -1
  5. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/cli/upload/upload.py +7 -3
  6. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/cli/upload/upload_reads.py +6 -3
  7. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/result/file_upload.py +15 -7
  8. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/result/result_file.py +8 -0
  9. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/upload_download_manager.py +11 -3
  10. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq.egg-info/PKG-INFO +1 -1
  11. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/pyproject.toml +1 -1
  12. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/setup.py +1 -1
  13. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/LICENSE +0 -0
  14. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/README.md +0 -0
  15. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/__init__.py +0 -0
  16. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/app.py +0 -0
  17. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/blob_constructors.py +0 -0
  18. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/bulk_creators.py +0 -0
  19. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/cli/__init__.py +0 -0
  20. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/cli/constants.py +0 -0
  21. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/cli/copy.py +0 -0
  22. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/cli/detail.py +0 -0
  23. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/cli/fastq_utils.py +0 -0
  24. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/cli/get_eula.py +0 -0
  25. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/cli/manage.py +0 -0
  26. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/cli/progress_bar.py +0 -0
  27. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/cli/run.py +0 -0
  28. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/cli/search.py +0 -0
  29. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/cli/shared_params/__init__.py +0 -0
  30. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/cli/shared_params/common_state.py +0 -0
  31. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/cli/shared_params/config.py +0 -0
  32. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/cli/shared_params/id_handlers.py +0 -0
  33. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/cli/shared_params/obj_getters.py +0 -0
  34. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/cli/upload/__init__.py +0 -0
  35. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/cli/upload/upload_advanced.py +0 -0
  36. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/cli/user.py +0 -0
  37. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/cli/utils.py +0 -0
  38. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/cli/view.py +0 -0
  39. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/constants.py +0 -0
  40. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/contrib/__init__.py +0 -0
  41. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/contrib/ncbi/__init__.py +0 -0
  42. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/contrib/ncbi/api.py +0 -0
  43. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/contrib/ncbi/bioproject.py +0 -0
  44. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/contrib/ncbi/cli.py +0 -0
  45. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/contrib/ncbi/setup_logging.py +0 -0
  46. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/file_system_cache.py +0 -0
  47. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/id_constructors/__init__.py +0 -0
  48. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/id_constructors/from_blobs.py +0 -0
  49. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/id_constructors/from_ids.py +0 -0
  50. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/id_constructors/from_names.py +0 -0
  51. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/id_constructors/from_uuids.py +0 -0
  52. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/id_constructors/resolvers.py +0 -0
  53. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/id_constructors/utils.py +0 -0
  54. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/knex.py +0 -0
  55. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/organization.py +0 -0
  56. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/pipeline.py +0 -0
  57. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/plotting/__init__.py +0 -0
  58. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/plotting/constants.py +0 -0
  59. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/plotting/highcharts.py +0 -0
  60. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/plotting/map/__init__.py +0 -0
  61. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/plotting/map/base_layer.py +0 -0
  62. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/plotting/map/map.py +0 -0
  63. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/plotting/map/overlay.py +0 -0
  64. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/plotting/selectable.py +0 -0
  65. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/project.py +0 -0
  66. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/remote_object.py +0 -0
  67. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/result/__init__.py +0 -0
  68. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/result/bioinfo.py +0 -0
  69. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/result/file_download.py +0 -0
  70. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/result/result_folder.py +0 -0
  71. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/result/utils.py +0 -0
  72. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/sample.py +0 -0
  73. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/search.py +0 -0
  74. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/user.py +0 -0
  75. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/utils.py +0 -0
  76. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/vc/__init__.py +0 -0
  77. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/vc/checksum.py +0 -0
  78. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/vc/cli.py +0 -0
  79. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/vc/clone.py +0 -0
  80. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/vc/constants.py +0 -0
  81. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/vc/vc_cache.py +0 -0
  82. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/vc/vc_dir.py +0 -0
  83. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/vc/vc_sample.py +0 -0
  84. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/vc/vc_stub.py +0 -0
  85. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq/work_orders.py +0 -0
  86. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq.egg-info/SOURCES.txt +0 -0
  87. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq.egg-info/dependency_links.txt +0 -0
  88. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq.egg-info/entry_points.txt +0 -0
  89. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/geoseeq.egg-info/top_level.txt +0 -0
  90. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/setup.cfg +0 -0
  91. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/tests/__init__.py +0 -0
  92. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/tests/test_api_client.py +0 -0
  93. {geoseeq-0.5.6a8 → geoseeq-0.5.6a10}/tests/test_plotting.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: geoseeq
3
- Version: 0.5.6a8
3
+ Version: 0.5.6a10
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>
@@ -97,13 +97,14 @@ def cli_download_metadata(state, sample_ids):
97
97
 
98
98
 
99
99
  cores_option = click.option('--cores', default=1, help='Number of downloads to run in parallel')
100
-
100
+ head_option = click.option('--head', default=None, type=int, help='Download the first N bytes of each file')
101
101
 
102
102
  @cli_download.command("files")
103
103
  @use_common_state
104
104
  @cores_option
105
105
  @click.option("--target-dir", default=".")
106
106
  @yes_option
107
+ @head_option
107
108
  @click.option("--download/--urls-only", default=True, help="Download files or just print urls")
108
109
  @click.option("--folder-type", type=click.Choice(['all', 'sample', 'project'], case_sensitive=False), default="all", help='Download files from sample folders, project folders, or both')
109
110
  @click.option("--folder-name", multiple=True, help='Filter folders for names that include this string. Case insensitive.')
@@ -120,6 +121,7 @@ def cli_download_files(
120
121
  sample_name_includes,
121
122
  target_dir,
122
123
  yes,
124
+ head,
123
125
  folder_type,
124
126
  folder_name,
125
127
  file_name,
@@ -213,6 +215,7 @@ def cli_download_files(
213
215
  ignore_errors=ignore_errors,
214
216
  log_level=state.log_level,
215
217
  progress_tracker_factory=PBarManager().get_new_bar,
218
+ head=head,
216
219
  )
217
220
  for fname, url in response["links"].items():
218
221
  download_manager.add_download(url, join(target_dir, fname))
@@ -230,11 +233,12 @@ def cli_download_files(
230
233
  @cores_option
231
234
  @click.option("-t", "--target-dir", default=".")
232
235
  @yes_option
236
+ @head_option
233
237
  @click.option("--download/--urls-only", default=True, help="Download files or just print urls")
234
238
  @ignore_errors_option
235
239
  @click.option('--hidden/--no-hidden', default=True, help='Download hidden files in folder')
236
240
  @folder_ids_arg
237
- def cli_download_folders(state, cores, target_dir, yes, download, ignore_errors, hidden, folder_ids):
241
+ def cli_download_folders(state, cores, target_dir, yes, head, download, ignore_errors, hidden, folder_ids):
238
242
  """Download entire folders from GeoSeeq.
239
243
 
240
244
  This command downloads folders directly based on their ID. This is used for "manual"
@@ -267,6 +271,7 @@ def cli_download_folders(state, cores, target_dir, yes, download, ignore_errors,
267
271
  ignore_errors=ignore_errors,
268
272
  log_level=state.log_level,
269
273
  progress_tracker_factory=PBarManager().get_new_bar,
274
+ head=head,
270
275
  )
271
276
  for result_folder in result_folders:
272
277
  download_manager.add_result_folder_download(
@@ -286,7 +291,7 @@ def cli_download_folders(state, cores, target_dir, yes, download, ignore_errors,
286
291
  @click.option("-n", "--file-name", multiple=True, help="File name to use for downloaded files. If set you must specify once per ID.")
287
292
  @yes_option
288
293
  @click.option("--download/--urls-only", default=True, help="Download files or just print urls")
289
- @click.option('--head', default=None, type=int, help='Download the first N bytes of each file')
294
+ @head_option
290
295
  @ignore_errors_option
291
296
  @click.argument("ids", nargs=-1)
292
297
  def cli_download_ids(state, cores, target_dir, file_name, yes, download, head, ignore_errors, ids):
@@ -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.6a8') # remember to update setup
56
+ click.echo('0.5.6a10') # remember to update setup
57
57
 
58
58
 
59
59
  @main.group('advanced')
@@ -2,7 +2,7 @@ import click
2
2
 
3
3
  dryrun_option = click.option('--dryrun/--wetrun', default=False, help='Print what will be created without actually creating it')
4
4
  overwrite_option = click.option('--overwrite/--no-overwrite', default=False, help='Overwrite existing samples, files, and data')
5
-
5
+ no_new_versions_option = click.option('--no-new-versions/--new-versions', default=False, help='Do not create new versions of the data')
6
6
  def module_option(options, use_default=True, default=None):
7
7
  if use_default:
8
8
  default = default or options[0]
@@ -24,6 +24,7 @@ from geoseeq.cli.shared_params import (
24
24
  handle_project_id,
25
25
  project_or_sample_id_arg,
26
26
  handle_project_or_sample_id,
27
+ no_new_versions_option,
27
28
  )
28
29
  from geoseeq.upload_download_manager import GeoSeeqUploadManager
29
30
 
@@ -41,11 +42,12 @@ hidden_option = click.option('--hidden/--no-hidden', default=False, help='Upload
41
42
  @link_option
42
43
  @recursive_option
43
44
  @hidden_option
45
+ @no_new_versions_option
44
46
  @click.option('-n', '--geoseeq-file-name', default=None, multiple=True,
45
47
  help='Specify a different name for the file on GeoSeeq than the local file name.')
46
48
  @folder_id_arg
47
49
  @click.argument('file_paths', type=click.Path(exists=True), nargs=-1)
48
- def cli_upload_file(state, cores, yes, private, link_type, recursive, hidden, geoseeq_file_name, folder_id, file_paths):
50
+ def cli_upload_file(state, cores, yes, private, link_type, recursive, hidden, no_new_versions, geoseeq_file_name, folder_id, file_paths):
49
51
  """Upload files to GeoSeeq.
50
52
 
51
53
  This command uploads files to either a sample or project on GeoSeeq. It can be used to upload
@@ -107,7 +109,7 @@ def cli_upload_file(state, cores, yes, private, link_type, recursive, hidden, ge
107
109
  link_type=link_type,
108
110
  progress_tracker_factory=PBarManager().get_new_bar,
109
111
  log_level=state.log_level,
110
- overwrite=True,
112
+ no_new_versions=no_new_versions,
111
113
  use_cache=state.use_cache,
112
114
  )
113
115
  for geoseeq_file_name, file_path in name_pairs:
@@ -131,9 +133,10 @@ def cli_upload_file(state, cores, yes, private, link_type, recursive, hidden, ge
131
133
  @private_option
132
134
  @recursive_option
133
135
  @hidden_option
136
+ @no_new_versions_option
134
137
  @project_or_sample_id_arg
135
138
  @click.argument('folder_names', type=click.Path(exists=True), nargs=-1)
136
- def cli_upload_folder(state, cores, yes, private, recursive, hidden, project_or_sample_id, folder_names):
139
+ def cli_upload_folder(state, cores, yes, private, recursive, hidden, no_new_versions, project_or_sample_id, folder_names):
137
140
  knex = state.get_knex()
138
141
  root_obj = handle_project_or_sample_id(knex, project_or_sample_id, yes=yes, private=private)
139
142
  upload_manager = GeoSeeqUploadManager(
@@ -143,6 +146,7 @@ def cli_upload_folder(state, cores, yes, private, recursive, hidden, project_or_
143
146
  log_level=logging.INFO,
144
147
  overwrite=True,
145
148
  use_cache=state.use_cache,
149
+ no_new_versions=no_new_versions,
146
150
  )
147
151
  for folder_name in folder_names:
148
152
  result_folder = root_obj.result_folder(folder_name).idem()
@@ -15,6 +15,7 @@ from geoseeq.cli.shared_params import (
15
15
  overwrite_option,
16
16
  yes_option,
17
17
  use_common_state,
18
+ no_new_versions_option
18
19
  )
19
20
  from geoseeq.upload_download_manager import GeoSeeqUploadManager
20
21
 
@@ -85,7 +86,7 @@ def _group_files(knex, filepaths, module_name, regex, yes):
85
86
  return groups
86
87
 
87
88
 
88
- def _do_upload(groups, module_name, link_type, lib, filepaths, overwrite, cores, state):
89
+ def _do_upload(groups, module_name, link_type, lib, filepaths, overwrite, no_new_versions, cores, state):
89
90
 
90
91
  with requests.Session() as session:
91
92
  upload_manager = GeoSeeqUploadManager(
@@ -96,6 +97,7 @@ def _do_upload(groups, module_name, link_type, lib, filepaths, overwrite, cores,
96
97
  overwrite=overwrite,
97
98
  progress_tracker_factory=PBarManager().get_new_bar,
98
99
  use_cache=state.use_cache,
100
+ no_new_versions=no_new_versions,
99
101
  )
100
102
  for group in groups:
101
103
  sample = lib.sample(group['sample_name']).idem()
@@ -139,10 +141,11 @@ def flatten_list_of_fastqs(filepaths):
139
141
  @click.option('--regex', default=None, help='An optional regex to use to extract sample names from the file names')
140
142
  @private_option
141
143
  @link_option
144
+ @no_new_versions_option
142
145
  @module_option(FASTQ_MODULE_NAMES)
143
146
  @project_id_arg
144
147
  @click.argument('fastq_files', type=click.Path(exists=True), nargs=-1)
145
- def cli_upload_reads_wizard(state, cores, overwrite, yes, regex, private, link_type, module_name, project_id, fastq_files):
148
+ def cli_upload_reads_wizard(state, cores, overwrite, yes, regex, private, link_type, no_new_versions, module_name, project_id, fastq_files):
146
149
  """Upload fastq read files to GeoSeeq.
147
150
 
148
151
  This command automatically groups files by their sample name, lane number
@@ -196,4 +199,4 @@ def cli_upload_reads_wizard(state, cores, overwrite, yes, regex, private, link_t
196
199
  click.echo(f'Found {len(filepaths)} files to upload.', err=True)
197
200
  regex = _get_regex(knex, filepaths, module_name, proj, regex)
198
201
  groups = _group_files(knex, filepaths, module_name, regex, yes)
199
- _do_upload(groups, module_name, link_type, proj, filepaths, overwrite, cores, state)
202
+ _do_upload(groups, module_name, link_type, proj, filepaths, overwrite, no_new_versions, cores, state)
@@ -2,7 +2,7 @@
2
2
  import time
3
3
  import json
4
4
  import os
5
- from os.path import basename, getsize, join, dirname, isfile
5
+ from os.path import basename, getsize, join, dirname, isfile, getctime
6
6
  from pathlib import Path
7
7
 
8
8
  import requests
@@ -49,7 +49,7 @@ class ResumableUploadTracker:
49
49
  self.filepath = filepath
50
50
  self.tracker_file = join(
51
51
  GEOSEEQ_CACHE_DIR, 'upload',
52
- tracker_file_prefix + f".{chunk_size}." + basename(filepath)
52
+ tracker_file_prefix + f".{chunk_size}.{getsize(filepath)}." + basename(filepath)
53
53
  )
54
54
  try:
55
55
  os.makedirs(dirname(self.tracker_file), exist_ok=True)
@@ -64,7 +64,7 @@ class ResumableUploadTracker:
64
64
  return
65
65
  if self.upload_started:
66
66
  raise GeoseeqGeneralError("Upload has already started.")
67
- blob = dict(upload_id=upload_id, urls=urls)
67
+ blob = dict(upload_id=upload_id, urls=urls, start_time=time.time())
68
68
  serialized = json.dumps(blob)
69
69
  with open(self.tracker_file, "w") as f:
70
70
  f.write(serialized + "\n")
@@ -89,6 +89,11 @@ class ResumableUploadTracker:
89
89
  with open(self.tracker_file, "r") as f:
90
90
  header_blob = json.loads(f.readline())
91
91
  self.upload_id, self.urls = header_blob["upload_id"], header_blob["urls"]
92
+ start_time = header_blob["start_time"]
93
+ if (time.time() - start_time) > (60 * 60 * 23):
94
+ logger.warning(f"Tracker file {self.tracker_file} is too old. Deleting.")
95
+ os.remove(self.tracker_file)
96
+ return
92
97
  self.upload_started = True
93
98
  for line in f:
94
99
  blob = json.loads(line)
@@ -161,14 +166,15 @@ class ResultFileUpload:
161
166
  http_response.raise_for_status()
162
167
  logger.debug(f"Upload for part {num + 1} succeeded.")
163
168
  break
164
- except requests.exceptions.HTTPError:
165
- logger.warn(
169
+ except (requests.exceptions.HTTPError, requests.exceptions.SSLError, requests.exceptions.ConnectionError) as e:
170
+ logger.debug(
166
171
  f"Upload for part {num + 1} failed. Attempt {attempts + 1} of {max_retries}."
167
172
  )
168
173
  attempts += 1
169
174
  if attempts == max_retries:
170
- raise
175
+ raise e
171
176
  time.sleep(10**attempts) # exponential backoff, (10 ** 2)s default max
177
+
172
178
  etag = http_response.headers["ETag"].replace('"', "")
173
179
  blob = {"ETag": etag, "PartNumber": num + 1}
174
180
  if resumable_upload_tracker:
@@ -260,10 +266,12 @@ class ResultFileUpload:
260
266
  logger.info(f'Finished Upload for "{filepath}"')
261
267
  return self
262
268
 
263
- def upload_file(self, filepath, multipart_thresh=FIVE_MB, overwrite=True, **kwargs):
269
+ def upload_file(self, filepath, multipart_thresh=FIVE_MB, overwrite=True, no_new_versions=False, **kwargs):
264
270
  if self.exists() and not overwrite:
265
271
  raise GeoseeqGeneralError(f"Overwrite is set to False and file {self.uuid} already exists.")
266
272
  self.idem()
273
+ if no_new_versions and self.has_downloadable_file():
274
+ raise GeoseeqGeneralError(f"File {self} already has a downloadable file. Not uploading a new version.")
267
275
  resolved_path = Path(filepath).resolve()
268
276
  file_size = getsize(resolved_path)
269
277
  return self.multipart_upload_file(filepath, file_size, **kwargs)
@@ -53,6 +53,14 @@ class ResultFile(RemoteObject, ResultFileUpload, ResultFileDownload):
53
53
  obj_type = "sample" if self.canon_url() == "sample_ar_fields" else "project"
54
54
  brn = f"brn:{self.knex.instance_code()}:{obj_type}_result_field:{self.uuid}"
55
55
 
56
+ def has_downloadable_file(self):
57
+ """Return True if this field has a downloadable file."""
58
+ try:
59
+ self.download(head=10, cache=False)
60
+ return True
61
+ except Exception as e:
62
+ return False
63
+
56
64
  def nested_url(self):
57
65
  escaped_name = urllib.parse.quote(self.name, safe="")
58
66
  return self.parent.nested_url() + f"/fields/{escaped_name}"
@@ -19,12 +19,18 @@ def _make_in_process_logger(log_level):
19
19
 
20
20
 
21
21
  def _upload_one_file(args):
22
- result_file, filepath, session, progress_tracker, link_type, overwrite, log_level, parallel_uploads, use_cache = args
22
+ (result_file, filepath, session, progress_tracker,
23
+ link_type, overwrite, log_level, parallel_uploads,
24
+ use_cache, no_new_versions) = args
23
25
  if parallel_uploads:
24
26
  _make_in_process_logger(log_level)
25
27
  if link_type == 'upload':
26
28
  # TODO: check checksums to see if the file is the same
27
- result_file.upload_file(filepath, session=session, overwrite=overwrite, progress_tracker=progress_tracker, threads=4, use_cache=use_cache)
29
+ result_file.upload_file(
30
+ filepath,
31
+ session=session, overwrite=overwrite, progress_tracker=progress_tracker,
32
+ threads=4, use_cache=use_cache, no_new_versions=no_new_versions
33
+ )
28
34
  else:
29
35
  result_file.link_file(link_type, filepath)
30
36
  return result_file
@@ -39,6 +45,7 @@ class GeoSeeqUploadManager:
39
45
  progress_tracker_factory=None,
40
46
  log_level=logging.WARNING,
41
47
  overwrite=True,
48
+ no_new_versions=False,
42
49
  use_cache=True):
43
50
  self.session = session
44
51
  self.n_parallel_uploads = n_parallel_uploads
@@ -47,6 +54,7 @@ class GeoSeeqUploadManager:
47
54
  self.link_type = link_type
48
55
  self.overwrite = overwrite
49
56
  self._result_files = []
57
+ self.no_new_versions = no_new_versions
50
58
  self.use_cache = use_cache
51
59
 
52
60
  def add_result_file(self, result_file, local_path):
@@ -72,7 +80,7 @@ class GeoSeeqUploadManager:
72
80
  result_file, local_path,
73
81
  self.session, self.progress_tracker_factory(local_path),
74
82
  self.link_type, self.overwrite, self.log_level,
75
- self.n_parallel_uploads > 1, self.use_cache
83
+ self.n_parallel_uploads > 1, self.use_cache, self.no_new_versions
76
84
  ) for result_file, local_path in self._result_files
77
85
  ]
78
86
  out = []
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: geoseeq
3
- Version: 0.5.6a8
3
+ Version: 0.5.6a10
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.6a8"
7
+ version = "0.5.6a10"
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.6a7', # remember to update version string in CLI as well
8
+ version='0.5.6a7', # DEPRECATED see pyproject.toml 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