biolmai 0.1.10__tar.gz → 0.2.3__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 (113) hide show
  1. {biolmai-0.1.10 → biolmai-0.2.3}/PKG-INFO +23 -18
  2. {biolmai-0.1.10 → biolmai-0.2.3}/biolmai/__init__.py +3 -1
  3. {biolmai-0.1.10 → biolmai-0.2.3}/biolmai/api.py +6 -2
  4. biolmai-0.2.3/biolmai/biolmai.py +121 -0
  5. biolmai-0.2.3/biolmai/client.py +699 -0
  6. {biolmai-0.1.10 → biolmai-0.2.3}/biolmai.egg-info/PKG-INFO +23 -18
  7. {biolmai-0.1.10 → biolmai-0.2.3}/biolmai.egg-info/SOURCES.txt +25 -4
  8. biolmai-0.2.3/biolmai.egg-info/requires.txt +14 -0
  9. biolmai-0.2.3/docs/_static/biolm_logomark_transparent.png +0 -0
  10. biolmai-0.2.3/docs/_static/biolm_logomark_transparent_for_dark.png +0 -0
  11. {biolmai-0.1.10 → biolmai-0.2.3}/docs/biolmai.rst +8 -0
  12. {biolmai-0.1.10 → biolmai-0.2.3}/docs/conf.py +29 -3
  13. biolmai-0.2.3/docs/index.rst +64 -0
  14. biolmai-0.2.3/docs/python-client/api_biolm.rst +49 -0
  15. biolmai-0.2.3/docs/python-client/api_client.rst +74 -0
  16. biolmai-0.2.3/docs/python-client/async_sync.rst +157 -0
  17. biolmai-0.2.3/docs/python-client/batching.rst +187 -0
  18. biolmai-0.2.3/docs/python-client/disk_output.rst +66 -0
  19. biolmai-0.2.3/docs/python-client/error_handling.rst +146 -0
  20. biolmai-0.2.3/docs/python-client/faq.rst +38 -0
  21. biolmai-0.2.3/docs/python-client/features.rst +22 -0
  22. biolmai-0.2.3/docs/python-client/index.rst +29 -0
  23. biolmai-0.2.3/docs/python-client/overview.rst +18 -0
  24. biolmai-0.2.3/docs/python-client/quickstart.rst +28 -0
  25. biolmai-0.2.3/docs/python-client/rate_limiting.rst +97 -0
  26. biolmai-0.2.3/docs/python-client/usage.rst +84 -0
  27. biolmai-0.2.3/pyproject.toml +93 -0
  28. {biolmai-0.1.10 → biolmai-0.2.3}/setup.cfg +5 -1
  29. {biolmai-0.1.10 → biolmai-0.2.3}/setup.py +20 -11
  30. biolmai-0.2.3/tests/test_abatch_calls.py +208 -0
  31. biolmai-0.2.3/tests/test_aclient.py +224 -0
  32. biolmai-0.2.3/tests/test_batch_error_retry.py +80 -0
  33. biolmai-0.2.3/tests/test_batch_errors.py +47 -0
  34. biolmai-0.2.3/tests/test_biolmai.py +201 -0
  35. biolmai-0.2.3/tests/test_client.py +218 -0
  36. biolmai-0.2.3/tests/test_max_items.py +183 -0
  37. biolmai-0.2.3/tests/test_rate_limit.py +182 -0
  38. biolmai-0.2.3/tests/test_schemas.py +30 -0
  39. biolmai-0.1.10/biolmai/biolmai.py +0 -5
  40. biolmai-0.1.10/biolmai.egg-info/requires.txt +0 -7
  41. biolmai-0.1.10/docs/index.rst +0 -110
  42. biolmai-0.1.10/docs/python-client/get_started/quickstart.rst +0 -25
  43. biolmai-0.1.10/docs/python-client/index.rst +0 -18
  44. biolmai-0.1.10/docs/python-client/usage.rst +0 -7
  45. biolmai-0.1.10/pyproject.toml +0 -44
  46. biolmai-0.1.10/tests/test_biolmai.py +0 -498
  47. {biolmai-0.1.10 → biolmai-0.2.3}/AUTHORS.rst +0 -0
  48. {biolmai-0.1.10 → biolmai-0.2.3}/CONTRIBUTING.rst +0 -0
  49. {biolmai-0.1.10 → biolmai-0.2.3}/HISTORY.rst +0 -0
  50. {biolmai-0.1.10 → biolmai-0.2.3}/LICENSE +0 -0
  51. {biolmai-0.1.10 → biolmai-0.2.3}/MANIFEST.in +0 -0
  52. {biolmai-0.1.10 → biolmai-0.2.3}/README.rst +0 -0
  53. {biolmai-0.1.10 → biolmai-0.2.3}/biolmai/asynch.py +0 -0
  54. {biolmai-0.1.10 → biolmai-0.2.3}/biolmai/auth.py +0 -0
  55. {biolmai-0.1.10 → biolmai-0.2.3}/biolmai/cli.py +0 -0
  56. {biolmai-0.1.10 → biolmai-0.2.3}/biolmai/cls.py +0 -0
  57. {biolmai-0.1.10 → biolmai-0.2.3}/biolmai/const.py +0 -0
  58. {biolmai-0.1.10 → biolmai-0.2.3}/biolmai/ltc.py +0 -0
  59. {biolmai-0.1.10 → biolmai-0.2.3}/biolmai/payloads.py +0 -0
  60. {biolmai-0.1.10 → biolmai-0.2.3}/biolmai/validate.py +0 -0
  61. {biolmai-0.1.10 → biolmai-0.2.3}/biolmai.egg-info/dependency_links.txt +0 -0
  62. {biolmai-0.1.10 → biolmai-0.2.3}/biolmai.egg-info/entry_points.txt +0 -0
  63. {biolmai-0.1.10 → biolmai-0.2.3}/biolmai.egg-info/not-zip-safe +0 -0
  64. {biolmai-0.1.10 → biolmai-0.2.3}/biolmai.egg-info/top_level.txt +0 -0
  65. {biolmai-0.1.10 → biolmai-0.2.3}/docs/Makefile +0 -0
  66. {biolmai-0.1.10 → biolmai-0.2.3}/docs/_static/api_reference_icon.png +0 -0
  67. {biolmai-0.1.10 → biolmai-0.2.3}/docs/_static/biolm_docs_logo_dark.png +0 -0
  68. {biolmai-0.1.10 → biolmai-0.2.3}/docs/_static/biolm_docs_logo_light.png +0 -0
  69. {biolmai-0.1.10 → biolmai-0.2.3}/docs/_static/chat_agents_icon.png +0 -0
  70. {biolmai-0.1.10 → biolmai-0.2.3}/docs/_static/jupyter_notebooks_icon.png +0 -0
  71. {biolmai-0.1.10 → biolmai-0.2.3}/docs/_static/model_docs_icon.png +0 -0
  72. {biolmai-0.1.10 → biolmai-0.2.3}/docs/_static/python_sdk_icon.png +0 -0
  73. {biolmai-0.1.10 → biolmai-0.2.3}/docs/_static/tutorials_icon.png +0 -0
  74. {biolmai-0.1.10 → biolmai-0.2.3}/docs/make.bat +0 -0
  75. {biolmai-0.1.10 → biolmai-0.2.3}/docs/model-docs/ablang/AbLang_API.rst +0 -0
  76. {biolmai-0.1.10 → biolmai-0.2.3}/docs/model-docs/ablang/AbLang_Additional.rst +0 -0
  77. {biolmai-0.1.10 → biolmai-0.2.3}/docs/model-docs/ablang/index.rst +0 -0
  78. {biolmai-0.1.10 → biolmai-0.2.3}/docs/model-docs/biolmtox/BioLMTox_API.rst +0 -0
  79. {biolmai-0.1.10 → biolmai-0.2.3}/docs/model-docs/biolmtox/BioLMTox_Additional.rst +0 -0
  80. {biolmai-0.1.10 → biolmai-0.2.3}/docs/model-docs/biolmtox/index.rst +0 -0
  81. {biolmai-0.1.10 → biolmai-0.2.3}/docs/model-docs/dnabert/DNABERT_Additional.rst +0 -0
  82. {biolmai-0.1.10 → biolmai-0.2.3}/docs/model-docs/dnabert/classifier_ft.rst +0 -0
  83. {biolmai-0.1.10 → biolmai-0.2.3}/docs/model-docs/dnabert/index.rst +0 -0
  84. {biolmai-0.1.10 → biolmai-0.2.3}/docs/model-docs/esm1v/ESM-1v_API.rst +0 -0
  85. {biolmai-0.1.10 → biolmai-0.2.3}/docs/model-docs/esm1v/ESM-1v_Additional.rst +0 -0
  86. {biolmai-0.1.10 → biolmai-0.2.3}/docs/model-docs/esm1v/index.rst +0 -0
  87. {biolmai-0.1.10 → biolmai-0.2.3}/docs/model-docs/esm2/ESM2_API.rst +0 -0
  88. {biolmai-0.1.10 → biolmai-0.2.3}/docs/model-docs/esm2/ESM2_Additional.rst +0 -0
  89. {biolmai-0.1.10 → biolmai-0.2.3}/docs/model-docs/esm2/index.rst +0 -0
  90. {biolmai-0.1.10 → biolmai-0.2.3}/docs/model-docs/esmfold/ESMFold_API.rst +0 -0
  91. {biolmai-0.1.10 → biolmai-0.2.3}/docs/model-docs/esmfold/ESMFold_Additional.rst +0 -0
  92. {biolmai-0.1.10 → biolmai-0.2.3}/docs/model-docs/esmfold/index.rst +0 -0
  93. {biolmai-0.1.10 → biolmai-0.2.3}/docs/model-docs/esmif/ESM_InverseFold_API.rst +0 -0
  94. {biolmai-0.1.10 → biolmai-0.2.3}/docs/model-docs/esmif/ESM_InverseFold_Additional.rst +0 -0
  95. {biolmai-0.1.10 → biolmai-0.2.3}/docs/model-docs/esmif/index.rst +0 -0
  96. {biolmai-0.1.10 → biolmai-0.2.3}/docs/model-docs/finetuning/index.rst +0 -0
  97. {biolmai-0.1.10 → biolmai-0.2.3}/docs/model-docs/img/book_icon.png +0 -0
  98. {biolmai-0.1.10 → biolmai-0.2.3}/docs/model-docs/img/esmfold_perf.png +0 -0
  99. {biolmai-0.1.10 → biolmai-0.2.3}/docs/model-docs/index.rst +0 -0
  100. {biolmai-0.1.10 → biolmai-0.2.3}/docs/model-docs/progen2/ProGen2_API.rst +0 -0
  101. {biolmai-0.1.10 → biolmai-0.2.3}/docs/model-docs/progen2/ProGen2_Additional.rst +0 -0
  102. {biolmai-0.1.10 → biolmai-0.2.3}/docs/model-docs/progen2/index.rst +0 -0
  103. {biolmai-0.1.10 → biolmai-0.2.3}/docs/model-docs/proteinfer/ProteInfer_API.rst +0 -0
  104. {biolmai-0.1.10 → biolmai-0.2.3}/docs/model-docs/proteinfer/ProteInfer_Additional.rst +0 -0
  105. {biolmai-0.1.10 → biolmai-0.2.3}/docs/model-docs/proteinfer/index.rst +0 -0
  106. {biolmai-0.1.10 → biolmai-0.2.3}/docs/model-docs/protgpt2/ProtGPT2.rst +0 -0
  107. {biolmai-0.1.10 → biolmai-0.2.3}/docs/model-docs/protgpt2/generator_ft.rst +0 -0
  108. {biolmai-0.1.10 → biolmai-0.2.3}/docs/model-docs/protgpt2/index.rst +0 -0
  109. {biolmai-0.1.10 → biolmai-0.2.3}/docs/modules.rst +0 -0
  110. {biolmai-0.1.10/docs/python-client/get_started → biolmai-0.2.3/docs/python-client}/authentication.rst +0 -0
  111. {biolmai-0.1.10/docs/python-client/get_started → biolmai-0.2.3/docs/python-client}/installation.rst +0 -0
  112. {biolmai-0.1.10 → biolmai-0.2.3}/docs/tutorials_use_cases/notebooks.rst +0 -0
  113. {biolmai-0.1.10 → biolmai-0.2.3}/tests/__init__.py +0 -0
@@ -1,10 +1,10 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: biolmai
3
- Version: 0.1.10
4
- Summary: Python client and SDK for https://biolm.ai
3
+ Version: 0.2.3
4
+ Summary: BioLM Python client
5
5
  Home-page: https://github.com/BioLM/py-biolm
6
- Author: Nikhil Haas
7
- Author-email: nhaas@biolm.ai
6
+ Author: BioLM
7
+ Author-email: BioLM <support@biolm.ai>
8
8
  License: Apache Software License 2.0
9
9
  Keywords: biolmai
10
10
  Classifier: Development Status :: 2 - Pre-Alpha
@@ -12,15 +12,30 @@ Classifier: Intended Audience :: Developers
12
12
  Classifier: License :: OSI Approved :: Apache Software License
13
13
  Classifier: Natural Language :: English
14
14
  Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3.7
16
15
  Classifier: Programming Language :: Python :: 3.8
17
16
  Classifier: Programming Language :: Python :: 3.9
18
17
  Classifier: Programming Language :: Python :: 3.10
19
18
  Classifier: Programming Language :: Python :: 3.11
20
- Requires-Python: >=3.6
21
- Provides-Extra: aiodns
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
22
23
  License-File: LICENSE
23
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
24
39
 
25
40
  ========
26
41
  BioLM AI
@@ -59,13 +74,3 @@ This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypack
59
74
 
60
75
  .. _Cookiecutter: https://github.com/audreyr/cookiecutter
61
76
  .. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
62
-
63
-
64
- =======
65
- History
66
- =======
67
-
68
- 0.1.0 (2023-09-04)
69
- ------------------
70
-
71
- * First release on PyPI.
@@ -1,8 +1,10 @@
1
1
  """Top-level package for BioLM AI."""
2
2
  __author__ = """Nikhil Haas"""
3
3
  __email__ = "nikhil@biolm.ai"
4
- __version__ = '0.1.10'
4
+ __version__ = '0.2.3'
5
5
 
6
6
  from biolmai.cls import *
7
+ from biolmai.client import BioLMApi, BioLMApiClient
8
+ from biolmai.biolmai import BioLM
7
9
 
8
10
  __all__ = []
@@ -4,8 +4,12 @@ import inspect
4
4
  import time
5
5
  from functools import lru_cache
6
6
 
7
- import numpy as np
8
- import pandas as pd
7
+ try:
8
+ import numpy as np
9
+ import pandas as pd
10
+ except ImportError:
11
+ pass
12
+
9
13
  import requests
10
14
  from requests.adapters import HTTPAdapter
11
15
  from requests.packages.urllib3.util.retry import Retry
@@ -0,0 +1,121 @@
1
+ """Main module."""
2
+ import logging
3
+
4
+ log = logging.getLogger("biolm_util")
5
+
6
+ from typing import Optional, Union, List, Any
7
+ from biolmai.client import BioLMApi, is_list_of_lists
8
+
9
+
10
+ class BioLM:
11
+ """
12
+ Universal client for BioLM API.
13
+
14
+ Args:
15
+ entity (str): The entity name (model, database, calculation, etc).
16
+ action (str): The action to perform (e.g., 'generate', 'encode', 'predict', 'search', 'finetune').
17
+ type (str): The type of item (e.g., 'sequence', 'pdb', 'fasta_str').
18
+ item (Union[Any, List[Any]]): The item(s) to process.
19
+ params (Optional[dict]): Optional parameters for the action.
20
+ raise_httpx (bool): Whether to raise HTTPX errors.
21
+ stop_on_error (bool): Stop on first error if True.
22
+ output (str): 'memory' or 'disk'.
23
+ file_path (Optional[str]): Output file path if output='disk'.
24
+ api_key (Optional[str]): API key for authentication.
25
+ """
26
+ def __new__(
27
+ cls,
28
+ *,
29
+ entity: str,
30
+ action: str,
31
+ type: Optional[str] = None,
32
+ items: Union[Any, List[Any]],
33
+ params: Optional[dict] = None,
34
+ api_key: Optional[str] = None,
35
+ **kwargs
36
+ ):
37
+ self = super().__new__(cls)
38
+ self.entity = entity
39
+ self.action = action
40
+ self.type = type
41
+ self.items = items
42
+ self.params = params
43
+ self.api_key = api_key
44
+ self._class_kwargs = kwargs
45
+ return self.run()
46
+
47
+ def run(self) -> Any:
48
+ """
49
+ Run the specified action on the entity with the given item(s).
50
+ Returns the result(s), unpacked if a single item was provided.
51
+ """
52
+ # if not self.items:
53
+ # return self.items
54
+
55
+ # Always pass a list of items to BioLMModel
56
+ if isinstance(self.items, list):
57
+ items = self.items
58
+ else:
59
+ items = [self.items]
60
+
61
+ is_lol, first_n, rest_iter = is_list_of_lists(items, check_n=10)
62
+ if is_lol:
63
+ for batch in first_n:
64
+ if not all(isinstance(x, dict) for x in batch):
65
+ raise ValueError("All items in each batch must be dicts when passing a list of lists.")
66
+ if self.type is not None:
67
+ raise ValueError("Do not specify `type` when passing a list of lists of dicts for `items`.")
68
+ items_dicts = list(first_n) + list(rest_iter)
69
+ elif all(isinstance(v, dict) for v in items):
70
+ items_dicts = items
71
+ else:
72
+ if self.type is None:
73
+ raise ValueError("If `items` are not dicts, `type` must be specified.")
74
+ items_dicts = [{self.type: v} for v in items]
75
+
76
+ unwrap_single = self._class_kwargs.pop('unwrap_single', True)
77
+
78
+ # Instantiate BioLMModel with correct settings
79
+ # Need these for the `action` method on BioLMApi; other kwargs to BioLMApi init
80
+ action_kwargs = {k: v for k, v in dict(
81
+ stop_on_error=self._class_kwargs.pop('stop_on_error', None),
82
+ output=self._class_kwargs.pop('output', None),
83
+ file_path=self._class_kwargs.pop('file_path', None),
84
+ ).items() if v is not None}
85
+
86
+ model = BioLMApi(
87
+ self.entity,
88
+ api_key=self.api_key,
89
+ unwrap_single=unwrap_single,
90
+ **self._class_kwargs,
91
+ )
92
+
93
+ # Map action to method
94
+ action_map = {
95
+ 'generate': model.generate,
96
+ 'predict': model.predict,
97
+ 'encode': model.encode,
98
+ 'search': getattr(model, 'search', None),
99
+ 'finetune': getattr(model, 'finetune', None),
100
+ 'lookup': model.lookup,
101
+ }
102
+ if self.action not in action_map or action_map[self.action] is None:
103
+ raise ValueError(f"Action '{self.action}' is not amongst the available actions {', '.join(action_map.keys())}.")
104
+
105
+ # Prepare kwargs for the method
106
+ method = action_map[self.action]
107
+ kwargs = {
108
+ 'items': items_dicts,
109
+ 'params': self.params,
110
+ }
111
+ kwargs.update(action_kwargs)
112
+ # Remove None values
113
+ kwargs = {k: v for k, v in kwargs.items() if v is not None}
114
+
115
+ # Call the method
116
+ result = method(**kwargs)
117
+
118
+ return result
119
+
120
+ # Example usage:
121
+ # result = BioLM(entity="esmfold", action="predict", type="sequence", item="MKT...").run()