biolmai 0.2.3__tar.gz → 0.2.5__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.

Potentially problematic release.


This version of biolmai might be problematic. Click here for more details.

Files changed (109) hide show
  1. biolmai-0.2.5/PKG-INFO +134 -0
  2. biolmai-0.2.5/README.rst +95 -0
  3. biolmai-0.2.5/biolmai/__init__.py +24 -0
  4. {biolmai-0.2.3 → biolmai-0.2.5}/biolmai/auth.py +56 -4
  5. biolmai-0.2.5/biolmai.egg-info/PKG-INFO +134 -0
  6. {biolmai-0.2.3 → biolmai-0.2.5}/biolmai.egg-info/SOURCES.txt +0 -34
  7. {biolmai-0.2.3 → biolmai-0.2.5}/docs/conf.py +103 -3
  8. {biolmai-0.2.3 → biolmai-0.2.5}/docs/index.rst +0 -16
  9. {biolmai-0.2.3 → biolmai-0.2.5}/docs/python-client/api_biolm.rst +3 -3
  10. {biolmai-0.2.3 → biolmai-0.2.5}/docs/python-client/async_sync.rst +6 -6
  11. {biolmai-0.2.3 → biolmai-0.2.5}/docs/python-client/batching.rst +9 -9
  12. {biolmai-0.2.3 → biolmai-0.2.5}/docs/python-client/disk_output.rst +2 -2
  13. {biolmai-0.2.3 → biolmai-0.2.5}/docs/python-client/error_handling.rst +7 -7
  14. {biolmai-0.2.3 → biolmai-0.2.5}/docs/python-client/quickstart.rst +4 -4
  15. {biolmai-0.2.3 → biolmai-0.2.5}/docs/python-client/usage.rst +6 -6
  16. {biolmai-0.2.3 → biolmai-0.2.5}/pyproject.toml +1 -1
  17. {biolmai-0.2.3 → biolmai-0.2.5}/setup.cfg +1 -1
  18. {biolmai-0.2.3 → biolmai-0.2.5}/setup.py +2 -2
  19. biolmai-0.2.3/PKG-INFO +0 -76
  20. biolmai-0.2.3/README.rst +0 -37
  21. biolmai-0.2.3/biolmai/__init__.py +0 -10
  22. biolmai-0.2.3/biolmai.egg-info/PKG-INFO +0 -76
  23. biolmai-0.2.3/docs/model-docs/ablang/AbLang_API.rst +0 -200
  24. biolmai-0.2.3/docs/model-docs/ablang/AbLang_Additional.rst +0 -94
  25. biolmai-0.2.3/docs/model-docs/ablang/index.rst +0 -10
  26. biolmai-0.2.3/docs/model-docs/biolmtox/BioLMTox_API.rst +0 -293
  27. biolmai-0.2.3/docs/model-docs/biolmtox/BioLMTox_Additional.rst +0 -62
  28. biolmai-0.2.3/docs/model-docs/biolmtox/index.rst +0 -10
  29. biolmai-0.2.3/docs/model-docs/dnabert/DNABERT_Additional.rst +0 -59
  30. biolmai-0.2.3/docs/model-docs/dnabert/classifier_ft.rst +0 -607
  31. biolmai-0.2.3/docs/model-docs/dnabert/index.rst +0 -10
  32. biolmai-0.2.3/docs/model-docs/esm1v/ESM-1v_API.rst +0 -196
  33. biolmai-0.2.3/docs/model-docs/esm1v/ESM-1v_Additional.rst +0 -89
  34. biolmai-0.2.3/docs/model-docs/esm1v/index.rst +0 -10
  35. biolmai-0.2.3/docs/model-docs/esm2/ESM2_API.rst +0 -450
  36. biolmai-0.2.3/docs/model-docs/esm2/ESM2_Additional.rst +0 -99
  37. biolmai-0.2.3/docs/model-docs/esm2/index.rst +0 -10
  38. biolmai-0.2.3/docs/model-docs/esmfold/ESMFold_API.rst +0 -166
  39. biolmai-0.2.3/docs/model-docs/esmfold/ESMFold_Additional.rst +0 -108
  40. biolmai-0.2.3/docs/model-docs/esmfold/index.rst +0 -10
  41. biolmai-0.2.3/docs/model-docs/esmif/ESM_InverseFold_API.rst +0 -212
  42. biolmai-0.2.3/docs/model-docs/esmif/ESM_InverseFold_Additional.rst +0 -104
  43. biolmai-0.2.3/docs/model-docs/esmif/index.rst +0 -10
  44. biolmai-0.2.3/docs/model-docs/finetuning/index.rst +0 -11
  45. biolmai-0.2.3/docs/model-docs/img/book_icon.png +0 -0
  46. biolmai-0.2.3/docs/model-docs/img/esmfold_perf.png +0 -0
  47. biolmai-0.2.3/docs/model-docs/index.rst +0 -13
  48. biolmai-0.2.3/docs/model-docs/progen2/ProGen2_API.rst +0 -222
  49. biolmai-0.2.3/docs/model-docs/progen2/ProGen2_Additional.rst +0 -70
  50. biolmai-0.2.3/docs/model-docs/progen2/index.rst +0 -10
  51. biolmai-0.2.3/docs/model-docs/proteinfer/ProteInfer_API.rst +0 -181
  52. biolmai-0.2.3/docs/model-docs/proteinfer/ProteInfer_Additional.rst +0 -92
  53. biolmai-0.2.3/docs/model-docs/proteinfer/index.rst +0 -10
  54. biolmai-0.2.3/docs/model-docs/protgpt2/ProtGPT2.rst +0 -75
  55. biolmai-0.2.3/docs/model-docs/protgpt2/generator_ft.rst +0 -573
  56. biolmai-0.2.3/docs/model-docs/protgpt2/index.rst +0 -10
  57. {biolmai-0.2.3 → biolmai-0.2.5}/AUTHORS.rst +0 -0
  58. {biolmai-0.2.3 → biolmai-0.2.5}/CONTRIBUTING.rst +0 -0
  59. {biolmai-0.2.3 → biolmai-0.2.5}/HISTORY.rst +0 -0
  60. {biolmai-0.2.3 → biolmai-0.2.5}/LICENSE +0 -0
  61. {biolmai-0.2.3 → biolmai-0.2.5}/MANIFEST.in +0 -0
  62. {biolmai-0.2.3 → biolmai-0.2.5}/biolmai/api.py +0 -0
  63. {biolmai-0.2.3 → biolmai-0.2.5}/biolmai/asynch.py +0 -0
  64. {biolmai-0.2.3 → biolmai-0.2.5}/biolmai/biolmai.py +0 -0
  65. {biolmai-0.2.3 → biolmai-0.2.5}/biolmai/cli.py +0 -0
  66. {biolmai-0.2.3 → biolmai-0.2.5}/biolmai/client.py +0 -0
  67. {biolmai-0.2.3 → biolmai-0.2.5}/biolmai/cls.py +0 -0
  68. {biolmai-0.2.3 → biolmai-0.2.5}/biolmai/const.py +0 -0
  69. {biolmai-0.2.3 → biolmai-0.2.5}/biolmai/ltc.py +0 -0
  70. {biolmai-0.2.3 → biolmai-0.2.5}/biolmai/payloads.py +0 -0
  71. {biolmai-0.2.3 → biolmai-0.2.5}/biolmai/validate.py +0 -0
  72. {biolmai-0.2.3 → biolmai-0.2.5}/biolmai.egg-info/dependency_links.txt +0 -0
  73. {biolmai-0.2.3 → biolmai-0.2.5}/biolmai.egg-info/entry_points.txt +0 -0
  74. {biolmai-0.2.3 → biolmai-0.2.5}/biolmai.egg-info/not-zip-safe +0 -0
  75. {biolmai-0.2.3 → biolmai-0.2.5}/biolmai.egg-info/requires.txt +0 -0
  76. {biolmai-0.2.3 → biolmai-0.2.5}/biolmai.egg-info/top_level.txt +0 -0
  77. {biolmai-0.2.3 → biolmai-0.2.5}/docs/Makefile +0 -0
  78. {biolmai-0.2.3 → biolmai-0.2.5}/docs/_static/api_reference_icon.png +0 -0
  79. {biolmai-0.2.3 → biolmai-0.2.5}/docs/_static/biolm_docs_logo_dark.png +0 -0
  80. {biolmai-0.2.3 → biolmai-0.2.5}/docs/_static/biolm_docs_logo_light.png +0 -0
  81. {biolmai-0.2.3 → biolmai-0.2.5}/docs/_static/biolm_logomark_transparent.png +0 -0
  82. {biolmai-0.2.3 → biolmai-0.2.5}/docs/_static/biolm_logomark_transparent_for_dark.png +0 -0
  83. {biolmai-0.2.3 → biolmai-0.2.5}/docs/_static/chat_agents_icon.png +0 -0
  84. {biolmai-0.2.3 → biolmai-0.2.5}/docs/_static/jupyter_notebooks_icon.png +0 -0
  85. {biolmai-0.2.3 → biolmai-0.2.5}/docs/_static/model_docs_icon.png +0 -0
  86. {biolmai-0.2.3 → biolmai-0.2.5}/docs/_static/python_sdk_icon.png +0 -0
  87. {biolmai-0.2.3 → biolmai-0.2.5}/docs/_static/tutorials_icon.png +0 -0
  88. {biolmai-0.2.3 → biolmai-0.2.5}/docs/biolmai.rst +0 -0
  89. {biolmai-0.2.3 → biolmai-0.2.5}/docs/make.bat +0 -0
  90. {biolmai-0.2.3 → biolmai-0.2.5}/docs/modules.rst +0 -0
  91. {biolmai-0.2.3 → biolmai-0.2.5}/docs/python-client/api_client.rst +0 -0
  92. {biolmai-0.2.3 → biolmai-0.2.5}/docs/python-client/authentication.rst +0 -0
  93. {biolmai-0.2.3 → biolmai-0.2.5}/docs/python-client/faq.rst +0 -0
  94. {biolmai-0.2.3 → biolmai-0.2.5}/docs/python-client/features.rst +0 -0
  95. {biolmai-0.2.3 → biolmai-0.2.5}/docs/python-client/index.rst +0 -0
  96. {biolmai-0.2.3 → biolmai-0.2.5}/docs/python-client/installation.rst +0 -0
  97. {biolmai-0.2.3 → biolmai-0.2.5}/docs/python-client/overview.rst +0 -0
  98. {biolmai-0.2.3 → biolmai-0.2.5}/docs/python-client/rate_limiting.rst +0 -0
  99. {biolmai-0.2.3 → biolmai-0.2.5}/docs/tutorials_use_cases/notebooks.rst +0 -0
  100. {biolmai-0.2.3 → biolmai-0.2.5}/tests/__init__.py +0 -0
  101. {biolmai-0.2.3 → biolmai-0.2.5}/tests/test_abatch_calls.py +0 -0
  102. {biolmai-0.2.3 → biolmai-0.2.5}/tests/test_aclient.py +0 -0
  103. {biolmai-0.2.3 → biolmai-0.2.5}/tests/test_batch_error_retry.py +0 -0
  104. {biolmai-0.2.3 → biolmai-0.2.5}/tests/test_batch_errors.py +0 -0
  105. {biolmai-0.2.3 → biolmai-0.2.5}/tests/test_biolmai.py +0 -0
  106. {biolmai-0.2.3 → biolmai-0.2.5}/tests/test_client.py +0 -0
  107. {biolmai-0.2.3 → biolmai-0.2.5}/tests/test_max_items.py +0 -0
  108. {biolmai-0.2.3 → biolmai-0.2.5}/tests/test_rate_limit.py +0 -0
  109. {biolmai-0.2.3 → biolmai-0.2.5}/tests/test_schemas.py +0 -0
biolmai-0.2.5/PKG-INFO ADDED
@@ -0,0 +1,134 @@
1
+ Metadata-Version: 2.4
2
+ Name: biolmai
3
+ Version: 0.2.5
4
+ Summary: BioLM Python client
5
+ Home-page: https://github.com/BioLM/py-biolm
6
+ Author: BioLM
7
+ Author-email: BioLM <support@biolm.ai>
8
+ License: Apache Software License 2.0
9
+ Keywords: biolmai
10
+ Classifier: Development Status :: 2 - Pre-Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Natural Language :: English
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Requires-Python: >=3.7
22
+ Description-Content-Type: text/x-rst
23
+ License-File: LICENSE
24
+ License-File: AUTHORS.rst
25
+ Requires-Dist: httpx>=0.23.0
26
+ Requires-Dist: httpcore
27
+ Requires-Dist: Click>=6.0
28
+ Requires-Dist: requests
29
+ Requires-Dist: aiodns
30
+ Requires-Dist: synchronicity>=0.5.0
31
+ Requires-Dist: aiohttp<=3.8.6; python_version < "3.12"
32
+ Requires-Dist: aiohttp>=3.9.0; python_version >= "3.12"
33
+ Requires-Dist: async-lru
34
+ Requires-Dist: aiofiles
35
+ Dynamic: author
36
+ Dynamic: home-page
37
+ Dynamic: license-file
38
+ Dynamic: requires-python
39
+
40
+ ========
41
+ BioLM AI
42
+ ========
43
+
44
+
45
+ .. image:: https://img.shields.io/pypi/v/biolmai.svg
46
+ :target: https://pypi.python.org/pypi/biolmai
47
+
48
+ .. image:: https://api.travis-ci.com/BioLM/py-biolm.svg?branch=production
49
+ :target: https://travis-ci.org/github/BioLM/py-biolm
50
+
51
+ .. image:: https://readthedocs.org/projects/biolm-ai/badge/?version=latest
52
+ :target: https://biolm-ai.readthedocs.io/en/latest/?version=latest
53
+ :alt: Documentation Status
54
+
55
+
56
+
57
+
58
+ Python client and SDK for `BioLM <https://biolm.ai>`_
59
+
60
+ Install the package:
61
+
62
+ .. code-block:: bash
63
+
64
+ pip install biolmai
65
+
66
+ Basic usage:
67
+
68
+ .. code-block:: python
69
+
70
+ from biolmai import biolm
71
+
72
+ # Encode a single sequence
73
+ result = biolm(entity="esm2-8m", action="encode", type="sequence", items="MSILVTRPSPAGEEL")
74
+
75
+ # Predict a batch of sequences
76
+ result = biolm(entity="esmfold", action="predict", type="sequence", items=["SEQ1", "SEQ2"])
77
+
78
+ # Write results to disk
79
+ biolm(entity="esmfold", action="predict", type="sequence", items=["SEQ1", "SEQ2"], output='disk', file_path="results.jsonl")
80
+
81
+ Asynchronous usage:
82
+
83
+ .. code-block:: python
84
+
85
+ from biolmai.client import BioLMApiClient
86
+ import asyncio
87
+
88
+ async def main():
89
+ model = BioLMApiClient("esmfold")
90
+ result = await model.predict(items=[{"sequence": "MDNELE"}])
91
+ print(result)
92
+
93
+ asyncio.run(main())
94
+
95
+ Overview
96
+ ========
97
+
98
+ The BioLM Python client provides a high-level, user-friendly interface for interacting with the BioLM API. It supports both synchronous and asynchronous usage, automatic batching, flexible error handling, and efficient processing of biological data.
99
+
100
+ Main features:
101
+
102
+ - High-level BioLM constructor for quick requests
103
+ - Sync and async interfaces
104
+ - Automatic or custom rate limiting/throttling
105
+ - Schema-based batch size detection
106
+ - Flexible input formats (single key + list, or list of dicts)
107
+ - Low memory usage via generators
108
+ - Flexible error handling (raise, continue, or stop on error)
109
+ - Universal HTTP client for both sync and async
110
+
111
+ Features
112
+ ========
113
+
114
+ - **High-level constructor**: Instantly run an API call with a single line.
115
+ - **Sync and async**: Use `BioLM` for sync, or `BioLMApiClient` for async.
116
+ - **Flexible rate limiting**: Use API throttle, disable, or set your own (e.g., '1000/second').
117
+ - **Schema-based batching**: Automatically queries API for max batch size.
118
+ - **Flexible input**: Accepts a single key and list, or list of dicts, or list of lists for advanced batching.
119
+ - **Low memory**: Uses generators for validation and batching.
120
+ - **Error handling**: Raise HTTPX errors, continue on error, or stop on first error.
121
+ - **Disk output**: Write results as JSONL to disk.
122
+ - **Universal HTTP client**: Efficient for both sync and async.
123
+ - **Direct access to schema and batching**: Use `BioLMApi` for advanced workflows, including `.schema()`, `.call()`, and `._batch_call_autoschema_or_manual()`.
124
+
125
+ **Example endpoints and actions:**
126
+
127
+ - `esm2-8m/encode`: Embedding for protein sequences.
128
+ - `esmfold/predict`: Structure prediction for protein sequences.
129
+ - `progen2-oas/generate`: Sequence generation from a context string.
130
+ - `dnabert2/predict`: Masked prediction for protein sequences.
131
+ - `ablang2/encode`: Embeddings for paired-chain antibodies.
132
+
133
+ * Free software: Apache Software License 2.0
134
+ * Documentation: https://docs.biolm.ai
@@ -0,0 +1,95 @@
1
+ ========
2
+ BioLM AI
3
+ ========
4
+
5
+
6
+ .. image:: https://img.shields.io/pypi/v/biolmai.svg
7
+ :target: https://pypi.python.org/pypi/biolmai
8
+
9
+ .. image:: https://api.travis-ci.com/BioLM/py-biolm.svg?branch=production
10
+ :target: https://travis-ci.org/github/BioLM/py-biolm
11
+
12
+ .. image:: https://readthedocs.org/projects/biolm-ai/badge/?version=latest
13
+ :target: https://biolm-ai.readthedocs.io/en/latest/?version=latest
14
+ :alt: Documentation Status
15
+
16
+
17
+
18
+
19
+ Python client and SDK for `BioLM <https://biolm.ai>`_
20
+
21
+ Install the package:
22
+
23
+ .. code-block:: bash
24
+
25
+ pip install biolmai
26
+
27
+ Basic usage:
28
+
29
+ .. code-block:: python
30
+
31
+ from biolmai import biolm
32
+
33
+ # Encode a single sequence
34
+ result = biolm(entity="esm2-8m", action="encode", type="sequence", items="MSILVTRPSPAGEEL")
35
+
36
+ # Predict a batch of sequences
37
+ result = biolm(entity="esmfold", action="predict", type="sequence", items=["SEQ1", "SEQ2"])
38
+
39
+ # Write results to disk
40
+ biolm(entity="esmfold", action="predict", type="sequence", items=["SEQ1", "SEQ2"], output='disk', file_path="results.jsonl")
41
+
42
+ Asynchronous usage:
43
+
44
+ .. code-block:: python
45
+
46
+ from biolmai.client import BioLMApiClient
47
+ import asyncio
48
+
49
+ async def main():
50
+ model = BioLMApiClient("esmfold")
51
+ result = await model.predict(items=[{"sequence": "MDNELE"}])
52
+ print(result)
53
+
54
+ asyncio.run(main())
55
+
56
+ Overview
57
+ ========
58
+
59
+ The BioLM Python client provides a high-level, user-friendly interface for interacting with the BioLM API. It supports both synchronous and asynchronous usage, automatic batching, flexible error handling, and efficient processing of biological data.
60
+
61
+ Main features:
62
+
63
+ - High-level BioLM constructor for quick requests
64
+ - Sync and async interfaces
65
+ - Automatic or custom rate limiting/throttling
66
+ - Schema-based batch size detection
67
+ - Flexible input formats (single key + list, or list of dicts)
68
+ - Low memory usage via generators
69
+ - Flexible error handling (raise, continue, or stop on error)
70
+ - Universal HTTP client for both sync and async
71
+
72
+ Features
73
+ ========
74
+
75
+ - **High-level constructor**: Instantly run an API call with a single line.
76
+ - **Sync and async**: Use `BioLM` for sync, or `BioLMApiClient` for async.
77
+ - **Flexible rate limiting**: Use API throttle, disable, or set your own (e.g., '1000/second').
78
+ - **Schema-based batching**: Automatically queries API for max batch size.
79
+ - **Flexible input**: Accepts a single key and list, or list of dicts, or list of lists for advanced batching.
80
+ - **Low memory**: Uses generators for validation and batching.
81
+ - **Error handling**: Raise HTTPX errors, continue on error, or stop on first error.
82
+ - **Disk output**: Write results as JSONL to disk.
83
+ - **Universal HTTP client**: Efficient for both sync and async.
84
+ - **Direct access to schema and batching**: Use `BioLMApi` for advanced workflows, including `.schema()`, `.call()`, and `._batch_call_autoschema_or_manual()`.
85
+
86
+ **Example endpoints and actions:**
87
+
88
+ - `esm2-8m/encode`: Embedding for protein sequences.
89
+ - `esmfold/predict`: Structure prediction for protein sequences.
90
+ - `progen2-oas/generate`: Sequence generation from a context string.
91
+ - `dnabert2/predict`: Masked prediction for protein sequences.
92
+ - `ablang2/encode`: Embeddings for paired-chain antibodies.
93
+
94
+ * Free software: Apache Software License 2.0
95
+ * Documentation: https://docs.biolm.ai
@@ -0,0 +1,24 @@
1
+ """Top-level package for BioLM AI."""
2
+ __author__ = """Nikhil Haas"""
3
+ __email__ = "nikhil@biolm.ai"
4
+ __version__ = '0.2.5'
5
+
6
+ from biolmai.client import BioLMApi, BioLMApiClient
7
+ from biolmai.biolmai import BioLM
8
+ from typing import Optional, Union, List, Any
9
+
10
+ __all__ = ['biolm']
11
+
12
+
13
+ def biolm(
14
+ *,
15
+ entity: str,
16
+ action: str,
17
+ type: Optional[str] = None,
18
+ items: Union[Any, List[Any]],
19
+ params: Optional[dict] = None,
20
+ api_key: Optional[str] = None,
21
+ **kwargs
22
+ ) -> Any:
23
+ """Top-level convenience function that wraps the BioLM class and returns the result."""
24
+ return BioLM(entity=entity, action=action, type=type, items=items, params=params, api_key=api_key, **kwargs)
@@ -1,3 +1,4 @@
1
+ import ast
1
2
  import json
2
3
  import os
3
4
  import pprint
@@ -9,6 +10,47 @@ import requests
9
10
  from biolmai.const import ACCESS_TOK_PATH, BASE_DOMAIN, GEN_TOKEN_URL, USER_BIOLM_DIR
10
11
 
11
12
 
13
+ def parse_credentials_file(file_path):
14
+ """Parse credentials file, handling JSON, Python dict syntax, and mixed types.
15
+
16
+ Returns a dict with 'access' and 'refresh' keys as strings, or None if parsing fails.
17
+ Uses ast.literal_eval() which is safe and only evaluates Python literals.
18
+ """
19
+ try:
20
+ with open(file_path, 'r') as f:
21
+ content = f.read().strip()
22
+
23
+ # Try JSON first
24
+ try:
25
+ data = json.loads(content)
26
+ except json.JSONDecodeError:
27
+ # Fall back to safe Python literal evaluation for dict syntax like {access: 123, refresh: 456}
28
+ # ast.literal_eval() is safe - it only evaluates literals, no code execution
29
+ try:
30
+ data = ast.literal_eval(content)
31
+ except (ValueError, SyntaxError):
32
+ return None
33
+
34
+ # Ensure we have a dictionary
35
+ if not isinstance(data, dict):
36
+ return None
37
+
38
+ # Extract access and refresh, converting to strings
39
+ access = data.get("access")
40
+ refresh = data.get("refresh")
41
+
42
+ # Convert to strings if they exist
43
+ if access is not None:
44
+ access = str(access)
45
+ if refresh is not None:
46
+ refresh = str(refresh)
47
+
48
+ return {"access": access, "refresh": refresh}
49
+
50
+ except Exception:
51
+ return None
52
+
53
+
12
54
  def validate_user_auth(api_token=None, access=None, refresh=None):
13
55
  """Validates an API token, to be used as 'Authorization: Token 1235abc'
14
56
  authentication method."""
@@ -61,8 +103,12 @@ def get_auth_status():
61
103
  elif os.path.exists(ACCESS_TOK_PATH):
62
104
  msg = f"Credentials file found {ACCESS_TOK_PATH}. Validating token..."
63
105
  click.echo(msg)
64
- with open(ACCESS_TOK_PATH) as f:
65
- access_refresh_dict = json.load(f)
106
+ access_refresh_dict = parse_credentials_file(ACCESS_TOK_PATH)
107
+ if access_refresh_dict is None:
108
+ click.echo(f"Error reading credentials file {ACCESS_TOK_PATH}.")
109
+ click.echo("The file may be corrupted or contain invalid data.")
110
+ click.echo("Please login again by running `biolmai login`.")
111
+ return
66
112
  access = access_refresh_dict.get("access")
67
113
  refresh = access_refresh_dict.get("refresh")
68
114
  resp = validate_user_auth(access=access, refresh=refresh)
@@ -156,8 +202,14 @@ def get_user_auth_header():
156
202
  if api_token:
157
203
  headers = {"Authorization": f"Token {api_token}"}
158
204
  elif os.path.exists(ACCESS_TOK_PATH):
159
- with open(ACCESS_TOK_PATH) as f:
160
- access_refresh_dict = json.load(f)
205
+ access_refresh_dict = parse_credentials_file(ACCESS_TOK_PATH)
206
+ if access_refresh_dict is None:
207
+ err = (
208
+ f"Error reading credentials file {ACCESS_TOK_PATH}. "
209
+ "The file may be corrupted or contain invalid data. "
210
+ "Please run `biolmai login` to re-authenticate."
211
+ )
212
+ raise AssertionError(err)
161
213
  access = access_refresh_dict.get("access")
162
214
  refresh = access_refresh_dict.get("refresh")
163
215
  headers = {
@@ -0,0 +1,134 @@
1
+ Metadata-Version: 2.4
2
+ Name: biolmai
3
+ Version: 0.2.5
4
+ Summary: BioLM Python client
5
+ Home-page: https://github.com/BioLM/py-biolm
6
+ Author: BioLM
7
+ Author-email: BioLM <support@biolm.ai>
8
+ License: Apache Software License 2.0
9
+ Keywords: biolmai
10
+ Classifier: Development Status :: 2 - Pre-Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Natural Language :: English
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Requires-Python: >=3.7
22
+ Description-Content-Type: text/x-rst
23
+ License-File: LICENSE
24
+ License-File: AUTHORS.rst
25
+ Requires-Dist: httpx>=0.23.0
26
+ Requires-Dist: httpcore
27
+ Requires-Dist: Click>=6.0
28
+ Requires-Dist: requests
29
+ Requires-Dist: aiodns
30
+ Requires-Dist: synchronicity>=0.5.0
31
+ Requires-Dist: aiohttp<=3.8.6; python_version < "3.12"
32
+ Requires-Dist: aiohttp>=3.9.0; python_version >= "3.12"
33
+ Requires-Dist: async-lru
34
+ Requires-Dist: aiofiles
35
+ Dynamic: author
36
+ Dynamic: home-page
37
+ Dynamic: license-file
38
+ Dynamic: requires-python
39
+
40
+ ========
41
+ BioLM AI
42
+ ========
43
+
44
+
45
+ .. image:: https://img.shields.io/pypi/v/biolmai.svg
46
+ :target: https://pypi.python.org/pypi/biolmai
47
+
48
+ .. image:: https://api.travis-ci.com/BioLM/py-biolm.svg?branch=production
49
+ :target: https://travis-ci.org/github/BioLM/py-biolm
50
+
51
+ .. image:: https://readthedocs.org/projects/biolm-ai/badge/?version=latest
52
+ :target: https://biolm-ai.readthedocs.io/en/latest/?version=latest
53
+ :alt: Documentation Status
54
+
55
+
56
+
57
+
58
+ Python client and SDK for `BioLM <https://biolm.ai>`_
59
+
60
+ Install the package:
61
+
62
+ .. code-block:: bash
63
+
64
+ pip install biolmai
65
+
66
+ Basic usage:
67
+
68
+ .. code-block:: python
69
+
70
+ from biolmai import biolm
71
+
72
+ # Encode a single sequence
73
+ result = biolm(entity="esm2-8m", action="encode", type="sequence", items="MSILVTRPSPAGEEL")
74
+
75
+ # Predict a batch of sequences
76
+ result = biolm(entity="esmfold", action="predict", type="sequence", items=["SEQ1", "SEQ2"])
77
+
78
+ # Write results to disk
79
+ biolm(entity="esmfold", action="predict", type="sequence", items=["SEQ1", "SEQ2"], output='disk', file_path="results.jsonl")
80
+
81
+ Asynchronous usage:
82
+
83
+ .. code-block:: python
84
+
85
+ from biolmai.client import BioLMApiClient
86
+ import asyncio
87
+
88
+ async def main():
89
+ model = BioLMApiClient("esmfold")
90
+ result = await model.predict(items=[{"sequence": "MDNELE"}])
91
+ print(result)
92
+
93
+ asyncio.run(main())
94
+
95
+ Overview
96
+ ========
97
+
98
+ The BioLM Python client provides a high-level, user-friendly interface for interacting with the BioLM API. It supports both synchronous and asynchronous usage, automatic batching, flexible error handling, and efficient processing of biological data.
99
+
100
+ Main features:
101
+
102
+ - High-level BioLM constructor for quick requests
103
+ - Sync and async interfaces
104
+ - Automatic or custom rate limiting/throttling
105
+ - Schema-based batch size detection
106
+ - Flexible input formats (single key + list, or list of dicts)
107
+ - Low memory usage via generators
108
+ - Flexible error handling (raise, continue, or stop on error)
109
+ - Universal HTTP client for both sync and async
110
+
111
+ Features
112
+ ========
113
+
114
+ - **High-level constructor**: Instantly run an API call with a single line.
115
+ - **Sync and async**: Use `BioLM` for sync, or `BioLMApiClient` for async.
116
+ - **Flexible rate limiting**: Use API throttle, disable, or set your own (e.g., '1000/second').
117
+ - **Schema-based batching**: Automatically queries API for max batch size.
118
+ - **Flexible input**: Accepts a single key and list, or list of dicts, or list of lists for advanced batching.
119
+ - **Low memory**: Uses generators for validation and batching.
120
+ - **Error handling**: Raise HTTPX errors, continue on error, or stop on first error.
121
+ - **Disk output**: Write results as JSONL to disk.
122
+ - **Universal HTTP client**: Efficient for both sync and async.
123
+ - **Direct access to schema and batching**: Use `BioLMApi` for advanced workflows, including `.schema()`, `.call()`, and `._batch_call_autoschema_or_manual()`.
124
+
125
+ **Example endpoints and actions:**
126
+
127
+ - `esm2-8m/encode`: Embedding for protein sequences.
128
+ - `esmfold/predict`: Structure prediction for protein sequences.
129
+ - `progen2-oas/generate`: Sequence generation from a context string.
130
+ - `dnabert2/predict`: Masked prediction for protein sequences.
131
+ - `ablang2/encode`: Embeddings for paired-chain antibodies.
132
+
133
+ * Free software: Apache Software License 2.0
134
+ * Documentation: https://docs.biolm.ai
@@ -42,40 +42,6 @@ docs/_static/jupyter_notebooks_icon.png
42
42
  docs/_static/model_docs_icon.png
43
43
  docs/_static/python_sdk_icon.png
44
44
  docs/_static/tutorials_icon.png
45
- docs/model-docs/index.rst
46
- docs/model-docs/ablang/AbLang_API.rst
47
- docs/model-docs/ablang/AbLang_Additional.rst
48
- docs/model-docs/ablang/index.rst
49
- docs/model-docs/biolmtox/BioLMTox_API.rst
50
- docs/model-docs/biolmtox/BioLMTox_Additional.rst
51
- docs/model-docs/biolmtox/index.rst
52
- docs/model-docs/dnabert/DNABERT_Additional.rst
53
- docs/model-docs/dnabert/classifier_ft.rst
54
- docs/model-docs/dnabert/index.rst
55
- docs/model-docs/esm1v/ESM-1v_API.rst
56
- docs/model-docs/esm1v/ESM-1v_Additional.rst
57
- docs/model-docs/esm1v/index.rst
58
- docs/model-docs/esm2/ESM2_API.rst
59
- docs/model-docs/esm2/ESM2_Additional.rst
60
- docs/model-docs/esm2/index.rst
61
- docs/model-docs/esmfold/ESMFold_API.rst
62
- docs/model-docs/esmfold/ESMFold_Additional.rst
63
- docs/model-docs/esmfold/index.rst
64
- docs/model-docs/esmif/ESM_InverseFold_API.rst
65
- docs/model-docs/esmif/ESM_InverseFold_Additional.rst
66
- docs/model-docs/esmif/index.rst
67
- docs/model-docs/finetuning/index.rst
68
- docs/model-docs/img/book_icon.png
69
- docs/model-docs/img/esmfold_perf.png
70
- docs/model-docs/progen2/ProGen2_API.rst
71
- docs/model-docs/progen2/ProGen2_Additional.rst
72
- docs/model-docs/progen2/index.rst
73
- docs/model-docs/proteinfer/ProteInfer_API.rst
74
- docs/model-docs/proteinfer/ProteInfer_Additional.rst
75
- docs/model-docs/proteinfer/index.rst
76
- docs/model-docs/protgpt2/ProtGPT2.rst
77
- docs/model-docs/protgpt2/generator_ft.rst
78
- docs/model-docs/protgpt2/index.rst
79
45
  docs/python-client/api_biolm.rst
80
46
  docs/python-client/api_client.rst
81
47
  docs/python-client/async_sync.rst
@@ -61,7 +61,7 @@ author = "Nikhil Haas"
61
61
  # the built documents.
62
62
  #
63
63
  # The short X.Y version.
64
- version = '0.2.3'
64
+ version = '0.2.5'
65
65
  # The full version, including alpha/beta/rc tags.
66
66
  release = version
67
67
 
@@ -80,6 +80,9 @@ exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
80
80
  # The name of the Pygments (syntax highlighting) style to use.
81
81
  pygments_style = "sphinx"
82
82
 
83
+ # Dark mode syntax highlighting (Furo-specific)
84
+ pygments_dark_style = "material"
85
+
83
86
  # If true, `todo` and `todoList` produce output, else they produce nothing.
84
87
  todo_include_todos = False
85
88
 
@@ -98,8 +101,58 @@ html_theme = "furo"
98
101
  html_theme_options = {
99
102
  "top_of_page_button": None,
100
103
  "sidebar_hide_name": True,
101
- "light_logo": "biolm_logomark_transparent.png",
102
- "dark_logo": "biolm_logomark_transparent_for_dark.png",
104
+ "light_logo": "biolm_logo_light.svg",
105
+ "dark_logo": "biolm_logo_dark.svg",
106
+
107
+ # Custom CSS variables for branding
108
+ "light_css_variables": {
109
+ # Primary brand colors - replace with your website's brand colors
110
+ "color-brand-primary": "#2563eb", # Replace with your main brand color
111
+ "color-brand-content": "#2563eb", # Links and interactive elements
112
+
113
+ # Sidebar customization
114
+ "color-sidebar-brand-text": "#1f2937",
115
+ "color-sidebar-background": "#f8fafc",
116
+ "color-sidebar-background-border": "#e2e8f0",
117
+
118
+ # Additional brand colors
119
+ "color-admonition-title-background--note": "#dbeafe",
120
+ "color-admonition-title--note": "#1e40af",
121
+
122
+ # Header and navigation
123
+ "color-header-background": "#ffffff",
124
+ "color-header-text": "#1f2937",
125
+
126
+ # Code blocks
127
+ "color-code-background": "#f1f5f9",
128
+ "color-code-foreground": "#334155",
129
+
130
+ # Font families to match your website exactly
131
+ "font-stack": '"Inter", ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',
132
+ "font-stack--monospace": '"Roboto Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',
133
+ },
134
+
135
+ "dark_css_variables": {
136
+ # Dark mode brand colors
137
+ "color-brand-primary": "#60a5fa", # Lighter version for dark mode
138
+ "color-brand-content": "#60a5fa",
139
+
140
+ # Dark sidebar
141
+ "color-sidebar-background": "#1e293b",
142
+ "color-sidebar-background-border": "#334155",
143
+ "color-sidebar-brand-text": "#f1f5f9",
144
+
145
+ # Dark mode code blocks
146
+ "color-code-background": "#1e293b",
147
+ "color-code-foreground": "#e2e8f0",
148
+
149
+ # Additional dark mode styling
150
+ "color-highlight-on-target": "#374151",
151
+
152
+ # Font families to match your website exactly (same as light mode)
153
+ "font-stack": '"Inter", ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',
154
+ "font-stack--monospace": '"Roboto Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',
155
+ },
103
156
  }
104
157
 
105
158
  # Add any paths that contain custom static files (such as style sheets) here,
@@ -107,6 +160,53 @@ html_theme_options = {
107
160
  # so a file named "default.css" will overwrite the builtin "default.css".
108
161
  html_static_path = ["_static"]
109
162
 
163
+ # Custom CSS files
164
+ html_css_files = [
165
+ 'custom.css',
166
+ ]
167
+
168
+ # Add Google Fonts (Inter and Roboto Mono to match website)
169
+ html_css_files.extend([
170
+ 'https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap',
171
+ 'https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@300;400;500;600;700&display=swap',
172
+ ])
173
+
174
+ # Additional branding options
175
+ html_title = "BioLM AI Documentation"
176
+ html_short_title = "BioLM AI"
177
+
178
+ # Custom favicon (add your favicon.ico to _static folder)
179
+ # html_favicon = "_static/favicon.ico"
180
+
181
+ # Custom footer
182
+ html_show_sphinx = False
183
+ html_show_copyright = True
184
+
185
+ # SEO and metadata
186
+ html_meta = {
187
+ "description": "Official documentation for BioLM AI - Advanced biological language models and APIs",
188
+ "keywords": "BioLM, AI, machine learning, biology, protein, DNA, API",
189
+ "author": "BioLM.ai Team",
190
+ "viewport": "width=device-width, initial-scale=1",
191
+ }
192
+
193
+ # Social media cards / Open Graph
194
+ html_theme_options.update({
195
+ "announcement": None, # Add site-wide announcements here if needed
196
+ "footer_icons": [
197
+ {
198
+ "name": "GitHub",
199
+ "url": "https://github.com/yourusername/yourrepo", # Update with your GitHub
200
+ "html": """
201
+ <svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 16 16">
202
+ <path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path>
203
+ </svg>
204
+ """,
205
+ "class": "",
206
+ },
207
+ ],
208
+ })
209
+
110
210
 
111
211
  # -- Options for HTMLHelp output ---------------------------------------
112
212
 
@@ -45,20 +45,4 @@ Welcome to Our Python Client Docs
45
45
 
46
46
  tutorials_use_cases/notebooks
47
47
 
48
- .. toctree::
49
- :maxdepth: 2
50
- :caption: Documentation:
51
- :hidden:
52
-
53
- model-docs/esm2/index
54
- model-docs/esm1v/index
55
- model-docs/esmfold/index
56
- model-docs/esmif/index
57
- model-docs/biolmtox/index
58
- model-docs/progen2/index
59
- model-docs/ablang/index
60
- model-docs/proteinfer/index
61
- model-docs/protgpt2/index
62
- model-docs/dnabert/index
63
- model-docs/finetuning/index
64
48
 
@@ -34,13 +34,13 @@ A universal, high-level client for the BioLM API. Instantiating this class immed
34
34
  .. code-block:: python
35
35
 
36
36
  # ESM2-8M: encode a single sequence
37
- result = BioLM(entity="esm2-8m", action="encode", type="sequence", items="MSILVTRPSPAGEEL")
37
+ result = biolm(entity="esm2-8m", action="encode", type="sequence", items="MSILVTRPSPAGEEL")
38
38
 
39
39
  # ESMFold: predict structure for a batch
40
- result = BioLM(entity="esmfold", action="predict", type="sequence", items=["MDNELE", "MENDEL"])
40
+ result = biolm(entity="esmfold", action="predict", type="sequence", items=["MDNELE", "MENDEL"])
41
41
 
42
42
  # ProGen2-OAS: generate new sequences
43
- result = BioLM(
43
+ result = biolm(
44
44
  entity="progen2-oas",
45
45
  action="generate",
46
46
  type="context",