geoseeq 0.5.6a8__py3-none-any.whl → 0.5.6a9__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
geoseeq/cli/main.py CHANGED
@@ -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.6a9') # 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)
@@ -260,10 +260,12 @@ class ResultFileUpload:
260
260
  logger.info(f'Finished Upload for "{filepath}"')
261
261
  return self
262
262
 
263
- def upload_file(self, filepath, multipart_thresh=FIVE_MB, overwrite=True, **kwargs):
263
+ def upload_file(self, filepath, multipart_thresh=FIVE_MB, overwrite=True, no_new_versions=False, **kwargs):
264
264
  if self.exists() and not overwrite:
265
265
  raise GeoseeqGeneralError(f"Overwrite is set to False and file {self.uuid} already exists.")
266
266
  self.idem()
267
+ if no_new_versions and self.has_downloadable_file():
268
+ raise GeoseeqGeneralError(f"File {self} already has a downloadable file. Not uploading a new version.")
267
269
  resolved_path = Path(filepath).resolve()
268
270
  file_size = getsize(resolved_path)
269
271
  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.6a9
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>
@@ -11,7 +11,7 @@ geoseeq/project.py,sha256=-9Y2ik0-BpT3iqh89v8VQBbdadhI58oaUP9oZK8oetc,13741
11
11
  geoseeq/remote_object.py,sha256=Es-JlAz8iLRmCpAzh1MOwUh2MqtbuQM-p8wHIBAqNlQ,7131
12
12
  geoseeq/sample.py,sha256=whgEVk6GnDJJLjn5uTOqFqRtVxZD3BgjTo7brAC5noU,7981
13
13
  geoseeq/search.py,sha256=gawad6Cx5FxJBPlYkXWb-UKAO-UC0_yhvyU9Ca1kaNI,3388
14
- geoseeq/upload_download_manager.py,sha256=Nh2cahwn7qvjfuWJSru40_k7q65NBSRQBu0EMdx-Gqc,7206
14
+ geoseeq/upload_download_manager.py,sha256=BGaEBAKu05CqftwRu3BjzL6FvcHp_w122yOS3LVVzd4,7423
15
15
  geoseeq/user.py,sha256=tol8i1UGLRrbMw5jeJDnna1ikRgrCDd50Jxz0a1lSgg,690
16
16
  geoseeq/utils.py,sha256=PDRiEQIZYTcfEV9AYvloQVvfqs5JaebcFZodAa2SUW8,3577
17
17
  geoseeq/work_orders.py,sha256=5uLVVfdKE8qh4gGaHkdBpXJGRTujuSg59knWCqEET4A,8071
@@ -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=Suhx91FX_oXb2Zd923oln3Bwk9W1gL5WTUQYk4CgjEk,3259
25
+ geoseeq/cli/main.py,sha256=7-OOKwxZ6npzer0KlnGDjjOzFLHlzQYZIgCpxICrkFg,3259
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
@@ -35,11 +35,11 @@ geoseeq/cli/shared_params/common_state.py,sha256=jiHZtL3TATMjEoqhbO7HT8KkLJr1QPs
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
38
- geoseeq/cli/shared_params/opts_and_args.py,sha256=4ZnXe0MfxHPIh1pqkpAHwoi1I0XXGGSBkAr0ltfSvEk,1948
38
+ geoseeq/cli/shared_params/opts_and_args.py,sha256=LrDkv9WtUryM4uUMXPRk04-EBcTQ7q5V6Yu-XRDUvvA,2083
39
39
  geoseeq/cli/upload/__init__.py,sha256=3C9_S9t7chmYU-2ot89NV03x-EtmsjibulErKaU9w1k,627
40
- geoseeq/cli/upload/upload.py,sha256=JsQnVyk4NLxgBtYfytORs8hgAeMGEE2o8atx1g2-Mek,9035
40
+ geoseeq/cli/upload/upload.py,sha256=vbUslOSPf8EDYFzFxukE4EFK_h8nfMYNbSczR2AJNxk,9203
41
41
  geoseeq/cli/upload/upload_advanced.py,sha256=Jq5eGe-wOdrzxGWVwaFPg0BAJcW0YSx_eHEmYjJeKuA,3434
42
- geoseeq/cli/upload/upload_reads.py,sha256=y9qsiBLF708QwQmZXqQIH2M1Ubhz7lbviupa3lbLFTw,7303
42
+ geoseeq/cli/upload/upload_reads.py,sha256=iInPDnfgEuLa8E4gfENFaZ_Uhxfv1Zfkc38iPvTsTwg,7450
43
43
  geoseeq/contrib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
44
44
  geoseeq/contrib/ncbi/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
45
45
  geoseeq/contrib/ncbi/api.py,sha256=WQeLoGA_-Zha-QeSO8_i7HpvXyD8UkV0qc5okm11KiA,1056
@@ -64,8 +64,8 @@ geoseeq/plotting/map/overlay.py,sha256=4VmxqOESTQra9tPr8b8OLEUhJSit9lNipabeSznEY
64
64
  geoseeq/result/__init__.py,sha256=IFHIyRV8ZzuKIfwfze1SXgcKwNMcSgMAknLHMkwjXIU,356
65
65
  geoseeq/result/bioinfo.py,sha256=QQtbyogrdro9avJSN0713sxLVnVeA24mFw3hWtKDKyw,1782
66
66
  geoseeq/result/file_download.py,sha256=XQA5bdQJJSZIgbFcN09OvVdLq12fnA98kPCIONAkLk0,5568
67
- geoseeq/result/file_upload.py,sha256=uAPPIouCbLjS5qgU0QsJZ7xFj4QrvCpmskVYQAI6ApA,11496
68
- geoseeq/result/result_file.py,sha256=HG1gKpgIcWImWuf6LduVLEOyW_auuQ-dWld8MNOXGLE,8433
67
+ geoseeq/result/file_upload.py,sha256=60flgzJ8KZ-EhDfKJEiBf305JmELaJdwoYRXzFIyQWk,11696
68
+ geoseeq/result/result_file.py,sha256=1Yj9fkZhds3J-tay6eNH2-EHi00MovHGV1M80_ckHD8,8677
69
69
  geoseeq/result/result_folder.py,sha256=6porOXPh7Tpxw3oX5yMRPYQzNCGYqszqmFJd3SwQmTc,11122
70
70
  geoseeq/result/utils.py,sha256=C-CxGzB3WddlnRiqFSkrY78I_m0yFgNqsTBRzGU-y8Q,2772
71
71
  geoseeq/vc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -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.6a8.dist-info/LICENSE,sha256=IuhIl1XCxXLPLJT_coN1CNqQU4Khlq7x4IdW7ioOJD8,1067
84
- geoseeq-0.5.6a8.dist-info/METADATA,sha256=yKLoJOHbteUBODSqcT9MpvbjKazjex-YIJjoHunZKuk,4805
85
- geoseeq-0.5.6a8.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
86
- geoseeq-0.5.6a8.dist-info/entry_points.txt,sha256=yF-6KDM8zXib4Al0qn49TX-qM7PUkWUIcYtsgt36rjM,45
87
- geoseeq-0.5.6a8.dist-info/top_level.txt,sha256=zZk7mmeaqAYqFJG8nq2DTgSQPbflRjJwkDIhNURPDEU,14
88
- geoseeq-0.5.6a8.dist-info/RECORD,,
83
+ geoseeq-0.5.6a9.dist-info/LICENSE,sha256=IuhIl1XCxXLPLJT_coN1CNqQU4Khlq7x4IdW7ioOJD8,1067
84
+ geoseeq-0.5.6a9.dist-info/METADATA,sha256=kej6OxkIxWfdo77ei6qzYJ1kO8R9lV7llK-Kd8FkXwA,4805
85
+ geoseeq-0.5.6a9.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
86
+ geoseeq-0.5.6a9.dist-info/entry_points.txt,sha256=yF-6KDM8zXib4Al0qn49TX-qM7PUkWUIcYtsgt36rjM,45
87
+ geoseeq-0.5.6a9.dist-info/top_level.txt,sha256=zZk7mmeaqAYqFJG8nq2DTgSQPbflRjJwkDIhNURPDEU,14
88
+ geoseeq-0.5.6a9.dist-info/RECORD,,