Skip to content

Commit da7a7ef

Browse files
committed
Updates the installation from dev to master
1 parent c5e405d commit da7a7ef

File tree

7 files changed

+50
-68
lines changed

7 files changed

+50
-68
lines changed

docs/protein-optimization/contributing/a_new_problem.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ dependencies:
138138
- pip
139139
- pip:
140140
- numpy
141-
- "git+https://github.com/MachineLearningLifeScience/poli.git"
141+
- "git+https://github.com/MachineLearningLifeScience/poli.git@master"
142142
- YOUR OTHER DEPENDENCIES
143143
```
144144
@@ -162,7 +162,7 @@ dependencies:
162162
- pip:
163163
- numpy
164164
- click
165-
- "git+https://github.com/MachineLearningLifeScience/poli.git"
165+
- "git+https://github.com/MachineLearningLifeScience/poli.git@master"
166166
167167
```
168168

docs/protein-optimization/getting_started/getting_started.md

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ If you are not interested in debugging, you can simply run
3939

4040
```bash
4141
# in the poli-base env
42-
pip install git+https://github.com/MachineLearningLifeScience/poli.git
42+
pip install git+https://github.com/MachineLearningLifeScience/poli.git@master
4343
```
4444

4545
:::
@@ -55,6 +55,8 @@ $ cd ./poli
5555
$ pip install -e .
5656
```
5757

58+
A stable version can be found on the `master` branch, the bleeding-edge is on `dev`.
59+
5860
:::
5961

6062
::::
@@ -71,10 +73,9 @@ To make sure everything went well, you can test your `poli` installation by runn
7173

7274
```bash
7375
$ python -c "from poli.core.registry import get_problems ; print(get_problems())"
74-
[]
76+
['aloha', 'white_noise']
7577
```
76-
77-
If the installation isn't fresh/the only one in your system, you might actually get some registered problems.
78+
In general: **all problems available will appear**. These two (`aloha` and `white_noise`) are available by default since their only requirements are `numpy` and `poli`. If the installation isn't fresh/the only one in your system, you might actually get more problems.
7879

7980
## Running `poli` on Colab
8081

@@ -83,12 +84,7 @@ With a little effort, you can run `poli` on Colab. [Check this example](https://
8384

8485
## Your first `poli` script
8586

86-
As you might have noticed, you can get a list of the registered problems using the `get_problems` method inside `poli.core.registry`. You can also get a list of objective functions available for installing/registration using `from poli.objective_repository import AVAILABLE_OBJECTIVES`:
87-
88-
```bash
89-
$ python -c "from poli.objective_repository import AVAILABLE_OBJECTIVES ; print(AVAILABLE_OBJECTIVES)"
90-
[..., 'white_noise']
91-
```
87+
As you might have noticed, you can get a list of the registered problems using the `get_problems` method inside `poli.core.registry`.
9288

9389
Let's write a small script that installs `white_noise` from the repository:
9490

@@ -104,13 +100,9 @@ for _ in range(5):
104100
print(f"f(x) = {f(x)}")
105101
```
106102

107-
If we run this script, `poli` will ask us to confirm that we want to register/install `"white_noise"` as an objective function (you can deactivate this confirmation step by passing the flag `force_register=True` to `.create`). Afterwards, it will print 5 evaluations of the objective function on the same input.
103+
If we run this script, it will print 5 evaluations of the objective function on the same input.
108104

109-
:::{warning}
110-
111-
In the registration process, `poli` creates a `conda` environment, and **executes a shell script**. Be wary of objective functions you find in the wild.
112-
113-
:::
105+
`white_noise` is a trivial example. We include plenty of examples on how to register objective functions that are more complex, including e.g. [computing the Quantitative Estimate of Druglikeness of a small molecule](../using_poli/objective_repository/rdkit_qed.md) or, if you have the `foldx` simulator installed, [how to compute the stability of a protein given a `.pdb` file](../using_poli/optimization_examples/protein-stability-foldx/optimizing_protein_stability.ipynb).
114106

115107
## Conclusion
116108

docs/protein-optimization/understanding_foldx/01-single-mutation-using-foldx/index.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@
899899
"name": "python",
900900
"nbconvert_exporter": "python",
901901
"pygments_lexer": "ipython3",
902-
"version": "3.9.16"
902+
"version": "3.9.17"
903903
},
904904
"orig_nbformat": 4
905905
},

docs/protein-optimization/using_poli/objective_repository/rdkit_logp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ problem_info, f, x0, y0, run_info = objective_factory.create(
5656
x = np.array([[1]])
5757

5858
# Querying:
59-
print(f(x)) # Should be close to 0.35978
59+
print(f(x)) # Should be close to 0.6361
6060
```
6161

6262
:::

docs/protein-optimization/using_poli/the_basics/intro_to_poli.ipynb

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,13 @@
6060
{
6161
"cell_type": "code",
6262
"execution_count": 1,
63-
"metadata": {
64-
"vscode": {
65-
"languageId": "plaintext"
66-
}
67-
},
63+
"metadata": {},
6864
"outputs": [
6965
{
7066
"name": "stdout",
7167
"output_type": "stream",
7268
"text": [
73-
"['white_noise']\n"
69+
"['aloha', 'white_noise']\n"
7470
]
7571
}
7672
],
@@ -83,7 +79,7 @@
8379
"cell_type": "markdown",
8480
"metadata": {},
8581
"source": [
86-
"The output is a list of registered problems. If the function that you're interested in is not registered, you can check whether we have it in `poli`'s internal repository:"
82+
"The output is a list of problems you can run without installing anything further. If the function that you're interested in is not in this list, you can check whether we have it in `poli`'s internal repository:"
8783
]
8884
},
8985
{
@@ -95,20 +91,21 @@
9591
"name": "stdout",
9692
"output_type": "stream",
9793
"text": [
98-
"['aloha', 'super_mario_bros', 'white_noise']\n"
94+
"['aloha', 'foldx_rfp_lambo', 'foldx_sasa', 'foldx_stability', 'foldx_stability_and_sasa', 'rdkit_logp', 'rdkit_qed', 'super_mario_bros', 'white_noise']\n"
9995
]
10096
}
10197
],
10298
"source": [
103-
"from poli.objective_repository import AVAILABLE_OBJECTIVES\n",
104-
"print(AVAILABLE_OBJECTIVES)"
99+
"print(get_problems(include_repository=True))"
105100
]
106101
},
107102
{
108103
"cell_type": "markdown",
109104
"metadata": {},
110105
"source": [
111-
"If the function isn't there, **implement it yourself!** An example of how to do this can be found in `poli_baselines/examples/00_a_simple_objective_function_registration`, or in our chapter on [registering optimization functions](./registering_an_objective_function.md).\n",
106+
"Each one of these objective functions can be run without modifying your environment, but you might need to check their prerequisites. We do our best to keep the list updated in [the introduction page](../../index.md), where you can find links to the requirements and installation descriptions for each one of these.\n",
107+
"\n",
108+
"If the function still isn't there, **implement it yourself!** An example of how to do this can be found in `poli_baselines/examples/00_a_simple_objective_function_registration`, or in our chapter on [registering optimization functions](./registering_an_objective_function.md).\n",
112109
"\n",
113110
"In what follows, we will use the `white_noise` objective function. You could drop-in your own function if desired."
114111
]
@@ -121,10 +118,7 @@
121118
"source": [
122119
"from poli import objective_factory\n",
123120
"\n",
124-
"problem_info, f, x0, y0, _ = objective_factory.create(\n",
125-
" name=\"white_noise\",\n",
126-
" force_register=True,\n",
127-
")"
121+
"problem_info, f, x0, y0, _ = objective_factory.create(name=\"white_noise\")"
128122
]
129123
},
130124
{
@@ -152,15 +146,15 @@
152146
},
153147
{
154148
"cell_type": "code",
155-
"execution_count": 13,
149+
"execution_count": 5,
156150
"metadata": {},
157151
"outputs": [
158152
{
159153
"name": "stdout",
160154
"output_type": "stream",
161155
"text": [
162156
"x0: [['1' '2' '3']]\n",
163-
"y0: [[1.58015034]]\n"
157+
"y0: [[-0.12847371]]\n"
164158
]
165159
}
166160
],
@@ -187,23 +181,23 @@
187181
},
188182
{
189183
"cell_type": "code",
190-
"execution_count": 14,
184+
"execution_count": 6,
191185
"metadata": {},
192186
"outputs": [
193187
{
194188
"name": "stdout",
195189
"output_type": "stream",
196190
"text": [
197-
"{'x': [array([['1', '2', '3']], dtype='<U1')], 'y': [array([[1.58015034]])]}\n"
191+
"{'x': [array([['1', '2', '3']], dtype='<U1')], 'y': [array([[-0.12847371]])]}\n"
198192
]
199193
},
200194
{
201195
"data": {
202196
"text/plain": [
203-
"array([['1', '3', '3']], dtype='<U1')"
197+
"array([['1', '8', '3']], dtype='<U1')"
204198
]
205199
},
206-
"execution_count": 14,
200+
"execution_count": 6,
207201
"metadata": {},
208202
"output_type": "execute_result"
209203
}
@@ -222,25 +216,16 @@
222216
},
223217
{
224218
"cell_type": "code",
225-
"execution_count": null,
219+
"execution_count": 7,
226220
"metadata": {},
227221
"outputs": [
228222
{
229223
"data": {
230224
"text/plain": [
231-
"{'0': 0,\n",
232-
" '1': 1,\n",
233-
" '2': 2,\n",
234-
" '3': 3,\n",
235-
" '4': 4,\n",
236-
" '5': 5,\n",
237-
" '6': 6,\n",
238-
" '7': 7,\n",
239-
" '8': 8,\n",
240-
" '9': 9}"
225+
"['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']"
241226
]
242227
},
243-
"execution_count": 16,
228+
"execution_count": 7,
244229
"metadata": {},
245230
"output_type": "execute_result"
246231
}
@@ -272,7 +257,7 @@
272257
},
273258
{
274259
"cell_type": "code",
275-
"execution_count": 19,
260+
"execution_count": 8,
276261
"metadata": {},
277262
"outputs": [],
278263
"source": [
@@ -281,14 +266,14 @@
281266
},
282267
{
283268
"cell_type": "code",
284-
"execution_count": 20,
269+
"execution_count": 9,
285270
"metadata": {},
286271
"outputs": [
287272
{
288273
"name": "stdout",
289274
"output_type": "stream",
290275
"text": [
291-
"[['0' '2' '3']]\n"
276+
"[['0' '2' '8']]\n"
292277
]
293278
}
294279
],

docs/protein-optimization/using_poli/the_basics/optimizing_an_objective_function.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ By the end, you should have registered the `aloha` problem.
1919

2020
## Is aloha registered?
2121

22-
We can start by checking that the `aloha` problem is indeed among the registered objectives:
22+
We can start by checking that the `aloha` problem is indeed among the available objectives:
2323

2424
```python
2525
# optimizing_aloha.py
@@ -34,7 +34,7 @@ This script should run without raising any problems.
3434
:::{admonition} Is aloha not registered?
3535
:class: dropdown
3636

37-
If the past snippet fails and raises an `AssertionError`, then it's likely you haven't registered `aloha` as a problem. Check [the first chapter for the process of registering this problem](./registering_an_objective_function.md).
37+
If the past snippet fails and raises an `AssertionError`, then it's likely you haven't registered `aloha` as a problem, or that you don't have `numpy` installed. Check [the first chapter for the process of registering this problem](./registering_an_objective_function.md).
3838

3939
:::
4040

@@ -74,9 +74,10 @@ Once instantiated, the solver can optimize our `aloha` problem easily:
7474
```python
7575
# optimizing_aloha.py
7676

77+
# What we discuss above
7778
...
7879

79-
if __name__ == "__main__"
80+
if __name__ == "__main__":
8081
...
8182

8283
# Running the optimization for 1000 steps,

docs/protein-optimization/using_poli/the_basics/registering_an_objective_function.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
```{contents}
44
```
55

6-
With `poli`, you can define and register black box objective functions. This page shows you how. For the entire script, check [`registering_aloha.py` TODO:ADD]() in the examples.
6+
With `poli`, you can define and register black box objective functions. This page shows you how. For the entire script, check [`registering_aloha.py`](https://github.com/MachineLearningLifeScience/poli/blob/master/examples/a_simple_objective_function_registration/registering_aloha.py) in the examples of `poli`.
77

88
## An example of a discrete black box function
99

@@ -48,9 +48,7 @@ class AlohaBlackBox(AbstractBlackBox):
4848
return np.sum(matches, axis=1, keepdims=True)
4949
```
5050

51-
As the code says, the only method you need to define is `_black_box(x: np.ndarray, context: dict = None)`, returning a numpy array of size `[1, 1]`. `AbstractBlackBox` takes it from there, making sure that the length of the inputs is correct and matches `L`. You can opt-out of length-checking by saying `L=np.inf` in the `__init__`.[^details-on-black-box]
52-
53-
[^details-on-black-box]: You can check the exact implementation in [TODOADD]().
51+
As the code says, the only method you need to define is `_black_box(x: np.ndarray, context: dict = None)`, returning a numpy array of size `[1, 1]`. `AbstractBlackBox` takes it from there, making sure that the length of the inputs is correct and matches `L`. You can opt-out of length-checking by saying `L=np.inf` in the `__init__`.
5452

5553
Black-box functions are wrapped around **problems**. A problem contains not only a black-box objective function, but also the relevant information for the discrete problem: the alphabet, maximum sequence length, whether the sequences are aligned... This next section discusses how to define problem factories, which create instances of the problem.
5654

@@ -86,7 +84,7 @@ class AlohaProblemFactory(AbstractProblemFactory):
8684
alphabet = {symbol: i for i, symbol in enumerate(alphabet_symbols)}
8785

8886
return ProblemSetupInformation(
89-
name="aloha",
87+
name="our_aloha", # To separate it from the "aloha" problem
9088
max_sequence_length=5,
9189
aligned=True,
9290
alphabet=alphabet,
@@ -108,6 +106,12 @@ class AlohaProblemFactory(AbstractProblemFactory):
108106

109107
**and that's it!** Once you have defined your problem factory, you need to register it to be able to call it on-the-go.
110108

109+
:::{note}
110+
The exact implementation of the `aloha` problem is slightly different: we allow users to e.g. query both integers or strings. Integers are interpreted as the token ids according to the alphabet.
111+
112+
Check the exact implementation on [`poli/objective_repository/aloha/register.py`](https://github.com/MachineLearningLifeScience/poli/blob/master/src/poli/objective_repository/aloha/register.py).
113+
:::
114+
111115
## Registering the problem factory
112116

113117
### Creating a conda environment for your problem
@@ -126,15 +130,15 @@ dependencies:
126130
- pip
127131
- pip:
128132
- numpy
129-
- "git+https://github.com/MachineLearningLifeScience/poli.git"
133+
- "git+https://github.com/MachineLearningLifeScience/poli.git@master"
130134
```
131135
132136
:::{admonition} Why conda? Why an entire environment?
133137
:class: dropdown
134138
135139
Using `conda` allows us to package more than Python dependencies. In some examples you might see yourself needing to using e.g. a Java runtime. With `conda`, we can create environments that *include* these dependencies.
136140

137-
For an example, [check the chapter on registering *Super Mario Bros* as a problem factory TODO:ADD]().
141+
For an example, [check the script that registers *Super Mario Bros* as a problem factory](https://github.com/MachineLearningLifeScience/poli/blob/master/src/poli/objective_repository/super_mario_bros/register.py).
138142

139143
:::
140144

@@ -195,7 +199,7 @@ Let's make sure that the problem is registered. The list of registered problems
195199
from poli.core.registry import get_problems
196200
197201
if __name__ == "__main__":
198-
print("aloha" in get_problems())
202+
print("our_aloha" in get_problems())
199203
200204
```
201205

@@ -216,7 +220,7 @@ from poli import objective_factory
216220
if __name__ == "__main__":
217221
# Creating an instance of the problem
218222
problem_info, f, x0, y0, run_info = objective_factory.create(
219-
name="aloha", caller_info=None, observer=None
223+
name="our_aloha", caller_info=None, observer=None
220224
)
221225
print(x0, y0)
222226

0 commit comments

Comments
 (0)