Library for interacting with the ahab cloud API and Kubernetes system
Tuple, LLC | tuple.xyz/solutions/ahab/
## Python library from PyPI using pip
pip install ahab-lib
## CLI using pipx
pipx install git+https://github.com/tuplexyz/ahab-lib.git
This library can use environment variables to avoid passing sensitive information in code. The following environment variables are used by this library:
AHAB_API_URL
- The URL for the ahab cloud APIAHAB_API_KEY
- Your API key for the ahab cloud API
You can retrieve these values using the following Azure CLI commands:
## On Unix
export AHAB_API_URL=https://$(az functionapp show --name func-ahab-dev-eastus-001 --resource-group rg-ahab-dev-eastus-001 --query defaultHostName -o tsv)
export AHAB_API_KEY=$(az functionapp keys list --name func-ahab-dev-eastus-001 --resource-group rg-ahab-dev-eastus-001 --query functionKeys -o tsv)
## On Windows
set AHAB_API_URL=https://$(az functionapp show --name func-ahab-dev-eastus-001 --resource-group rg-ahab-dev-eastus-001 --query defaultHostName -o tsv)
set AHAB_API_KEY=$(az functionapp keys list --name func-ahab-dev-eastus-001 --resource-group rg-ahab-dev-eastus-001 --query functionKeys -o tsv)
...changing the --name
and --resource-group
values to the names of your ahab instance's Function App and Resource Group, respectively.
ahab job submit --body='{"job_type": "rnaseq", "metadata": {"project": "project_001", "sample": "sample_001"}, "inputs": {"references": "/mnt/datalake/reference/rnaseq_1", "fastq_1": "/mnt/datalake/project_001/sample_001/rnaseq/file_1.fastq.gz", "fastq_2": "/mnt/datalake/project_001/sample_001/rnaseq/file_2.fastq.gz"}}'
ahab job get --job_type=rnaseq
ahab job update --id=fb273f3b-9665-4f9d-978c-9f6cb9f1cc19 --status=COMPLETE --body='{"outputs": {"bam": "/mnt/datalake/project_001/sample_001/rnaseq/file_1.bam", "bai": "/mnt/datalake/project_001/sample_001/rnaseq/file_1.bam.bai"}}'
from ahab.job import get_job, submit_job, update_job
import os, json
api_base_url = os.environ.get('AHAB_API_URL', '')
api_key = os.environ.get('AHAB_API_KEY', '')
body = {
"job_type": "rnaseq",
"metadata": {
"project": "project_001",
"sample": "sample_001"
},
"inputs": {
"references": "/mnt/datalake/reference/rnaseq_1",
"fastq_1": "/mnt/datalake/project_001/sample_001/rnaseq/file_1.fastq.gz",
"fastq_2": "/mnt/datalake/project_001/sample_001/rnaseq/file_2.fastq.gz"
}
}
response = submit_job(body = body, api_base_url = api_base_url, api_key = api_key)
# {'message': 'Job created successfully.', 'id': 'fb273f3b-9665-4f9d-978c-9f6cb9f1cc19', 'job_type': 'rnaseq'}
job = get_job(job_type='rnaseq', api_base_url = api_base_url, api_key = api_key)
# {'id': 'fb273f3b-9665-4f9d-978c-9f6cb9f1cc19', 'job_type': 'rnaseq', 'current_status': 'STARTED', 'status_history': {'2024-04-29T17:10:18.552843': 'PENDING', '2024-04-29T17:11:15.582001': 'STARTED'}, 'metadata': {'project': 'project_001', 'sample': 'sample_001'}, 'inputs': {'references': '/mnt/datalake/reference/rnaseq_1', 'fastq_1': '/mnt/datalake/project_001/sample_001/rnaseq/file_1.fastq.gz', 'fastq_2': '/mnt/datalake/project_001/sample_001/rnaseq/file_2.fastq.gz'}}
body = {
"outputs": {
"bam": "/mnt/datalake/project_001/sample_001/rnaseq/file_1.bam",
"bai": "/mnt/datalake/project_001/sample_001/rnaseq/file_1.bam.bai"
}
}
response = update_job(id = 'fb273f3b-9665-4f9d-978c-9f6cb9f1cc19', status = "COMPLETE", body = body, api_base_url = api_base_url, api_key = api_key)
# {'message': 'Job updated successfully.', 'id': 'fb273f3b-9665-4f9d-978c-9f6cb9f1cc19', 'status': 'COMPLETE'}