byod-cli 1.0.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.
@@ -0,0 +1,44 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ dist/
9
+ *.egg-info/
10
+ *.egg
11
+ .venv/
12
+ venv/
13
+
14
+ # Environment
15
+ .env
16
+ .env.local
17
+
18
+ # IDE
19
+ .idea/
20
+ .vscode/
21
+ *.swp
22
+ *.swo
23
+ *~
24
+
25
+ # OS
26
+ .DS_Store
27
+ Thumbs.db
28
+
29
+ # Testing / Coverage
30
+ .coverage
31
+ htmlcov/
32
+ .pytest_cache/
33
+
34
+ # Linting
35
+ .ruff_cache
36
+ .mypy_cache/
37
+
38
+ # Build artifacts
39
+ *.whl
40
+ *.tar.gz
41
+
42
+ output/
43
+ results/
44
+ samples/
byod_cli-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Lablytics Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,567 @@
1
+ Metadata-Version: 2.4
2
+ Name: byod-cli
3
+ Version: 1.0.0
4
+ Summary: Command-line interface for Lablytics BYOD - Secure biotech data processing with zero-knowledge encryption
5
+ Project-URL: Homepage, https://lablytics.io
6
+ Project-URL: Documentation, https://docs.lablytics.io/cli
7
+ Project-URL: Repository, https://github.com/lablytics/byod-cli
8
+ Project-URL: Issues, https://github.com/lablytics/byod-cli/issues
9
+ Project-URL: Changelog, https://github.com/lablytics/byod-cli/releases
10
+ Author-email: Lablytics <support@lablytics.io>
11
+ License-Expression: MIT
12
+ License-File: LICENSE
13
+ Keywords: aws,biotech,encryption,genomics,kms,nextflow,nitro-enclave,proteomics,secure-computing,zero-knowledge
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Environment :: Console
16
+ Classifier: Intended Audience :: Healthcare Industry
17
+ Classifier: Intended Audience :: Science/Research
18
+ Classifier: License :: OSI Approved :: MIT License
19
+ Classifier: Operating System :: OS Independent
20
+ Classifier: Programming Language :: Python :: 3
21
+ Classifier: Programming Language :: Python :: 3.9
22
+ Classifier: Programming Language :: Python :: 3.10
23
+ Classifier: Programming Language :: Python :: 3.11
24
+ Classifier: Programming Language :: Python :: 3.12
25
+ Classifier: Programming Language :: Python :: 3.13
26
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
27
+ Classifier: Topic :: Security :: Cryptography
28
+ Classifier: Typing :: Typed
29
+ Requires-Python: >=3.9
30
+ Requires-Dist: boto3>=1.28.0
31
+ Requires-Dist: click>=8.1.0
32
+ Requires-Dist: cryptography>=41.0.0
33
+ Requires-Dist: pyyaml>=6.0
34
+ Requires-Dist: requests>=2.31.0
35
+ Requires-Dist: rich>=13.0.0
36
+ Requires-Dist: tqdm>=4.66.0
37
+ Provides-Extra: dev
38
+ Requires-Dist: moto>=5.0.0; extra == 'dev'
39
+ Requires-Dist: mypy>=1.5.0; extra == 'dev'
40
+ Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
41
+ Requires-Dist: pytest-mock>=3.11.0; extra == 'dev'
42
+ Requires-Dist: pytest>=7.4.0; extra == 'dev'
43
+ Requires-Dist: responses>=0.24.0; extra == 'dev'
44
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
45
+ Description-Content-Type: text/markdown
46
+
47
+ # BYOD CLI
48
+
49
+ Command-line interface for the Lablytics BYOD (Bring Your Own Data) platform.
50
+
51
+ Process sensitive biotech data with zero-knowledge encryption. Your data is encrypted client-side, processed inside a cryptographically attested AWS Nitro Enclave, and returned encrypted. **No one—including Lablytics—can access your plaintext data.**
52
+
53
+ ## Table of Contents
54
+
55
+ - [Installation](#installation)
56
+ - [Quick Start](#quick-start)
57
+ - [Complete Setup Guide](#complete-setup-guide)
58
+ - [Commands Reference](#commands-reference)
59
+ - [Security Model](#security-model)
60
+ - [Examples](#examples)
61
+ - [Troubleshooting](#troubleshooting)
62
+
63
+ ---
64
+
65
+ ## Installation
66
+
67
+ ### From PyPI (Recommended)
68
+
69
+ ```bash
70
+ pip install byod-cli
71
+ ```
72
+
73
+ ### From Source
74
+
75
+ ```bash
76
+ cd byod-cli
77
+ pip install -e .
78
+
79
+ # With development dependencies
80
+ pip install -e ".[dev]"
81
+ ```
82
+
83
+ ### Prerequisites
84
+
85
+ - Python 3.10+
86
+ - AWS credentials configured (`~/.aws/credentials` or environment variables)
87
+ - A Lablytics account with API key
88
+
89
+ ---
90
+
91
+ ## Quick Start
92
+
93
+ ```bash
94
+ # 1. Authenticate with your API key
95
+ byod auth login
96
+
97
+ # 2. Set up your AWS resources (one-time)
98
+ byod setup
99
+
100
+ # 3. Submit data for processing
101
+ byod submit genomic-qc ./sample.fastq.gz
102
+
103
+ # 4. Check job status
104
+ byod status <job-id>
105
+
106
+ # 5. Download and decrypt results
107
+ byod retrieve <job-id> -o ./results/
108
+ byod decrypt ./results/ -o ./decrypted/
109
+ ```
110
+
111
+ ---
112
+
113
+ ## Complete Setup Guide
114
+
115
+ ### Step 1: Create a Lablytics Account
116
+
117
+ 1. Go to https://byod.cultivatedcode.co and sign up
118
+ 2. Verify your email address
119
+ 3. Log in to the dashboard
120
+
121
+ ### Step 2: Generate an API Key
122
+
123
+ 1. In the dashboard, go to **Settings** → **API Keys**
124
+ 2. Click **Create New Key**
125
+ 3. Copy the key (it's shown only once!)
126
+ 4. Store it securely
127
+
128
+ ### Step 3: Authenticate the CLI
129
+
130
+ ```bash
131
+ byod auth login
132
+ # Enter your API key when prompted: sk_live_xxxxx
133
+ ```
134
+
135
+ You should see:
136
+ ```
137
+ ✓ Authentication successful!
138
+
139
+ Organization: Acme Biotech
140
+ Tenant ID: tenant_abc123xyz
141
+ Region: us-east-1
142
+
143
+ Ready to submit jobs!
144
+ ```
145
+
146
+ ### Step 4: Set Up AWS Resources
147
+
148
+ This creates a KMS key and IAM role in YOUR AWS account:
149
+
150
+ ```bash
151
+ byod setup
152
+ ```
153
+
154
+ **What this creates:**
155
+
156
+ | Resource | Purpose |
157
+ |----------|---------|
158
+ | KMS Key | Encrypts your data. Only the Nitro Enclave can decrypt. |
159
+ | IAM Role | Allows the enclave to use your KMS key with attestation |
160
+ | Key Alias | `alias/byod-{tenant_id}` for easy identification |
161
+
162
+ **Output:**
163
+ ```
164
+ Setting up AWS resources for BYOD...
165
+
166
+ Fetching enclave configuration...
167
+ Tenant ID: tenant_abc123xyz
168
+ Enclave PCR0: a1b2c3d4e5f6...
169
+
170
+ Checking AWS credentials...
171
+ AWS Account: 123456789012
172
+ Region: us-east-1
173
+
174
+ Creating cross-account IAM role...
175
+ Role: arn:aws:iam::123456789012:role/BYODEnclaveRole-tenant_abc123
176
+
177
+ Creating KMS key with attestation policy...
178
+ KMS Key: arn:aws:kms:us-east-1:123456789012:key/xxx-xxx
179
+ Alias: alias/byod-tenant_abc123
180
+
181
+ Attaching KMS permissions to role...
182
+ Attached BYODKMSAccess policy
183
+
184
+ Registering with Lablytics...
185
+ Registration complete
186
+
187
+ ============================================================
188
+ ✓ Setup complete!
189
+ ============================================================
190
+
191
+ Resources created:
192
+ KMS Key: arn:aws:kms:us-east-1:123456789012:key/xxx-xxx
193
+ IAM Role: arn:aws:iam::123456789012:role/BYODEnclaveRole-tenant_abc123
194
+
195
+ Security guarantees:
196
+ ✓ Only YOU can manage/delete the KMS key
197
+ ✓ Only the Nitro Enclave (with PCR0 verification) can decrypt
198
+ ✓ Lablytics operators cannot access your data
199
+
200
+ Ready to submit jobs!
201
+ ```
202
+
203
+ ### Step 5: Submit Your First Job
204
+
205
+ ```bash
206
+ # Submit a FASTQ file for quality control
207
+ byod submit genomic-qc ./sample.fastq.gz
208
+
209
+ # Or submit with a description and tags
210
+ byod submit genomic-qc ./sample.fastq.gz \
211
+ --description "Sample batch 2024-01" \
212
+ --tags experiment=exp001 \
213
+ --tags batch=batch_a
214
+ ```
215
+
216
+ ### Step 6: Monitor and Retrieve Results
217
+
218
+ ```bash
219
+ # Check status
220
+ byod status genomic-qc-20260208-abc123
221
+
222
+ # List all your jobs
223
+ byod list
224
+
225
+ # Download encrypted results when complete
226
+ byod retrieve genomic-qc-20260208-abc123 -o ./results/
227
+
228
+ # Decrypt locally (extracts to directory)
229
+ byod decrypt ./results/ -o ./qc_report/
230
+ ```
231
+
232
+ ---
233
+
234
+ ## Commands Reference
235
+
236
+ ### Authentication
237
+
238
+ | Command | Description |
239
+ |---------|-------------|
240
+ | `byod auth login` | Authenticate with API key |
241
+ | `byod auth logout` | Clear stored credentials |
242
+ | `byod auth status` | Check authentication status |
243
+
244
+ ### Setup
245
+
246
+ | Command | Description |
247
+ |---------|-------------|
248
+ | `byod setup` | Create KMS key and IAM role in your AWS account |
249
+ | `byod setup --region us-west-2` | Create resources in a specific region |
250
+
251
+ ### Jobs
252
+
253
+ | Command | Description |
254
+ |---------|-------------|
255
+ | `byod submit <plugin> <path>` | Submit data for processing |
256
+ | `byod status <job-id>` | Check job status |
257
+ | `byod list` | List all your jobs |
258
+ | `byod retrieve <job-id> -o <dir>` | Download encrypted results |
259
+ | `byod decrypt <dir> -o <output>` | Decrypt results locally |
260
+
261
+ ### Utilities
262
+
263
+ | Command | Description |
264
+ |---------|-------------|
265
+ | `byod plugins` | List available pipeline plugins |
266
+ | `byod config show` | Display current configuration |
267
+ | `byod --version` | Show CLI version |
268
+ | `byod --help` | Show help for any command |
269
+
270
+ ---
271
+
272
+ ## Security Model
273
+
274
+ ### How It Works
275
+
276
+ ```
277
+ ┌─────────────────────────────────────────────────────────────────────────────┐
278
+ │ YOUR MACHINE │
279
+ │ │
280
+ │ ~/.aws/credentials ◄─── Your AWS creds (standard AWS config) │
281
+ │ │ │
282
+ │ ▼ │
283
+ │ ┌─────────────────────────────────────────────────────────────────────┐ │
284
+ │ │ byod-cli │ │
285
+ │ │ │ │
286
+ │ │ byod auth login → Authenticate with Lablytics API │ │
287
+ │ │ byod setup → Create KMS key + IAM role in YOUR account │ │
288
+ │ │ byod submit <file> → Encrypt locally, upload to Lablytics S3 │ │
289
+ │ │ byod status <job> → Check job progress │ │
290
+ │ │ byod retrieve <job> → Download encrypted results │ │
291
+ │ │ byod decrypt <dir> → Decrypt locally with YOUR KMS key │ │
292
+ │ └─────────────────────────────────────────────────────────────────────┘ │
293
+ └─────────────────────────────────────────────────────────────────────────────┘
294
+ │ │
295
+ │ API Key │ Presigned URLs
296
+ ▼ ▼
297
+ ┌─────────────────────────────────────────────────────────────────────────────┐
298
+ │ LABLYTICS INFRASTRUCTURE │
299
+ │ │
300
+ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────────────────────┐ │
301
+ │ │ Dashboard │ │ S3 Buckets │ │ Orchestrator + Enclave │ │
302
+ │ │ (read-only) │ │ (encrypted │ │ │ │
303
+ │ │ │ │ data only) │ │ Assumes cross-account role │ │
304
+ │ │ - Job status │ │ │ │ Enclave decrypts via KMS │ │
305
+ │ │ - Logs │ │ │ │ with attestation (PCR0) │ │
306
+ │ └──────────────┘ └──────────────┘ └──────────────────────────────┘ │
307
+ └─────────────────────────────────────────────────────────────────────────────┘
308
+ ```
309
+
310
+ ### Who Can Access Your Data?
311
+
312
+ | Actor | Can Encrypt | Can Decrypt | How |
313
+ |-------|-------------|-------------|-----|
314
+ | You (CLI) | ✓ Yes | ✓ Yes | Your own AWS credentials |
315
+ | Nitro Enclave | ✓ Yes | ✓ Yes | Cross-account role + PCR0 attestation |
316
+ | Lablytics Orchestrator | ✓ Yes | **No** | Can assume role but no attestation |
317
+ | Lablytics Dashboard | No | **No** | No access to KMS |
318
+ | Lablytics Operators | No | **No** | No access to keys or data |
319
+
320
+ ### Security Guarantees
321
+
322
+ 1. **Customer-owned KMS key**: The key lives in YOUR AWS account
323
+ 2. **Attestation-based decrypt**: Only the verified Nitro Enclave can decrypt
324
+ 3. **ExternalId protection**: Each tenant has a unique ExternalId
325
+ 4. **No plaintext transit**: Data is encrypted before leaving your machine
326
+ 5. **No network in enclave**: The enclave has no internet—data flows via vsock
327
+
328
+ ---
329
+
330
+ ## Examples
331
+
332
+ ### Submit a Single File
333
+
334
+ ```bash
335
+ byod submit genomic-qc ./sample.fastq.gz
336
+ ```
337
+
338
+ ### Submit a Directory
339
+
340
+ ```bash
341
+ # The CLI will tar.gz the directory automatically
342
+ byod submit genomic-qc ./samples/
343
+ ```
344
+
345
+ ### Submit with Custom Config
346
+
347
+ ```bash
348
+ # Create a config file
349
+ echo '{"min_quality": 20, "trim_adapters": true}' > config.json
350
+
351
+ # Submit with config
352
+ byod submit genomic-qc ./sample.fastq.gz --config config.json
353
+ ```
354
+
355
+ ### Wait for Job Completion
356
+
357
+ ```bash
358
+ # Block until job finishes (with 1-hour timeout)
359
+ byod submit genomic-qc ./sample.fastq.gz --wait --timeout 3600
360
+ ```
361
+
362
+ ### Check Multiple Jobs
363
+
364
+ ```bash
365
+ # List recent jobs
366
+ byod list
367
+
368
+ # List only completed jobs
369
+ byod list --status completed
370
+
371
+ # List in JSON format for scripting
372
+ byod list --format json
373
+ ```
374
+
375
+ ### Retrieve and Decrypt in One Script
376
+
377
+ ```bash
378
+ #!/bin/bash
379
+ JOB_ID=$1
380
+
381
+ # Wait for completion
382
+ while true; do
383
+ STATUS=$(byod status $JOB_ID --format json | jq -r '.status')
384
+ if [ "$STATUS" = "completed" ]; then
385
+ break
386
+ elif [ "$STATUS" = "failed" ]; then
387
+ echo "Job failed!"
388
+ exit 1
389
+ fi
390
+ sleep 30
391
+ done
392
+
393
+ # Download and decrypt (auto-extracts to directory)
394
+ byod retrieve $JOB_ID -o ./results/
395
+ byod decrypt ./results/ -o ./output/
396
+ ```
397
+
398
+ ### Use Environment Variables
399
+
400
+ ```bash
401
+ # Set API key via environment (useful for CI/CD)
402
+ export BYOD_API_KEY=sk_live_xxxxx
403
+ export BYOD_DEBUG=1 # Enable debug logging
404
+
405
+ byod submit genomic-qc ./sample.fastq.gz
406
+ ```
407
+
408
+ ---
409
+
410
+ ## Available Plugins
411
+
412
+ | Plugin | Description | Input Types |
413
+ |--------|-------------|-------------|
414
+ | `genomic-qc` | FastQC + MultiQC quality control | `.fastq`, `.fastq.gz`, `.fq`, `.fq.gz` |
415
+ | `demo-count` | Simple line/word counting demo | Any text file |
416
+
417
+ List all available plugins:
418
+ ```bash
419
+ byod plugins
420
+ ```
421
+
422
+ ---
423
+
424
+ ## Environment Variables
425
+
426
+ | Variable | Description | Default |
427
+ |----------|-------------|---------|
428
+ | `BYOD_API_KEY` | API key (alternative to `byod auth login`) | - |
429
+ | `BYOD_API_URL` | Custom API URL (for self-hosted) | `https://api.lablytics.io` |
430
+ | `BYOD_DEBUG` | Enable debug logging (`1` or `true`) | `false` |
431
+ | `AWS_PROFILE` | AWS credentials profile to use | `default` |
432
+ | `AWS_REGION` | AWS region for KMS operations | `us-east-1` |
433
+
434
+ ---
435
+
436
+ ## Troubleshooting
437
+
438
+ ### "Not authenticated"
439
+
440
+ **Problem**: CLI cannot find valid credentials.
441
+
442
+ **Solution**:
443
+ ```bash
444
+ byod auth login
445
+ # Enter your API key from the dashboard
446
+ ```
447
+
448
+ ### "No KMS key configured"
449
+
450
+ **Problem**: You haven't run the setup command.
451
+
452
+ **Solution**:
453
+ ```bash
454
+ byod setup
455
+ ```
456
+
457
+ ### "Failed to get AWS identity"
458
+
459
+ **Problem**: AWS credentials are not configured.
460
+
461
+ **Solution**: Configure AWS credentials using one of:
462
+ ```bash
463
+ # Option 1: AWS CLI
464
+ aws configure
465
+
466
+ # Option 2: Environment variables
467
+ export AWS_ACCESS_KEY_ID=AKIA...
468
+ export AWS_SECRET_ACCESS_KEY=...
469
+
470
+ # Option 3: ~/.aws/credentials file
471
+ [default]
472
+ aws_access_key_id = AKIA...
473
+ aws_secret_access_key = ...
474
+ ```
475
+
476
+ ### "AccessDenied when creating KMS key"
477
+
478
+ **Problem**: Your AWS user lacks permissions.
479
+
480
+ **Solution**: Ensure your AWS user has these permissions:
481
+ - `kms:CreateKey`
482
+ - `kms:CreateAlias`
483
+ - `kms:PutKeyPolicy`
484
+ - `iam:CreateRole`
485
+ - `iam:PutRolePolicy`
486
+ - `iam:TagRole`
487
+
488
+ ### "Job stuck in processing"
489
+
490
+ **Problem**: Job is taking longer than expected.
491
+
492
+ **Solution**:
493
+ 1. Check status: `byod status <job-id>`
494
+ 2. View logs in dashboard: https://app.lablytics.io/jobs/<job-id>
495
+ 3. Large files take longer—genomic QC for a 10GB file may take 30+ minutes
496
+
497
+ ### "Decryption failed: AccessDeniedException"
498
+
499
+ **Problem**: KMS won't release the key.
500
+
501
+ **Possible causes**:
502
+ 1. Wrong AWS credentials—ensure you're using the same account as setup
503
+ 2. Key was deleted—check AWS KMS console
504
+ 3. Role was modified—re-run `byod setup`
505
+
506
+ ### Debug Mode
507
+
508
+ Enable verbose logging for troubleshooting:
509
+ ```bash
510
+ byod --debug submit genomic-qc ./sample.fastq.gz
511
+ # or
512
+ export BYOD_DEBUG=1
513
+ byod submit genomic-qc ./sample.fastq.gz
514
+ ```
515
+
516
+ ---
517
+
518
+ ## Configuration Files
519
+
520
+ The CLI stores configuration in `~/.byod/`:
521
+
522
+ ```
523
+ ~/.byod/
524
+ ├── config.json # API key, URL, active profile
525
+ └── profiles/ # Per-tenant profiles (auto-created)
526
+ ```
527
+
528
+ View current config:
529
+ ```bash
530
+ byod config show
531
+ ```
532
+
533
+ ---
534
+
535
+ ## Development
536
+
537
+ ```bash
538
+ # Install with dev dependencies
539
+ pip install -e ".[dev]"
540
+
541
+ # Run tests
542
+ pytest
543
+
544
+ # Type checking
545
+ mypy src/
546
+
547
+ # Linting
548
+ ruff check src/
549
+
550
+ # Format code
551
+ ruff format src/
552
+ ```
553
+
554
+ ---
555
+
556
+ ## Support
557
+
558
+ - **Documentation**: https://docs.lablytics.io/cli
559
+ - **Dashboard**: https://app.lablytics.io
560
+ - **Issues**: https://github.com/lablytics/byod-platform/issues
561
+ - **Email**: support@lablytics.io
562
+
563
+ ---
564
+
565
+ ## License
566
+
567
+ MIT