biothoth 0.1.0__tar.gz

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.
biothoth-0.1.0/LICENSE ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
@@ -0,0 +1,64 @@
1
+ Metadata-Version: 2.4
2
+ Name: biothoth
3
+ Version: 0.1.0
4
+ Summary: The CLI for Biothoth.
5
+ Author-email: Biothoth <hello@biothoth.com>
6
+ License: LGPL-3.0-or-later
7
+ Project-URL: Homepage, https://www.biothoth.com
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
11
+ Requires-Python: >=3.8
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: click
15
+ Requires-Dist: keyring
16
+ Requires-Dist: requests
17
+ Requires-Dist: tqdm
18
+ Dynamic: license-file
19
+
20
+ # Biothoth CLI
21
+
22
+ A powerful command-line interface for interacting with Biothoth AI services.
23
+
24
+ ## Installation
25
+
26
+ ```bash
27
+ pip install biothoth
28
+ ```
29
+
30
+ ##Getting Started
31
+
32
+ Before using Biothoth CLI, you'll need to authenticate with your credentials:
33
+
34
+ ```bash
35
+ biothoth auth
36
+ ```
37
+ You'll be prompted to enter your email and secret token. These credentials will be securely stored for future use.
38
+
39
+ ## Uploading Files
40
+
41
+ To upload a file to Biothoth, use the following command:
42
+
43
+ ```bash
44
+ biothoth upload [path]
45
+ ```
46
+
47
+ The "path" can point to a local file or directory.
48
+
49
+ To upload to a specific directory, use the following command:
50
+
51
+ ```bash
52
+ biothoth upload [path] --destination folder/
53
+ ```
54
+
55
+
56
+ ## Local Development
57
+
58
+ To run the CLI locally, you can use the following command:
59
+
60
+ ```bash
61
+ python uninstall biothoth
62
+ pip install -e .
63
+ ```
64
+
@@ -0,0 +1,45 @@
1
+ # Biothoth CLI
2
+
3
+ A powerful command-line interface for interacting with Biothoth AI services.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install biothoth
9
+ ```
10
+
11
+ ##Getting Started
12
+
13
+ Before using Biothoth CLI, you'll need to authenticate with your credentials:
14
+
15
+ ```bash
16
+ biothoth auth
17
+ ```
18
+ You'll be prompted to enter your email and secret token. These credentials will be securely stored for future use.
19
+
20
+ ## Uploading Files
21
+
22
+ To upload a file to Biothoth, use the following command:
23
+
24
+ ```bash
25
+ biothoth upload [path]
26
+ ```
27
+
28
+ The "path" can point to a local file or directory.
29
+
30
+ To upload to a specific directory, use the following command:
31
+
32
+ ```bash
33
+ biothoth upload [path] --destination folder/
34
+ ```
35
+
36
+
37
+ ## Local Development
38
+
39
+ To run the CLI locally, you can use the following command:
40
+
41
+ ```bash
42
+ python uninstall biothoth
43
+ pip install -e .
44
+ ```
45
+
File without changes
@@ -0,0 +1,434 @@
1
+ import warnings
2
+ warnings.filterwarnings("ignore")
3
+
4
+ import os
5
+ import json
6
+ from pathlib import Path
7
+ import click
8
+ import keyring
9
+ import requests
10
+ from typing import List
11
+ import mimetypes
12
+ from tqdm import tqdm
13
+ import math
14
+
15
+ CONFIG_DIR = Path.home() / '.biothoth'
16
+ CONFIG_FILE = CONFIG_DIR / 'config.json'
17
+ SERVICE_NAME = 'biothoth'
18
+
19
+ URL_BASE = "https://www.biothoth.com/api"
20
+ # URL_BASE = "http://localhost:3000/api"
21
+
22
+ # File size constants
23
+ MULTIPART_THRESHOLD = 3 * 1024 * 1024 * 1024 # 3GB
24
+ CHUNK_SIZE = 50 * 1024 * 1024 # 50MB
25
+
26
+ def load_credentials():
27
+ """Load credentials from config file if they exist"""
28
+ if CONFIG_FILE.exists():
29
+ with open(CONFIG_FILE, 'r') as f:
30
+ return json.load(f)
31
+ return None
32
+
33
+ def save_credentials(email, token):
34
+ """Save credentials to config file"""
35
+ CONFIG_DIR.mkdir(exist_ok=True)
36
+ credentials = {
37
+ 'email': email,
38
+ 'token': token
39
+ }
40
+ with open(CONFIG_FILE, 'w') as f:
41
+ json.dump(credentials, f)
42
+
43
+ def get_credentials():
44
+ """Get credentials from system keyring"""
45
+ email = keyring.get_password(SERVICE_NAME, 'email')
46
+ token = keyring.get_password(SERVICE_NAME, 'token')
47
+ return email, token
48
+
49
+ def save_credentials_system(email, token):
50
+ """Save credentials to system keyring"""
51
+ keyring.set_password(SERVICE_NAME, 'email', email)
52
+ keyring.set_password(SERVICE_NAME, 'token', token)
53
+
54
+ @click.group()
55
+ def cli():
56
+ """Biothoth CLI tool"""
57
+ pass
58
+
59
+ @cli.command()
60
+ def auth():
61
+ """Authenticate with Biothoth"""
62
+ # Check if credentials already exist
63
+ existing_email, existing_token = get_credentials()
64
+ if existing_email and existing_token:
65
+ if not click.confirm('Credentials already exist. Do you want to overwrite them?'):
66
+ click.echo('Authentication cancelled.')
67
+ return
68
+
69
+ email = click.prompt('Please enter your email')
70
+ token = click.prompt('Please enter your secret token', hide_input=True)
71
+
72
+ # Verify credentials before saving
73
+ click.echo('Verifying credentials...')
74
+ try:
75
+ # Test credentials by requesting a presigned URL for a test file
76
+ bucket_name = "magicode-user-data-store"
77
+ verify_response = requests.post(
78
+ f'{URL_BASE}/s3-cli',
79
+ params={'bucket': bucket_name},
80
+ json={
81
+ 'email': email,
82
+ 'secretKey': token,
83
+ 'fileName': 'test-verification.txt',
84
+ }
85
+ )
86
+
87
+ if verify_response.status_code != 200:
88
+ click.echo(f'Invalid credentials. Authentication failed.', err=True)
89
+ return
90
+
91
+ click.echo('Credentials verified successfully.')
92
+ save_credentials(email, token)
93
+ save_credentials_system(email, token)
94
+ click.echo('Credentials saved.')
95
+ except Exception as e:
96
+ click.echo(f'Error verifying credentials: {str(e)}', err=True)
97
+
98
+ @cli.command()
99
+ def logout():
100
+ """Clear stored credentials"""
101
+ try:
102
+ keyring.delete_password(SERVICE_NAME, 'email')
103
+ keyring.delete_password(SERVICE_NAME, 'token')
104
+ click.echo('Logged out successfully.')
105
+ except keyring.errors.PasswordDeleteError:
106
+ click.echo('No credentials found.')
107
+
108
+ @cli.command()
109
+ @click.argument('source')
110
+ @click.option('--destination', default='', help='Destination path to prepend to uploaded files (should end with /)')
111
+ def upload(source: str, destination: str):
112
+ """Upload a file or folder to Biothoth
113
+
114
+ SOURCE: Path to the file or folder to upload
115
+ """
116
+ # Get credentials
117
+ email, token = get_credentials()
118
+ if not email or not token:
119
+ click.echo('Please authenticate first using the auth command.', err=True)
120
+ return
121
+
122
+ # Validate destination format if provided
123
+ if destination and not destination.endswith('/'):
124
+ click.echo('Destination path must end with a forward slash (/)', err=True)
125
+ return
126
+
127
+ path = Path(source)
128
+ if not path.exists():
129
+ click.echo(f'Path does not exist: {path}', err=True)
130
+ return
131
+
132
+ files_to_upload: List[Path] = []
133
+ folders_to_upload: List[Path] = []
134
+
135
+ # Collect all files and folders
136
+ if path.is_file():
137
+ files_to_upload.append(path)
138
+ else:
139
+ # Collect all subdirectories and files (skip root folder itself)
140
+ for item in path.rglob('*'):
141
+ if item.is_file():
142
+ files_to_upload.append(item)
143
+ elif item.is_dir():
144
+ folders_to_upload.append(item)
145
+
146
+ total_items = len(files_to_upload) + len(folders_to_upload)
147
+ error = False
148
+ errored_items = []
149
+ current_index = 0
150
+
151
+ # Upload empty content for folders first
152
+ for folder_path in folders_to_upload:
153
+ current_index += 1
154
+ try:
155
+ click.echo(f'Creating folder {current_index}/{total_items}: {folder_path}/')
156
+
157
+ # Get relative path for the folder and prepend destination if provided
158
+ relative_path = folder_path.relative_to(path.parent)
159
+ folder_key = str(relative_path) + '/' if not str(relative_path).endswith('/') else str(relative_path)
160
+ if destination:
161
+ folder_key = destination + folder_key
162
+
163
+ # bucket name depends on the destination
164
+ bucket_name = "magicode-user-data-store"
165
+
166
+ # Get presigned URL
167
+ presigned_response = requests.post(
168
+ f'{URL_BASE}/s3-cli',
169
+ params={'bucket': bucket_name},
170
+ json={
171
+ 'email': email,
172
+ 'secretKey': token,
173
+ 'fileName': folder_key,
174
+ }
175
+ )
176
+
177
+ if presigned_response.status_code != 200:
178
+ error = True
179
+ errored_items.append(folder_path)
180
+ continue
181
+
182
+ presigned_data = presigned_response.json()
183
+ presigned_url = presigned_data['presignedUrl']
184
+
185
+ # Upload empty content for folder
186
+ upload_response = requests.put(
187
+ presigned_url,
188
+ data=b'',
189
+ headers={
190
+ 'Content-Type': 'application/x-directory',
191
+ 'Content-Length': '0'
192
+ }
193
+ )
194
+
195
+ if upload_response.status_code not in (200, 204):
196
+ error = True
197
+ errored_items.append(folder_path)
198
+ continue
199
+
200
+ except Exception as e:
201
+ error = True
202
+ errored_items.append(folder_path)
203
+ continue
204
+
205
+ # Upload files
206
+ for file_path in files_to_upload:
207
+ current_index += 1
208
+ try:
209
+ click.echo(f'Uploading file {current_index}/{total_items}: {file_path}')
210
+
211
+ # Get relative path for the file and prepend destination if provided
212
+ relative_path = file_path.relative_to(path.parent)
213
+ file_key = str(relative_path)
214
+ if destination:
215
+ file_key = destination + file_key
216
+
217
+ # bucket name depends on the destination
218
+ bucket_name = "magicode-user-data-store"
219
+
220
+ # Get file size
221
+ file_size = os.path.getsize(file_path)
222
+ content_type = mimetypes.guess_type(file_path)[0] or 'application/octet-stream'
223
+
224
+ # Check if file is large enough for multipart upload
225
+ if file_size > MULTIPART_THRESHOLD:
226
+ # Use multipart upload for large files
227
+ if not upload_large_file(file_path, file_key, bucket_name, email, token, content_type, file_size):
228
+ error = True
229
+ errored_items.append(file_path)
230
+ else:
231
+ # Use regular upload for smaller files
232
+ # Get presigned URL
233
+ presigned_response = requests.post(
234
+ f'{URL_BASE}/s3-cli',
235
+ params={'bucket': bucket_name},
236
+ json={
237
+ 'email': email,
238
+ 'secretKey': token,
239
+ 'fileName': file_key,
240
+ }
241
+ )
242
+
243
+ if presigned_response.status_code != 200:
244
+ error = True
245
+ errored_items.append(file_path)
246
+ continue
247
+
248
+ presigned_data = presigned_response.json()
249
+ presigned_url = presigned_data['presignedUrl']
250
+
251
+ # Upload file using presigned URL with progress bar
252
+ with open(file_path, 'rb') as f:
253
+ with tqdm(total=file_size, unit='B', unit_scale=True, unit_divisor=1024) as pbar:
254
+ file_data = f.read()
255
+
256
+ upload_response = requests.put(
257
+ presigned_url,
258
+ data=file_data,
259
+ headers={
260
+ 'Content-Type': content_type,
261
+ 'Content-Length': str(file_size)
262
+ }
263
+ )
264
+ pbar.update(file_size) # Ensure bar reaches 100%
265
+
266
+ if upload_response.status_code not in (200, 204):
267
+ error = True
268
+ errored_items.append(file_path)
269
+ continue
270
+
271
+ except Exception as e:
272
+ click.echo(f'Error uploading {file_path}: {str(e)}', err=True)
273
+ error = True
274
+ errored_items.append(file_path)
275
+ continue
276
+
277
+ if error:
278
+ click.echo(f'Upload has completed with errors.')
279
+ click.echo(f'The following items were not uploaded:')
280
+ for item in errored_items:
281
+ click.echo(f' - {item}')
282
+ click.echo(f'Please check your credentials and try again.')
283
+ else:
284
+ click.echo('Upload completed successfully.')
285
+
286
+ def upload_large_file(file_path, file_key, bucket_name, email, token, content_type, file_size):
287
+ """Upload a large file using multipart upload"""
288
+ click.echo(f'File size is {file_size/1024/1024/1024:.2f} GB. Using multipart upload...')
289
+
290
+ # Calculate number of parts
291
+ num_parts = math.ceil(file_size / CHUNK_SIZE)
292
+
293
+ try:
294
+ # 1. Initiate multipart upload
295
+ initiate_response = requests.post(
296
+ f'{URL_BASE}/s3-cli-multipart',
297
+ params={'bucket': bucket_name, 'action': 'initiate'},
298
+ json={
299
+ 'email': email,
300
+ 'secretKey': token,
301
+ 'fileName': file_key,
302
+ 'contentType': content_type
303
+ }
304
+ )
305
+
306
+ if initiate_response.status_code != 200:
307
+ click.echo(f'Failed to initiate multipart upload: {initiate_response.text}', err=True)
308
+ return False
309
+
310
+ initiate_data = initiate_response.json()
311
+ upload_id = initiate_data['uploadId']
312
+ s3_key = initiate_data['key']
313
+
314
+ click.echo(f'Initiated multipart upload with ID: {upload_id}')
315
+
316
+ # 2. Upload parts
317
+ part_info = []
318
+
319
+ with tqdm(total=num_parts, desc="Uploading parts", unit="part") as pbar:
320
+ for part_number in range(1, num_parts + 1):
321
+ # Get presigned URLs for this part
322
+ urls_response = requests.post(
323
+ f'{URL_BASE}/s3-cli-multipart',
324
+ params={'bucket': bucket_name, 'action': 'getUrls'},
325
+ json={
326
+ 'email': email,
327
+ 'secretKey': token,
328
+ 'key': s3_key,
329
+ 'uploadId': upload_id,
330
+ 'partNumbers': [part_number]
331
+ }
332
+ )
333
+
334
+ if urls_response.status_code != 200:
335
+ click.echo(f'Failed to get presigned URL for part {part_number}: {urls_response.text}', err=True)
336
+ # Abort the multipart upload
337
+ requests.post(
338
+ f'{URL_BASE}/s3-cli-multipart',
339
+ params={'bucket': bucket_name, 'action': 'abort'},
340
+ json={
341
+ 'email': email,
342
+ 'secretKey': token,
343
+ 'key': s3_key,
344
+ 'uploadId': upload_id
345
+ }
346
+ )
347
+ return False
348
+
349
+ urls_data = urls_response.json()
350
+ part_url = urls_data['presignedUrls'][0]['presignedUrl']
351
+
352
+ # Calculate byte range for this part
353
+ start_byte = (part_number - 1) * CHUNK_SIZE
354
+ end_byte = min(start_byte + CHUNK_SIZE, file_size)
355
+ part_size = end_byte - start_byte
356
+
357
+ # Read the chunk from the file
358
+ with open(file_path, 'rb') as f:
359
+ f.seek(start_byte)
360
+ part_data = f.read(part_size)
361
+
362
+ # Upload the part
363
+ part_response = requests.put(
364
+ part_url,
365
+ data=part_data,
366
+ headers={'Content-Length': str(part_size)}
367
+ )
368
+
369
+ if part_response.status_code not in (200, 204):
370
+ click.echo(f'Failed to upload part {part_number}: {part_response.text}', err=True)
371
+ # Abort the multipart upload
372
+ requests.post(
373
+ f'{URL_BASE}/s3-cli-multipart',
374
+ params={'bucket': bucket_name, 'action': 'abort'},
375
+ json={
376
+ 'email': email,
377
+ 'secretKey': token,
378
+ 'key': s3_key,
379
+ 'uploadId': upload_id
380
+ }
381
+ )
382
+ return False
383
+
384
+ # Get the ETag from the response headers
385
+ etag = part_response.headers.get('ETag')
386
+ part_info.append({
387
+ 'PartNumber': part_number,
388
+ 'ETag': etag
389
+ })
390
+
391
+ pbar.update(1)
392
+
393
+ # 3. Complete multipart upload
394
+ click.echo('Finalizing multipart upload...')
395
+ complete_response = requests.post(
396
+ f'{URL_BASE}/s3-cli-multipart',
397
+ params={'bucket': bucket_name, 'action': 'complete'},
398
+ json={
399
+ 'email': email,
400
+ 'secretKey': token,
401
+ 'key': s3_key,
402
+ 'uploadId': upload_id,
403
+ 'parts': part_info
404
+ }
405
+ )
406
+
407
+ if complete_response.status_code != 200:
408
+ click.echo(f'Failed to complete multipart upload: {complete_response.text}', err=True)
409
+ return False
410
+
411
+ click.echo('Multipart upload completed successfully.')
412
+ return True
413
+
414
+ except Exception as e:
415
+ click.echo(f'Error during multipart upload: {str(e)}', err=True)
416
+ # Try to abort the upload if possible
417
+ try:
418
+ if 'upload_id' in locals() and 's3_key' in locals():
419
+ requests.post(
420
+ f'{URL_BASE}/s3-cli-multipart',
421
+ params={'bucket': bucket_name, 'action': 'abort'},
422
+ json={
423
+ 'email': email,
424
+ 'secretKey': token,
425
+ 'key': s3_key,
426
+ 'uploadId': upload_id
427
+ }
428
+ )
429
+ except:
430
+ pass
431
+ return False
432
+
433
+ if __name__ == '__main__':
434
+ cli()
@@ -0,0 +1,64 @@
1
+ Metadata-Version: 2.4
2
+ Name: biothoth
3
+ Version: 0.1.0
4
+ Summary: The CLI for Biothoth.
5
+ Author-email: Biothoth <hello@biothoth.com>
6
+ License: LGPL-3.0-or-later
7
+ Project-URL: Homepage, https://www.biothoth.com
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
11
+ Requires-Python: >=3.8
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: click
15
+ Requires-Dist: keyring
16
+ Requires-Dist: requests
17
+ Requires-Dist: tqdm
18
+ Dynamic: license-file
19
+
20
+ # Biothoth CLI
21
+
22
+ A powerful command-line interface for interacting with Biothoth AI services.
23
+
24
+ ## Installation
25
+
26
+ ```bash
27
+ pip install biothoth
28
+ ```
29
+
30
+ ##Getting Started
31
+
32
+ Before using Biothoth CLI, you'll need to authenticate with your credentials:
33
+
34
+ ```bash
35
+ biothoth auth
36
+ ```
37
+ You'll be prompted to enter your email and secret token. These credentials will be securely stored for future use.
38
+
39
+ ## Uploading Files
40
+
41
+ To upload a file to Biothoth, use the following command:
42
+
43
+ ```bash
44
+ biothoth upload [path]
45
+ ```
46
+
47
+ The "path" can point to a local file or directory.
48
+
49
+ To upload to a specific directory, use the following command:
50
+
51
+ ```bash
52
+ biothoth upload [path] --destination folder/
53
+ ```
54
+
55
+
56
+ ## Local Development
57
+
58
+ To run the CLI locally, you can use the following command:
59
+
60
+ ```bash
61
+ python uninstall biothoth
62
+ pip install -e .
63
+ ```
64
+
@@ -0,0 +1,11 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ biothoth/__init__.py
5
+ biothoth/main.py
6
+ biothoth.egg-info/PKG-INFO
7
+ biothoth.egg-info/SOURCES.txt
8
+ biothoth.egg-info/dependency_links.txt
9
+ biothoth.egg-info/entry_points.txt
10
+ biothoth.egg-info/requires.txt
11
+ biothoth.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ biothoth = biothoth.main:cli
@@ -0,0 +1,4 @@
1
+ click
2
+ keyring
3
+ requests
4
+ tqdm
@@ -0,0 +1 @@
1
+ biothoth
@@ -0,0 +1,31 @@
1
+ [build-system]
2
+ requires = ["setuptools>=42", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "biothoth"
7
+ version = "0.1.0"
8
+ authors = [
9
+ { name="Biothoth", email="hello@biothoth.com" },
10
+ ]
11
+ description = "The CLI for Biothoth."
12
+ readme = "README.md"
13
+ requires-python = ">=3.8"
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "Operating System :: OS Independent",
17
+ "License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
18
+ ]
19
+ license = {text = "LGPL-3.0-or-later"}
20
+ dependencies = [
21
+ "click",
22
+ "keyring",
23
+ "requests",
24
+ "tqdm",
25
+ ]
26
+
27
+ [project.urls]
28
+ Homepage = "https://www.biothoth.com"
29
+
30
+ [project.scripts]
31
+ biothoth = "biothoth.main:cli"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+