Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
pip install -r requirements.txt

- name: Run notebook scripts
env:
SMOKE_TEST: "true"
run: |
for script in notebooks/*.py; do
if [ -f "$script" ]; then
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased
### Added
- `SMOKE_TEST` switch for notebooks that reduces iteration counts in CI for faster runs
- Notebook on transfer learning
- ~~Notebook on chemical encodings~~ See **Removed**
- CODEOWNERS file
Expand Down
15 changes: 10 additions & 5 deletions notebooks/Coffee_Optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
@app.cell
def _():
import marimo as mo
import os
import warnings

warnings.filterwarnings("ignore")
return (mo,)

# If the SMOKE_TEST environment variable is set (e.g. in CI), iteration counts are
# reduced so the notebook runs quickly. Unset it for full-fidelity results.
SMOKE_TEST = "SMOKE_TEST" in os.environ
return SMOKE_TEST, mo


@app.cell(hide_code=True)
Expand Down Expand Up @@ -216,9 +221,9 @@ def _(campaign_discrete, initial_recommendations):


@app.cell
def _(campaign_discrete, espresso_taste, mo):
def _(SMOKE_TEST, campaign_discrete, espresso_taste, mo):
for iteration in mo.status.progress_bar(
range(20),
range(2 if SMOKE_TEST else 20),
title="Optimizing your espresso",
):
recommendations = campaign_discrete.recommend(batch_size=1)
Expand Down Expand Up @@ -398,10 +403,10 @@ def _(campaign_hybrid, initial_recommendations):


@app.cell
def _(campaign_hybrid, espresso_taste, mo):
def _(SMOKE_TEST, campaign_hybrid, espresso_taste, mo):

for iteration_hybrid in mo.status.progress_bar(
range(20),
range(2 if SMOKE_TEST else 20),
title="Optimizing espresso parameters (hybrid)",
):
recommendation_hybrid = campaign_hybrid.recommend(batch_size=1)
Expand Down
21 changes: 13 additions & 8 deletions notebooks/Goldmining_Demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
@app.cell
def _():
import marimo as mo
import os
import warnings

warnings.filterwarnings("ignore")
return (mo,)

# If the SMOKE_TEST environment variable is set (e.g. in CI), iteration counts are
# reduced so the notebook runs quickly. Unset it for full-fidelity results.
SMOKE_TEST = "SMOKE_TEST" in os.environ
return SMOKE_TEST, mo


@app.cell(hide_code=True)
Expand Down Expand Up @@ -145,7 +150,7 @@ def _(mo):


@app.cell
def _(mine, objective, searchspace):
def _(SMOKE_TEST, mine, objective, searchspace):
import pandas as pd
import numpy as np
from baybe import Campaign
Expand All @@ -161,7 +166,7 @@ def _(mine, objective, searchspace):
random_best_values = []
current_best_random = -np.inf

for _ in range(20):
for _ in range(2 if SMOKE_TEST else 20):
random_rec = random_campaign.recommend(batch_size=1)
random_rec = mine.evaluate(random_rec)
random_campaign.add_measurements(random_rec)
Expand Down Expand Up @@ -192,7 +197,7 @@ def _(mo):


@app.cell
def _(Campaign, mine, np, objective, pd, searchspace):
def _(SMOKE_TEST, Campaign, mine, np, objective, pd, searchspace):
baybe_campaign = Campaign(
searchspace=searchspace,
objective=objective,
Expand All @@ -202,7 +207,7 @@ def _(Campaign, mine, np, objective, pd, searchspace):
baybe_best_values = []
current_best_baybe = -np.inf

for _i in range(20):
for _i in range(2 if SMOKE_TEST else 20):
baybe_rec = baybe_campaign.recommend(batch_size=1)
baybe_rec = mine.evaluate(baybe_rec)
baybe_campaign.add_measurements(baybe_rec)
Expand Down Expand Up @@ -319,11 +324,11 @@ def _(mo):


@app.cell
def _(mine, scenarios):
def _(SMOKE_TEST, mine, scenarios):
from baybe.simulation import simulate_scenarios

N_DOE_ITERATIONS = 4 # Number of optimization iterations per run - incraese to ~30 for better results
N_MC_ITERATIONS = 4 # Number of Monte Carlo runs - incraese to ~30 for better results
N_DOE_ITERATIONS = 2 if SMOKE_TEST else 4 # Number of optimization iterations per run - incraese to ~30 for better results
N_MC_ITERATIONS = 2 if SMOKE_TEST else 4 # Number of Monte Carlo runs - incraese to ~30 for better results

results = simulate_scenarios(
scenarios,
Expand Down
17 changes: 11 additions & 6 deletions notebooks/Reaction_Optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
@app.cell
def _():
import marimo as mo
import os
import warnings

warnings.filterwarnings("ignore")
return (mo,)

# If the SMOKE_TEST environment variable is set (e.g. in CI), iteration counts are
# reduced so the notebook runs quickly. Unset it for full-fidelity results.
SMOKE_TEST = "SMOKE_TEST" in os.environ
return SMOKE_TEST, mo


@app.cell(hide_code=True)
Expand Down Expand Up @@ -320,9 +325,9 @@ def _(mo):


@app.cell
def _(campaign, df, merge_columns, mo):
def _(SMOKE_TEST, campaign, df, merge_columns, mo):
for _ in mo.status.progress_bar(
range(10),
range(2 if SMOKE_TEST else 10),
title="Optimizing reaction conditions",
):
rec = campaign.recommend(5)
Expand Down Expand Up @@ -484,12 +489,12 @@ def _(mo):


@app.cell
def _(df, scenarios):
def _(SMOKE_TEST, df, scenarios):
from baybe.simulation import simulate_scenarios

BATCH_SIZE = 2
N_DOE_ITERATIONS = 12 # Change to ~20 for better plots
N_MC_ITERATIONS = 15 # Change to ~30 for better plots
N_DOE_ITERATIONS = 2 if SMOKE_TEST else 12 # Change to ~20 for better plots
N_MC_ITERATIONS = 2 if SMOKE_TEST else 15 # Change to ~30 for better plots

results = simulate_scenarios(
scenarios,
Expand Down
13 changes: 9 additions & 4 deletions notebooks/Transfer_Learning.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
@app.cell
def _():
import marimo as mo
import os
import warnings

warnings.filterwarnings("ignore")
return (mo,)

# If the SMOKE_TEST environment variable is set (e.g. in CI), iteration counts are
# reduced so the notebook runs quickly. Unset it for full-fidelity results.
SMOKE_TEST = "SMOKE_TEST" in os.environ
return SMOKE_TEST, mo


@app.cell(hide_code=True)
Expand Down Expand Up @@ -311,17 +316,17 @@ def _(mo):


@app.cell
def _(Campaign, data, labs, pd, tl_campaigns):
def _(SMOKE_TEST, Campaign, data, labs, pd, tl_campaigns):
from baybe.simulation import simulate_scenarios

from baybe.utils.random import set_random_seed

N_DOE_ITERATIONS = 5
N_DOE_ITERATIONS = 2 if SMOKE_TEST else 5
BATCH_SIZE = 2
N_MC_ITERATIONS = 2
set_random_seed(1337)

SAMPLE_FRACTIONS = [0.01, 0.05, 0.1, 0.15]
SAMPLE_FRACTIONS = [0.01] if SMOKE_TEST else [0.01, 0.05, 0.1, 0.15]

def optimize_for_lab(
lab: str,
Expand Down
Loading